2014-10-04 3 views
0

무료 배송이 내 WooCommerce 장바구니에 활성화되어 있으면 사람들에게 "안녕하세요, 무료 배송이 있습니다!"라고 말하고 싶습니다. 무료 배송은 주문 금액 또는 쿠폰 중 하나로 활성화 할 수 있습니다.WooCommerce 무료 배송이 활성화되어 있는지 확인하십시오.

이 코드를 시도했지만 빈 배열을 반환합니다.

global $woocommerce; 
$woocommerce->shipping->get_shipping_methods(); 

그렇지 않으면 free_shipping이 설정되었는지 확인할 수 있습니다.

여러분 모두가이 작업 :

답변

0
global $woocommerce; 
$shipping_methods = $woocommerce->shipping->load_shipping_methods(); 
if($shipping_methods['free_shipping']->enabled == "yes") 
{ 
    $cart_total_amount = floatval(preg_replace('#[^\d.]#', '', $woocommerce->cart->get_cart_total())); 

    if($shipping_methods['free_shipping']->min_amount <= $cart_total_amount) echo "Hey, you've got free shipping!"; 
    else echo "Free shipping on all orders of " . $shipping_methods['free_shipping']->min_amount . get_woocommerce_currency_symbol() . "+"; 
} 
활용하는 방법을 몇 가지 좋은 아이디어를 가지고 희망
관련 문제