• Resolved TC.K

    (@wp_dummy)


    I want to have conditional payment gateway based on the cart total amount.

    eg: for amount > 10 , use cc and local gateways (eg fpx, grabpay etc)
    else use CC only.

    I have tried your hooks, wc_stripe_available_payment_gateways

    add_filter('wc_stripe_available_payment_gateways', 'remove_mobile_pay', 99999);
    function remove_mobile_pay($gateways){
        $total = WC()->cart->total;
    }

    But the $total give me 0 values. I have tried WC()->cart->get_cart_subtotal() , WC()->cart->cart_contents_total , WC()->cart->subtotal , All these hooks giving zero (0) amount.

    What did i done wrong?
    Or any other methods to have conditional gateways?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @wp_dummy,

    There isn’t a filter named wc_stripe_available_payment_gateways in this Stripe plugin.

    I recommend you use the filter woocommerce_available_payment_gateways instead.

    Kind Regards,

    Thread Starter TC.K

    (@wp_dummy)

    Oh, my mistake.
    It is wc_stripe_payment_gateways hook.

    But neither woocommerce_available_payment_gateways and wc_stripe_payment_gateways works. Still having the same 0 amount issue from the cart object.

    Plugin Author Payment Plugins

    (@mrclayton)

    @wp_dummy don’t use filter wc_stripe_payment_gateways for what you’re trying to do because it’s too early in the WooCommerce loading cycle for the cart to have data.

    The cart’s totals aren’t calculated until after the checkout shortcode is called.

    The fact that your cart’s total is zero in the woocommerce_available_payment_gateways has nothing to do with the Stripe plugin. I’d make sure you have an item in your cart etc.

    You can always call WC()->cart->calculate_totals(); in your custom function to ensure the cart totals have been calculated. There will be a performance hit to consider though.

    Kind Regards,

    Thread Starter TC.K

    (@wp_dummy)

    i found the problem, it was not from this plugin.
    Thanks for the help though.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional payment methods’ is closed to new replies.