Skip to content

Instantly share code, notes, and snippets.

@kilbot
Created May 5, 2025 16:59
Show Gist options
  • Save kilbot/9e0b3989e786d844844d7307a16c75f1 to your computer and use it in GitHub Desktop.
Save kilbot/9e0b3989e786d844844d7307a16c75f1 to your computer and use it in GitHub Desktop.
Force TaxJar to use POS store shipping address
<?php
// add to your functions.php file
function apply_pos_forced_shipping_address( $order, $request, $creating ) {
// only apply on order creation
if ( ! $creating ) {
return $order;
}
// only apply for POS orders
if( ! function_exists('woocommerce_pos_request') || ! woocommerce_pos_request() )
return $order;
}
$forced = [
'first_name' => 'Warehouse',
'last_name' => 'Team',
'company' => 'Acme Inc.',
'address_1' => '1 Infinite Loop',
'address_2' => '',
'city' => 'Cupertino',
'state' => 'CA',
'postcode' => '95014',
'country' => 'US',
];
// Loop over the map and call the matching WC_Order setter.
foreach ( $forced as $key => $value ) {
$setter = "set_shipping_{$key}";
if ( method_exists( $order, $setter ) ) {
$order->$setter( $value );
}
}
return $order;
}
add_filter( 'woocommerce_rest_pre_insert_shop_order_object', 'apply_pos_forced_shipping_address', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment