【问题标题】:Woocommerce checkout with edit address layout带有编辑地址布局的 Woocommerce 结帐
【发布时间】:2019-07-22 06:05:23
【问题描述】:

因此,当您结帐时,您会看到所有帐单字段输入,但我想删除所有这些并显示一张卡片,例如基于“我的帐户”/“编辑地址”的“编辑”按钮。这可能吗?

基本上我需要在帐单字段的地方弹出该卡。有什么建议吗?

我已经在使用Hide billing address from checkout page but keep the information答案码了。

【问题讨论】:

    标签: php wordpress woocommerce field checkout


    【解决方案1】:

    所以,

    我已经使用了我在问题上放置的代码,并将其也添加到了我的 functions.php 文件中:

    function action_woocommerce_after_checkout_billing_form( $wccs_custom_checkout_field_pro ) {
    
        if (is_user_logged_in()){
            $customer_id = get_current_user_id();
            $address = get_user_meta( $customer_id, 'billing_address_1', true );
            if (!empty($address)){          
                echo '<style>.woocommerce-billing-fields__field-wrapper {display: none;}</style>';
                echo '<div class="checkoutaddress">
                        <a href="#" class="edit">'. __( 'Edit', 'woocommerce' ).'</a>
                        <h3>'. __( 'Billing address', 'woocommerce' ) .'</h3>
                    <address>'.
                get_user_meta( $customer_id, 'billing_first_name', true ).' '.
                get_user_meta( $customer_id, 'billing_last_name', true )    .'<br>'.
                get_user_meta( $customer_id, 'billing_phone', true ).'<br>'.
                $address.'<br>'.
                get_user_meta( $customer_id, 'billing_postcode', true ).' '.
                get_user_meta( $customer_id, 'billing_city', true ).'<br>'.
                get_user_meta( $customer_id, 'billing_state', true )
                    .'</address>
                </div>';
            }
        }
    
    }; 
    add_action( 'woocommerce_after_checkout_billing_form', 'action_woocommerce_after_checkout_billing_form', 10, 1 );
    

    它将检查用户是否已登录(否则显示字段),然后检查帐单地址是否已填写(否则也会显示字段)

    希望这对某人有所帮助。这不是一个很好的解决方案,但它有效!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2016-01-10
      • 2020-03-26
      • 2021-06-12
      • 2020-08-07
      • 1970-01-01
      相关资源
      最近更新 更多