Created
May 5, 2025 16:59
-
-
Save kilbot/9e0b3989e786d844844d7307a16c75f1 to your computer and use it in GitHub Desktop.
Force TaxJar to use POS store shipping address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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