Home > Wordpress > Woocommerce hide flat rate when free shipping

Woocommerce hide flat rate when free shipping

Khi thiêt kế web bán hàng với plugin Woocommerce trên WordPress, bạn chi muốn hiển thị 1 trong các tùy chọn về phí giao hàng.

Ví dụ:

– Nếu tổng đơn hàng > 700.000 đ thì hiện Free Shipping
– Nếu tổng đơn hàng < 700.000 đ hiện Flat rate 30.000 đ (phí giao hàng charge thêm 30 ngàn)

 

 

 


// Hide standard shipping option when free shipping is available
add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 );

/**
 *  Hide Standard Shipping option when free shipping is available
 *
 * @param array $available_methods
 */
function hide_standard_shipping_when_free_is_available( $available_methods ) {

    if( isset( $available_methods['free_shipping'] ) AND 
        isset( $available_methods['flat_rate'] ) ) {

        // remove standard shipping option
        unset( $available_methods['flat_rate'] );
    }

    return $available_methods;
}

Chúc các bạn thành công

nhantam
công ty làm web app Panpic.vn

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: