Answer the question
In order to leave comments, you need to log in
Exclude woocommerce discounted products?
Hello.
There is such a script. It displays the discount in the cart.
How can I make sure that goods for which the promotional price is not included in this condition?
foreach(WC()->cart->get_cart() as $cart_item ){
$product_price = get_post_meta( $cart_item['product_id'], 'woo_second_price', true );
$products_total += $product_price * $cart_item['quantity'];
}
if($products_total < 47.5) {
$sale = 47.5 - $products_total;
echo "Чтобы получить скидку 20% добавьте к заказу товаров ещё на {$sale} CV";
}
else if($products_total >= 47.5 && $products_total <= 94) {
$sale = 95 - $products_total;
echo "Чтобы получить скидку 30% добавьте к заказу товаров ещё на {$sale} CV";
} else if($products_total >= 95 && $products_total <= 189) {
$sale = 190 - $products_total;
echo "Чтобы получить скидку 40% добавьте в корзину товаров на {$sale} CV";
} else if($products_total >= 190 && $products_total <= 474) {
$sale = 475 - $products_total;
echo "Чтобы получить подарок 95 CV добавьте к заказу товаров ещё на {$sale} CV";
} else if($products_total >= 475) {
echo 'Вам положен подарок на 95 CV. Наш менеджер поможет Вам их выбрать.';
}
Answer the question
In order to leave comments, you need to log in
what is the woo_second_price field x.s
but the discounted price is stored in the _sale_price field
respectively:
foreach(WC()->cart->get_cart() as $cart_item ){
$sale = get_post_meta( $cart_item['product_id'], '_sale_price', true );
if(! isset($sale) ) :
$product_price = get_post_meta( $cart_item['product_id'], 'woo_second_price', true );
$products_total += $product_price * $cart_item['quantity'];
endif:
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question