Title: Zero charge for certain items
Last modified: January 18, 2018

---

# Zero charge for certain items

 *  Resolved [lh23](https://wordpress.org/support/users/lh23/)
 * (@lh23)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/)
 * Hi Karolina,
    I have some free virtual products in my store. Usually this isn’t
   a problem for your plugin because someone will buy them along with a paid product.
   However sometimes they will buy only the free item and are being charged a 30
   cent fee (the fixed charge part of the fee).
 * Is there a way to disable charging a fee on a per-product basis?
 * Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Karolina Vyskocilova](https://wordpress.org/support/users/vyskoczilova/)
 * (@vyskoczilova)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9878937)
 * Hi [@lh23](https://wordpress.org/support/users/lh23/),
 * have a look on following filter and implement it as you want 🙂
 * [https://github.com/vyskoczilova/woocommerce-payforpayment#filter-woocommerce_pay4pay_apply](https://github.com/vyskoczilova/woocommerce-payforpayment#filter-woocommerce_pay4pay_apply)
 * Best regards,
    Karolina
 *  Thread Starter [lh23](https://wordpress.org/support/users/lh23/)
 * (@lh23)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9879035)
 * 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.
 *  Thread Starter [lh23](https://wordpress.org/support/users/lh23/)
 * (@lh23)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9918573)
 * 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 );
 *  Plugin Author [Karolina Vyskocilova](https://wordpress.org/support/users/vyskoczilova/)
 * (@vyskoczilova)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9933291)
 * Hi [@lh23](https://wordpress.org/support/users/lh23/), could you send me as well
   the `amout_is_0()` function? I will test it.
 *  Thread Starter [lh23](https://wordpress.org/support/users/lh23/)
 * (@lh23)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9934337)
 * Hi [@vyskoczilova](https://wordpress.org/support/users/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
 *  Plugin Author [Karolina Vyskocilova](https://wordpress.org/support/users/vyskoczilova/)
 * (@vyskoczilova)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9934427)
 * Hi [@lh23](https://wordpress.org/support/users/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
 *  Thread Starter [lh23](https://wordpress.org/support/users/lh23/)
 * (@lh23)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9934581)
 * That did it! Thank you so much. Same to you!!
 *  Plugin Author [Karolina Vyskocilova](https://wordpress.org/support/users/vyskoczilova/)
 * (@vyskoczilova)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9934652)
 * Great! If you are enjoying my support, feel free to give a review or donation
   for plugin development.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Zero charge for certain items’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pay-for-payment/assets/icon-256x256.png?rev=
   2541841)
 * [Pay for Payment for WooCommerce](https://wordpress.org/plugins/woocommerce-pay-for-payment/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pay-for-payment/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/reviews/)

## Tags

 * [exclude products](https://wordpress.org/support/topic-tag/exclude-products/)

 * 8 replies
 * 2 participants
 * Last reply from: [Karolina Vyskocilova](https://wordpress.org/support/users/vyskoczilova/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/zero-charge-for-certain-items/#post-9934652)
 * Status: resolved