skip to Main Content

the option on the site
"Default to customer billing address" is selected

but the shipping address is still empty.

I tried to fix it with code

    add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_shipping_update_order_meta' );
function my_custom_shipping_update_order_meta( $order_id ) {
    if ( empty( $_POST['shipping_address_1'] ) ) {
        update_post_meta( $order_id, 'shipping_address_1', sanitize_text_field( $_POST['billing_address_1'] ) );
    }
        if ( empty( $_POST['shipping_address_2'] ) ) {
        update_post_meta( $order_id, 'shipping_address_2', sanitize_text_field( $_POST['billing_address_2'] ) );
    }
}

still, shipping address is empty in the order
what can I do?

2

Answers


  1. Please make sure your WordPress and WooCommerce are all the newest versions. There were bugs in past versions that could have caused this to happen.

    After doing that, if the problem persists, there is a 99% chance this is being caused by a conflict with another plugin. This is a common problem with plugins like ‘Flexible Checkout Fields for WooCommerce’ and others.

    Please make a staging version of your website, then disable all plugins except for WooCommerce. Do a test order and see if the problem persists. If it is fixed try turning on plugins 1 at a time until it breaks again and you’ll know what plugin is causing the problem.

    Login or Signup to reply.
  2. In case anyone stumbles upon this, like me, the reason for me was that the products I added to the basked where all virtual products, not physical. For virtual products you cannot select a shipping address.

    Hope this helps someone

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search