특정 플러그인에 대한 업데이트 :
add_filter('woocommerce_package_rates', 'custom_free_shipping_option', 15, 2);
function custom_free_shipping_option($rates, $package){
// HERE set the "minimum order amount" for free shipping
$limit = 500;
$free_total = 0;
// Get the cart content total excluding virtual products
foreach(WC()->cart->get_cart() as $cart_item)
if(! $cart_item['data']->is_virtual())
$free_total += $cart_item['line_total'];
// Set the cost to 0 based on specific cart content total
if($free_total > $limit)
foreach ($rates as $rate_key => $rate)
if('pakkelabels_shipping_gls' === $rate->method_id)
$rates[$rate->id]->cost = 0;
return $rates;
}
코드 활성 자식 테마 (또는 테마)의 function.php 파일에 간다 나 또한 어떤 플러그인 파일입니다.
특정 배송 방법으로 작동해야합니다.
원래 대답(클래식 "무료 배송"방식) 다음은
가상 제품 제외 배송 방법 무료 배송 "최소 주문 금액"옵션을 대체 할 필요한 코드입니다 :
add_filter('woocommerce_package_rates', 'custom_free_shipping_option', 10, 2);
function custom_free_shipping_option($rates, $package){
// HERE set the "minimum order amount" for free shipping
$limit = 500;
$free_total = 0;
// Get the cart content total excluding virtual products
foreach(WC()->cart->get_cart() as $cart_item)
if(! $cart_item['data']->is_virtual())
$free_total += $cart_item['line_total'];
// Disabling free shipping method based on specific cart content total
if($free_total < $limit)
foreach ($rates as $rate_key => $rate)
if('free_shipping' == $rate->method_id)
unset($rates[ $rate_key ]);
return $rates;
}
코드는 활성 자녀 테마 (또는 테마)의 function.php 파일 또는 모든 플러그인 파일에 있습니다.
테스트 및
그래서 당신도 무료 배달 설정에서이 옵션을 제거 할 수 있습니다 작업.
작동하지 않습니다 - 내 잘못입니다. 우리는 WooCommerce 무료 배송 옵션을 사용하지 않습니다. 우리는 3 종류의 배달 (가게, 집, 비지니스)이있는 플러그인을 가지고 있습니다. 500 명 이상을 지불하면 첫 번째 옵션은 무료 배송이됩니다. 이것은 이미 작동하지만 현재 가상 제품을 추가 할 수 있으며이 500 한계에 포함됩니다. 아마도 위의 코드는 관련된 특정 전달 옵션을 사용해야할까요? 500 이상 지출시 무료 배달을 제공하는 배달 옵션의 값/이름은 pakkelabels_shipping_gls1입니다. 어쨌든 우리는 가상 제품을이쪽으로 세지 않도록 제외하면됩니다. – eMikkelsen
물론 그럴 겁니다. 많은 사람들을 도울 것입니다. 그럼 끝났어. 보낸 새 코드가 여전히 작동하지 않습니다. 이 플러그인으로 작동하게 할 수있는 방법이 있습니까? 그것은 덴마크의 모든 사람의 90 %가 사용하고 Pakkelabels라고 불리므로 다소 유용 할 것입니다. 필요한 추가 ID, 값 또는 정보를 제공 할 수 있습니다. – eMikkelsen
추가 조사 후. 코드는 옵션을 완전히 제거합니다. 옵션의 일부만 변경하는 것이 아닙니다. 기본적으로 방법은 다음과 같습니다. 상점으로의 배송 비용은 49입니다. 499를 지불하는 경우 무료입니다. 여기서 우리는 499에 포함되지 않는 선물 카드가 필요합니다. – eMikkelsen