某些用户收到通知,如果他们花费500美元,就可以免费送货。
但是,我们免费将产品免费交付给当地人,因此不需要此通知就可以表明他们是否是本地客户。
我试图将PHP脚本设置为仅显示是否正在使用某种运送方式,但该方式无法正常工作。
add_action( 'woocommerce_before_cart','bbloomer_free_shipping_cart_notice' );
function bbloomer_free_shipping_cart_notice() {
$min_amount = 500; //change this to your free shipping threshold
$current = WC()->cart->subtotal;
if ( is_user_logged_in() && current_user_can('wholesale_user') || current_user_can('wholesale_terms' ) || current_user_can('craft_brewery_user') && $chosen_shipping ='flexible_shipping_7_1' && $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' );
}
}