Notice mua thêm được freeship

In cart page

Add code to function.php

function notice_freeship(){
    global $woocommerce;
    $free_shipping = get_option( 'woocommerce_free_shipping_11_settings' ); //woocomrce_free_shipping_[id coupon giảm giá]_settings
    $min = $free_shipping['min_amount'];
    $current = WC()->cart->subtotal;
    if ( $current < $min ) {
      echo '<div class="text-center freeship-title">Chỉ cần mua thêm <span class="price-freeship">'.wc_price($min - $current).'</span> nữa đơn hàng sẽ được <span class="label-freeship">MIỄN PHÍ VẬN CHUYỂN</span></div>';
     } else {
       echo '<div class="text-center freeship-title freeship-success">Chúc mừng! Đơn hàng của bạn đã được <span class="label-freeship">MIỄN PHÍ VẬN CHUYỂN</span></div>';
     }
}
add_action('woocommerce_after_cart_contents','notice_freeship');

Add style css

/* NOTICE FREE SHIP CART PAGE **/
.freeship-title{
    padding: 15px 0;
    background: #2998f7;
    border-radius: 5px; 
    margin-bottom: 20px; 
    color: #fff;
}
.freeship-title .label-freeship,
.freeship-title span.price-freeship bdi { 
    font-size: 18px;
    font-weight: bold;
    color: #ffd012;
}
@media (max-width:680px){
    .freeship-title .label-freeship,
    .freeship-title span.price-freeship bdi { 
    font-size: 15px;
    font-weight: bold;
    color: #ffd012;
}
}
/* END NOTICE FREESHIP CART PAGE */

Last updated