Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jessepearson/9f6b715c2f2f7e0eba7c78be8ff5f124 to your computer and use it in GitHub Desktop.

Select an option

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
<?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