WPSlash Licences

Disable Tipping for Virtual Products

Disable Tipping for Virtual Products – code snippet guide from WPSlash
Published
Updated
Reading time
1 minutes
Written by
WPSlash team
Code
add_filter("wpslash_tipping_enabled_filter", "wpslash_tipping_enabled_filter");
function wpslash_tipping_enabled_filter($bool)
{
	global $woocommerce;
	foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
   $product = $cart_item['data'];
   $product_id = $cart_item['product_id'];
   $quantity = $cart_item['quantity'];
   $price = WC()->cart->get_product_price( $product );
   $subtotal = WC()->cart->get_product_subtotal( $product, $cart_item['quantity'] );
   $link = $product->get_permalink( $cart_item );
   // Anything related to $product, check $product tutorial
   $meta = wc_get_formatted_cart_item_data( $cart_item );
		
		if ($product->is_virtual('yes')) {
        	return true;


    }
}
	return false;
}
TippingAccept tips and donations at checkout with fixed or free amounts, reported separately in orders.$79 for one site
All guides

Tipping for WooCommerce11 min read

How to Accept Tips and Donations on Your Website

Add a tip or donation option to your WooCommerce checkout, choose a plugin that fits, and avoid the mistakes that cost you contributions.

The plugins these guides are about

FoodMaster for restaurants, courier vouchers for the Greek market, marketplace sync and store tools, all for WooCommerce.

Browse plugins30-day money-back on every plugin