woocommerce offtopic – my woocommerce_checkout_order_processed filter runs but doesn’t copy addresses as it should

I’m struggling with Apple Pay breaking shipping addresses (forced for virtual product), and have decided to turn all that off, but I still want the shipping address in all orders, even if it’s the same as billing Are. So I wrote:

add_action( 'woocommerce_checkout_order_processed', 'scna_checkout_order_processed');
function scna_checkout_order_processed($order_id) {
    $order = wc_get_order( $order_id );
    if ( ! $order->has_shipping_address() ) {
        $order->set_address('shipping', $order->get_address('billing'));
    }
}

I know it runs because if I throw an exception there, I get that message back to cart and checkout is suspended. Am I missing something on how these methods work on orders?

Leave a Comment