如何定义单个产品的交付方式?

时间:2019-01-09 16:49:31

标签: php wordpress woocommerce shipping

我正在尝试通过ID为给定产品设置“提货地点”。但是,我只找到了免运费的方法。

function wcs_my_free_shipping( $is_available ) {
    global $woocommerce;

    // set the product ids that are eligible
    $eligible = array( '6260' );

    // get cart contents
    $cart_items = $woocommerce->cart->get_cart();
    // loop through the items looking for one in the eligible array
    foreach ( $cart_items as $key => $item ) {
        if( in_array( $item['product_id'], $eligible ) ) {
            return true;
        }
    }

    // nothing found return the default value
    return $is_available;
}
add_filter( 'woocommerce_shipping_free_shipping_is_available', 'wcs_my_free_shipping', 20 );

0 个答案:

没有答案