Last active
January 3, 2018 16:55
-
-
Save jessepearson/9f6b715c2f2f7e0eba7c78be8ff5f124 to your computer and use it in GitHub Desktop.
This function will set the tax address for WooCommerce AvaTax when local_pickup is chosen
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 // only copy this line if needed | |
| /** | |
| * This function will set the tax address for WooCommerce AvaTax when local_pickup is chosen | |
| * | |
| * @param $address array The orignal address | |
| * @return array The original or modified address. | |
| */ | |
| function adjust_local_pickup_tax_address_for_avatax( $address ) { | |
| // get the chosen shipping method | |
| $chosen_shipping_method = WC()->session->get( 'chosen_shipping_methods' ); | |
| $chosen_shipping_method = explode( ':', $chosen_shipping_method[0] ); | |
| // if it's local pickup, change our address | |
| if ( 'local_pickup' === $chosen_shipping_method[0] ) { | |
| $address = array( | |
| 'address_1' => '123 Main Street', | |
| 'address_2' => '', | |
| 'city' => 'Ocala', | |
| 'state' => 'FL', | |
| 'country' => 'US', | |
| 'postcode' => '34480', | |
| ); | |
| } | |
| return $address; | |
| } | |
| add_filter( 'wc_avatax_tax_destination_address', 'adjust_local_pickup_tax_address_for_avatax', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment