Thank you for the reply, that may be beyond my abilities but I will play around with it sometime!
Thanks for the plugin as well.
Hi Karolina, I don’t expect you to offer free support but thought I would ask. I am trying this code and getting errors, but I am guessing at some of the terms:
/** Woocommerce – don’t add Stripe fee if only a free purchase
*/
function my_pay4pay_handle_free( $do_apply , $amount , $cart_subtotal , $current_payment_gateway ) {
if ( amount_is_0() )
return false;
else
return $do_apply;
}
add_filter( “woocommerce_pay4pay_apply”, ‘my_pay4pay_handle_free’ , 10 , 4 );
Hi @lh23, could you send me as well the amout_is_0()
function? I will test it.
Hi @vyskoczilova,
I am just trying to tell it that if the cart subtotal is zero, not to apply the fee.
/** Woocommerce â donât add Stripe fee if only a free purchase
*/
function my_pay4pay_handle_free( $do_apply , $amount , $cart_subtotal , $current_payment_gateway ) {
if ($cart_subtotal == 0)
return false;
else
return $do_apply;
}
add_filter( âwoocommerce_pay4pay_applyâ, âmy_pay4pay_handle_freeâ , 10 , 4 );
I think the two things I’m having trouble with are getting the cart subtotal:
if ($cart_subtotal == 0)
I have also tried: WC()->cart->subtotal == 0
Also, does this code go in functions.php or class-pay4play.php
Thanks again
Hi @lh23,
I understood what are you trying to achieve, but I wanted to know how it was checked to be able to catch the problem. This one should work fine for you:
/** Woocommerce â donât add Stripe fee if only a free purchase
*/
function my_pay4pay_handle_free( $do_apply , $amount , $calculation_base , $current_payment_gateway ) {
$cart = WC()->cart;
if ( wc_prices_include_tax() ) {
$subtotal = intval( $cart->subtotal );
} else {
$subtotal = intval( $cart->subtotal_ex_tax );
}
if ($subtotal == 0) {
return false;
} else {
return $do_apply;
}
}
add_filter( "woocommerce_pay4pay_apply", "my_pay4pay_handle_free" , 10 , 4 );
Add it to your functions.php.
Have a nice weekend!
Karolina
That did it! Thank you so much. Same to you!!
Great! If you are enjoying my support, feel free to give a review or donation for plugin development.