我在 WordPress 安装中对 WooCommerce 进行了自定义。
我有类似的东西:
/**
* Disable free shipping for select products
*
* @param bool $is_available
*/
function my_free_shipping( $is_available ) {
global $woocommerce;
// set the product ids that are ineligible
$ineligible = array( '14009', '14031' );
// get cart contents
$cart_items = $woocommerce->cart->get_cart();
// loop through the items looking for one in the ineligible array
foreach ( $cart_items as $key => $item ) {
if( in_array( $item['product_id'], $ineligible ) ) {
return false;
}
} …Run Code Online (Sandbox Code Playgroud) 在 WooCommerce 3 中,我有这些运输选项(设置):
free_shipping:1- 最低订单金额设置为$50。flat_rate:3- 金额$5。flat_rate:5- 金额$10。我希望快递运输选项始终可用(如图所示)。
但是当免费送货可用时(意味着客户在购物车中的金额超过 50 美元),我只想隐藏 正常送货。
所以,当Free shipping是不提供(或隐藏),可用的运费将是正常的运输和快递运输。
那可能吗?我怎样才能在 WooCommerce 3 上获得这个?