WooCommerce:在购物车中显示“您只需支付$$即可获得免费送货!”

这是一个非常酷的代码段,很多人应该使用它来增加平均订单价值。接近“免费送货”门槛的电子商务客户将尝试向购物车中添加更多产品,以便有资格获得免费送货。这是纯粹的心理学。

这是我们在WooCommerce购物车页面上显示一条简单消息的方式。
仿牌独立站出海专家


add_action( 'woocommerce_before_cart', 'bbloomer_free_shipping_cart_notice' );
  
function bbloomer_free_shipping_cart_notice() {
  
   $min_amount = 50; //change this to your free shipping threshold
   
   $current = WC()->cart->subtotal;
  
   if ( $current < $min_amount ) {
      $added_text = 'Get free shipping if you order ' . wc_price( $min_amount - $current ) . ' more!';
      $return_to = wc_get_page_permalink( 'shop' );
      $notice = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), 'Continue Shopping', $added_text );
      wc_print_notice( $notice, 'notice' );
   }
  
}