Friday, November 11, 2022
HomeWordPress Developmentwoocommerce offtopic - My woocommerce_checkout_order_processed filter runs however would not copy addresses...

woocommerce offtopic – My woocommerce_checkout_order_processed filter runs however would not copy addresses because it ought to


I am scuffling with transport addresses (compelled on for a digital product) breaking Apple Pay, and determined to show off all that, however I nonetheless actually need a transport deal with in all Orders, even when it is principally the identical as Billing. So I wrote:

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

I do know it runs as a result of if I throw an exception in there, I get that message again within the Cart and checkout is suspended. Am I lacking one thing about how these strategies on Order work?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments