15 1 0 4000 1 https://codeblock.co.za 300 true 0
theme-sticky-logo-alt

set_payment_method()

0 Comments

Framework / CMS

WooCommerce [Version: Since 3.0.0]

Syntax

Typical Usage

Sets the payment method for a WooCommerce order.

Accepted Parameters

  • payment_method (string) (Optional) (Default = none): The payment method.

Return Value(s)

Mixed.

Notes

payment_method() supports WC_Payment_Gateway for backward compatibility with  versions before 3.0.

Examples of set_payment_method()

Example 1

<?php
$user_id = get_current_user_id(); 

$args = array(
    'customer_id'   => $user_id
);

$gateways = WC()->payment_gateways->payment_gateways();

$new_order->set_payment_method( $gateways['bacs'] );

Was This Helpful?

Previous Post
payment_gateways()
Next Post
calculate_totals()

0 Comments

Leave a Reply