php - Null the price of a Specific Product category from Cart Total -


i want remove / takeout price of specific category products cart total.

please see screenshot:

cart page

what hook use this?

thanks.

the right hook woocommerce_before_calculate_totals using has_term() wordpress conditional function filter product categories in cart items. way can null price cart items.

this code:

add_action( 'woocommerce_before_calculate_totals', 'custom_price_product_category', 10, 1 ); function custom_price_product_category( $cart_object ) {      foreach ( $cart_object->cart_contents $key => $item ) {         // when product has 'glass' category null price.         if( has_term( 'posters', 'product_cat', $item["product_id"] ) )             $item['data']->price = '0';     } } 

this goes in function.php file of active child theme (or theme) or in plugin file.

this code tested , works.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -