Based on this answer (code below)을 숨겨 사용할 수, 나는 성공적으로 특정 제품 카테고리 및 로컬 배달 옵션에서 고정 요금을 숨길 수없는 지역 픽업 옵션을 사용할 수 있습니다. 이것은 완벽하게 작동합니다.배송 방법 - 고정 요금이
문제 :지역 픽업 옵션은 특정 범주에 대한 사용할 수 없습니다.
로컬 픽업 옵션을이 특수한 범주에서 사용하려면 어떻게해야합니까?
이
내가 사용하는 코드입니다 :function custom_shipping_methods($rates){
// Define/replace here your correct category slug (!)
$cat_slug = 'your_category_slug';
$prod_cat = false;
// Going through each item in cart to see if there is anyone of your category
foreach (WC()->cart->get_cart() as $values) {
$item = $values['data'];
if (has_term($cat_slug, 'product_cat', $item->id))
$prod_cat = true;
}
$rates_arr = array();
if ($prod_cat) {
foreach($rates as $key => $rate) {
if ('free_shipping' === $rate->method_id || 'local_pickup' === $rate->method_id || 'local_delivery' === $rate->method_id) {
$rates_arr[ $rate_id ] = $rate;
break;
}
}
}
return !empty($rates_arr) ? $rates_arr : $rates;
}
add_filter('woocommerce_package_rates', 'custom_shipping_methods', 100);
한가지 더 :이 보여줄 수 있나요 로컬 배달과 위치에 따라 특별한 범주에 대한 지역 픽업?
현재 내 상점 로컬 픽업 또는 배송은 하나의 위치에서만 설정됩니다.
좋아요. 고맙습니다. 그것은 완벽하게 일했습니다 :) –
@ ZahidIqbal 어리석은 실수와'휴식;'... 주변에서 보자 :) ... – LoicTheAztec