add_filter('woocommerce_package_rates', 'asc_modify_shipping_costs_by_category_old', 100, 2); function asc_modify_shipping_costs_by_category_old($rates, $package) { $shipping_costs = get_option('asc_shipping_costs', []); $special_cats = get_option('asc_special_categories', []); if (!$shipping_costs || !is_array($shipping_costs)) return $rates; $cart_cats = []; foreach ($package['contents'] as $item) { $terms = get_the_terms($item['product_id'], 'product_cat'); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term) { $cart_cats[] = $term->slug; } } } $cart_cats = array_unique($cart_cats); $special_in_cart = array_intersect($cart_cats, $special_cats); $normal_in_cart = array_diff($cart_cats, $special_cats); foreach ($rates as $rate_id => $rate) { $total_cost = 0; $method_slug = false; foreach ($shipping_costs as $cat => $cost_data) { foreach ($cost_data as $method => $price) { if (strpos($rate_id, $method) !== false) { $method_slug = $method; } } } if (!$method_slug) continue; // هزینه دسته خاص + بیشترین هزینه از سایر دسته‌ها $special_total = 0; $normal_max = 0; foreach ($special_in_cart as $cat) { if (isset($shipping_costs[$cat][$method_slug])) { $special_total += floatval($shipping_costs[$cat][$method_slug]); } } foreach ($normal_in_cart as $cat) { if (isset($shipping_costs[$cat][$method_slug])) { $normal_max = max($normal_max, floatval($shipping_costs[$cat][$method_slug])); } } $total_cost = $special_total + $normal_max; if ($total_cost > 0) { $rates[$rate_id]->cost = $total_cost; $rates[$rate_id]->taxes = false; } } return $rates; } add_filter('woocommerce_package_rates', 'asc_modify_shipping_costs_fixed_special', 100, 2); function asc_modify_shipping_costs_fixed_special($rates, $package) { $shipping_costs = get_option('asc_shipping_costs', []); if (!$shipping_costs || !is_array($shipping_costs)) return $rates; $special_slugs = ['محافظ-صفحه-تلویزیون', 'wall-mount']; $cart_cats = []; foreach ($package['contents'] as $item) { $terms = get_the_terms($item['product_id'], 'product_cat'); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term) { $cart_cats[] = $term->slug; } } } $cart_cats = array_unique($cart_cats); $has_special_1 = in_array('محافظ-صفحه-تلویزیون', $cart_cats); $has_special_2 = in_array('wall-mount', $cart_cats); foreach ($rates as $rate_id => $rate) { $method_slug = false; foreach ($shipping_costs as $cat => $cost_data) { foreach ($cost_data as $method => $price) { if (strpos($rate_id, $method) !== false) { $method_slug = $method; } } } if (!$method_slug) continue; $total = 0; $counted = []; foreach ($cart_cats as $cat) { if (isset($shipping_costs[$cat][$method_slug]) && in_array($cat, $special_slugs)) { $total += floatval($shipping_costs[$cat][$method_slug]); $counted[] = $cat; } } if (!empty($counted)) { // دسته‌های خاص باهم یا با دیگران => جمع قیمت‌ها foreach ($cart_cats as $cat) { if (!in_array($cat, $special_slugs) && isset($shipping_costs[$cat][$method_slug])) { $total += floatval($shipping_costs[$cat][$method_slug]); break; } } $rates[$rate_id]->cost = $total; $rates[$rate_id]->taxes = false; } } return $rates; } رابط صدا - پیکاوکالا
حساب کاربری
0
سبد خرید
سبد خرید شما خالی است

رابط صدا

فیلتر بر اساس وضعیت موجودی
فیلتر بر اساس قیمت
فیلتر بر اساس امتیاز
فیلترهای فعال

کابل رابط 2 به 1 صدا

52,000
60,000تومان
جستجو در سایت
Loading...
کلمات کلیدی پیشنهادی اپل لنوو شیائومی لپ تاپ اسپیکر بلوتوثی کیبورد بی سیم party box kts
[device_search_form]
موجود است، هم اکنون می توانید سفارش دهید!
ناموجود!