0

如果用户选择具有“本地取货”标签的运输表费率选项,我一直在努力隐藏我的 woocommerce 结帐送货地址。我发现的大多数代码片段都是基于 shipping_method 的触发器。我尝试了类似 `table_rate:10:1' 的运输方法,但无济于事。有任何想法吗?

此外,我并不完全清楚如何指定表格中的特定行 - 我检查了代码并找到了上面的值,但不确定它是否正确。

发货相关插件:Woocommerce Table Rate Shipping

尝试使用以下代码作为基础:

add_filter( 'woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields' );
function xa_remove_billing_checkout_fields( $fields ) {
    global $woocommerce;

    // Set the desired shipping method to hide the checkout field(s).
    $shipping_method = 'table_rate:10:1';

    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    $chosen_shipping = $chosen_methods[0];

    if ( $chosen_shipping == $shipping_method ) {
        // Add/change field name to be hide
        unset($fields['billing']['billing_address_1']); 
        unset($fields['billing']['billing_address_2']);
    }
    return $fields;
}

网站: camp4coffee.com

4

0 回答 0