Скидка
-
add_action( 'woocommerce_cart_calculate_fees', 'custom_discount_for_pickup_shipping_method', 10, 1 ); function custom_discount_for_pickup_shipping_method( $cart) { $percentage = 10; $categories = array('pizza'); foreach($cart->get_cart() as $cart_item) { if (has_term( $categories , 'product_cat' , $cart_item['product_id'])) { $discount = ($cart_item['data']->get_price('edit') * $cart_item['quantity'] * $percentage)/100; if($discount > 0){ $cart->add_fee( __('Cкидка') . ' (' . $percentage . '%)', -$discount = round( $discount, 1 , PHP_ROUND_HALF_DOWN) ); } } } }
Просмотр 3 ответов — с 1 по 3 (всего 3)
Просмотр 3 ответов — с 1 по 3 (всего 3)
- Тема «Скидка» закрыта для новых ответов.