Забронировать

Г. Екатеринбург ул. Радищева д. 23 +7(343) 257-25-56

Бронированиестолика








    Манты

    29.10.2018



    ×
    function woo_discount_total(WC_Cart $cart) { if(is_admin() && !defined('DOING_AJAX')) { return; } global $woocommerce; $delivery_name = ''; $delivery_selected = []; $available_methods = $woocommerce->shipping->get_packages(); if(isset($woocommerce->session)) { $delivery_selected = $woocommerce->session->get('chosen_shipping_methods'); } foreach($available_methods as $method) { foreach($delivery_selected as $delivery) { if(isset($method['rates'][$delivery])) { $delivery_name = $method['rates'][$delivery]->label; break; } } } if($delivery_name == 'Самовывоз') { $discount = $cart->subtotal * 0.10; // 0.05 - это 5% $cart->add_fee('Скидка в 10% за самовывоз ', -$discount); } } add_action('woocommerce_cart_calculate_fees' , 'woo_discount_total');