1
을 제외 woocommerce 그들이 woocommerce를 통해 제공하는 무료 배송 계약에서. 내 테마 function.php 또는 플러그인 형식을 통해 입력하면 오류가 발생합니다.내가 woocommerces 무료 배송 (호주 사이트)에서 상태를 제외 니펫을하지만,이 오류로 실행하고 구현하기 위해 노력하고있어 국가 무료 배송 (호주 주)
다음 방법을 사용해 보았습니다.
How can I disable free shipping for particular states?
이 플러그인
/**
* Hide ALL shipping options when free shipping is available and customer is NOT in certain states
* Hide Free Shipping if customer IS in those states
*
* Change $excluded_states = array('AK','HI','GU','PR'); to include all the states that DO NOT have free shipping
*/
add_filter('woocommerce_available_shipping_methods', 'hide_all_shipping_when_free_is_available' , 10, 1);
/**
* Hide ALL Shipping option when free shipping is available
*
* @param array $available_methods
*/
function hide_all_shipping_when_free_is_available($available_methods) {
$excluded_states = array('WA');
if(isset($available_methods['free_shipping']) AND !in_array($woocommerce->customer->get_shipping_state(), $excluded_states)) :
// Get Free Shipping array into a new array
$freeshipping = array();
$freeshipping = $available_methods['free_shipping'];
// Empty the $available_methods array
unset($available_methods);
// Add Free Shipping back into $avaialble_methods
$available_methods = array();
$available_methods[] = $freeshipping;
endif;
if(isset($available_methods['free_shipping']) AND in_array($woocommerce->customer->get_shipping_state(), $excluded_states)) {
// remove free shipping option
unset($available_methods['free_shipping']);
}
return $available_methods;
}
?>