douhanshu5517 2018-08-15 17:32
浏览 64

根据运费表费率选项隐藏woocommerce结账时的送货地址

I have been working to hide my woocommerce checkout shipping address if a user selects a shipping table rate option that has a Label of "Local Pickup". Most code snippets I have found trigger based on shipping_method. I tried a shipping-method like `table_rate:10:1', to no avail. Any ideas?

Also, I am not completely clear on how to designate the specific row in the table - I inspected the code and found the value above, but am unsure if its correct.

Shipping related plug-ins: Woocommerce Table Rate Shipping

Trying to use the following code as a base:

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;
}

website: camp4coffee.com

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退