1

I'm setting up a store for a client with multiples user roles. One of them need to have prices of 0$ because the company's billed monthly. Others roles have to pay differents prices with multipliers depending on their roles using "Product Price by User Role".

Anyway, when a user buy some products for 0$ the COD method's not showing and i need that payment gateway to set a custom status.

Anyone encountered the problem before? If so, any guidance is appreciated!

7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
Vinnie
  • 21
  • 6

1 Answers1

2

"Anyone encountered the problem before?". This is default behavior in WooCommerce

To prevent this, use:

// Looks at the totals to see if payment is actually required.
function filter_woocommerce_cart_needs_payment( $needs_payment, $cart ) {
    // Set true
    $needs_payment = true;
    
    return $needs_payment;
}
add_filter( 'woocommerce_cart_needs_payment', 'filter_woocommerce_cart_needs_payment', 10, 2 );

Or in short

add_filter( 'woocommerce_cart_needs_payment', '__return_true' );

AND

// Checks if an order needs payment, based on status and order total.
function filter_woocommerce_order_needs_payment( $needs_payment, $order, $valid_order_statuses ) {  
    // Set true
    $needs_payment = true;

    return $needs_payment;
}
add_filter( 'woocommerce_order_needs_payment', 'filter_woocommerce_order_needs_payment', 10, 3 );

Or in short

add_filter( 'woocommerce_order_needs_payment', '__return_true' );
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50