Skip to content
Advertisement

Discount cart item price excluding a category and its children in WooCommerce

The fact is that the customer asks for a 50% discount for “Local Pickup” – I have already done this (I found a code here on StackOverFlow that applies a discount on all goods), but there is one more condition – this discount should not be applied to two categories goods. Sorry for Russian image;)

I tried to go through each product in the list of orders, and check whether it belongs to a certain category or not through various operators (is_category, in_category, has_term), but it didn’t work. What am I doing wrong? (id = 37 is the id of the Premium rolls category)

JavaScript

Advertisement

Answer

Updated

There are some mistakes in your code. The code below will apply a discounted price on cart items from specific product category (and its children):

JavaScript

Code goes in functions.php file of the active child theme (or active theme). It should works.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement