2013-10-15 2 views
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; 
} 


?> 

답변

0

나는 고급 사용자 구성을 허용 플러그인을했습니다에 woocommerce의 조각입니다. 그것은 단지 미국의 주를 포함하지만, 국가 및 우편 번호 조건을 구성 할 수 있습니다.

이 요구 사항이 충족되는지는 잘 모르겠지만 확인해 볼 가치가 있습니다. http://wordpress.org/plugins/woocommerce-advanced-free-shipping/