Answer the question
In order to leave comments, you need to log in
How to make a discount in woocmomerce?
Hello! Please tell me how to make a discount when placing an order, for example, for a table and 4 chairs 10%.
On the Internet, I found a function for a discount only from the number of goods in the basket, but here you need to unlock the number of categories in the basket
, this is what I found:
function woo_discount_total(WC_Cart $cart) {
if(is_admin() && !defined('DOING_AJAX')) {
return;
}
$woo_count_item = $cart->get_cart_contents_count(); // Количество товаров в корзине
if($woo_count_item >= 3 && $woo_count_item <= 50) {
$discount = $cart->subtotal * 0.05;
$cart->add_fee('Скидка в 5% за заказ включающий в себя от 3 товаров ', -$discount);
} elseif($woo_count_item > 100000) {
$discount = $cart->subtotal * 0.05;
$cart->add_fee('Скидка в 5% за заказ включающий в себя от 3 товаров ', -$discount);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question