Filter hook before create order WooCommerce

Stumbled on this looking for the same thing which I’ve now figured out (Woocommerce 3.x)…

add_filter( 'woocommerce_checkout_create_order', 'mbm_alter_shipping', 10, 1 );
function mbm_alter_shipping ($order) {

  if ($something == $condition) {
    $address = array(
      'first_name' => 'Martin',
      'last_name'  => 'Stevens',
      'company'    => 'MBM Studio',
      'email'      => '[email protected]',
      'phone'      => '777-777-777-777',
      'address_1'  => '99 Arcadia Avenue',
      'address_2'  => '', 
      'city'       => 'London',
      'state'      => '',
      'postcode'   => '12345',
      'country'    => 'UK'
    );

    $order->set_address( $address, 'shipping' );

  }

  return $order;

}

Leave a Comment