Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
562 B
1
Indexable
Never
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) { 
    if ( ! $order_id ) {
        return;
    }

    $order = wc_get_order( $order_id );

    // Check for the 'free shipping' method in the order
    foreach( $order->get_shipping_methods() as $shipping_method ) {
        if ( $shipping_method->get_method_id() == 'free_shipping' ) {

            $order->update_status( 'wc-pending-shipping', 'Order is pending shipping quotes' );
            break; 
        }
    }
}
Leave a Comment