Skip to content

Commit

Permalink
Added base location filters. Version bump to 2.0.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed May 8, 2024
1 parent 871305b commit 5a77e1b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"prefer-stable": true,
"version": "2.0.3",
"version": "2.0.4",
"minimum-stability": "dev",
"require": {
"automattic/jetpack-autoloader": "^2.6.0",
Expand Down
54 changes: 43 additions & 11 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Helper {
*
* @var string
*/
const VERSION = '2.0.3';
const VERSION = '2.0.4';

public static function get_version() {
return self::VERSION;
Expand Down Expand Up @@ -335,10 +335,10 @@ public static function get_order_taxable_location( $order ) {
$order = is_a( $order, 'WC_Order' ) ? $order : wc_get_order( $order );

$taxable_address = array(
WC()->countries->get_base_country(),
WC()->countries->get_base_state(),
WC()->countries->get_base_postcode(),
WC()->countries->get_base_city(),
self::get_base_country(),
self::get_base_state(),
self::get_base_postcode(),
self::get_base_city(),
);

if ( ! $order ) {
Expand Down Expand Up @@ -390,10 +390,10 @@ public static function get_taxable_location() {

if ( $is_admin_order_request ) {
$taxable_address = array(
WC()->countries->get_base_country(),
WC()->countries->get_base_state(),
WC()->countries->get_base_postcode(),
WC()->countries->get_base_city(),
self::get_base_country(),
self::get_base_state(),
self::get_base_postcode(),
self::get_base_city(),
);

if ( isset( $_POST['order_id'] ) && ( $order = wc_get_order( absint( $_POST['order_id'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
Expand Down Expand Up @@ -543,10 +543,42 @@ public static function current_request_has_vat_exempt() {

public static function get_base_country() {
if ( WC()->countries ) {
return WC()->countries->get_base_country();
$base_country = WC()->countries->get_base_country();
} else {
return wc_get_base_location()['country'];
$base_country = wc_get_base_location()['country'];
}

return apply_filters( 'woocommerce_eu_tax_helper_base_country', $base_country );
}

public static function get_base_postcode() {
$base_postcode = '';

if ( WC()->countries ) {
$base_postcode = WC()->countries->get_base_postcode();
}

return apply_filters( 'woocommerce_eu_tax_helper_base_postcode', $base_postcode );
}

public static function get_base_state() {
$base_state = '';

if ( WC()->countries ) {
$base_state = WC()->countries->get_base_state();
}

return apply_filters( 'woocommerce_eu_tax_helper_base_state', $base_state );
}

public static function get_base_city() {
$base_city = '';

if ( WC()->countries ) {
$base_city = WC()->countries->get_base_city();
}

return apply_filters( 'woocommerce_eu_tax_helper_base_city', $base_city );
}

/**
Expand Down

0 comments on commit 5a77e1b

Please sign in to comment.