• Resolved John Doe

    (@heartbreakkid58)


    Hi Team CheckoutWC,

    Thank you for this amazing plugin. I have a very confusing question regarding the Checkout process where user selects “Use a different billing address”. The WooCommerce creates account based on the Billing Address, but we want the new customer account will always recreated with the Shipping Address Details. The functionality is fine when the “Same as shipping address” option is selected. So, the situation is, any other family member can enter the Billing address and payment details of himself, for his younger sibling (in Shipping address), and we want system forcefully creates the account based on the Shipping address.

    Alternative solution is to switch the Billing and Shipping fields (which I have tried), but it only works when we enter both address fields (on single billing it give required fields errors).

    Please help and advise me on this. Many thanks.
    Regards.

Viewing 1 replies (of 1 total)
  • Plugin Author Clifton Griffin

    (@clifgriffin)

    Hi John,

    I think you would need to use this WooCommerce action:

    woocommerce_checkout_update_customer

    It receives the customer object, so you could make updates to the customer with this hook.

    For example, this is how they set the first and last name before that action hook is called:

    if ( ! empty( $data['billing_first_name'] ) && '' === $customer->get_first_name() ) {
    				$customer->set_first_name( $data['billing_first_name'] );
    			}
    
    			if ( ! empty( $data['billing_last_name'] ) && '' === $customer->get_last_name() ) {
    				$customer->set_last_name( $data['billing_last_name'] );
    			}

    So you could call $customer->set_first_name( ‘Foo’ ) within your action hook callback, to override this.

    Hope this helps!

    Clif

Viewing 1 replies (of 1 total)
  • The topic ‘Create accout based on Shipping address’ is closed to new replies.