Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: taxjar/taxjar-woocommerce-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.2.2
Choose a base ref
...
head repository: taxjar/taxjar-woocommerce-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 6 commits
  • 9 files changed
  • 3 contributors

Commits on Aug 11, 2024

  1. Stop displaying the metabox when the order can't be found

    ahumulescu committed Aug 11, 2024
    Copy the full SHA
    384aad2 View commit details

Commits on Aug 19, 2024

  1. RUN_TJPLAT-1732 - Fix test failures

    https://jira.corp.stripe.com/browse/RUN_TJPLAT-1732
    #263
    
    This work fixes rate change based test failures so we have a better idea if
    upcoming changes break things. These tests seemed to be failing because of
    natural tax law changes and rate updates, so we've updated the values.
    saville-stripe committed Aug 19, 2024
    Copy the full SHA
    1136627 View commit details
  2. Merge pull request #263 from taxjar/saville-RUN_TJPLAT-1732-fix-test-…

    …failures
    
    RUN_TJPLAT-1732 - Fix test failures
    saville-stripe authored Aug 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6ebde2c View commit details
  3. Merge pull request #262 from taxjar/258-fatal-error-in-product-page

    #258 Stop displaying the metabox when the order can't be found
    saville-stripe authored Aug 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f460a3e View commit details
  4. Release 4.2.3

    saville-stripe committed Aug 19, 2024
    Copy the full SHA
    312ccdf View commit details
  5. Merge pull request #264 from taxjar/version-4.2.3

    Release 4.2.3
    saville-stripe authored Aug 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9a6017a View commit details
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 4.2.3 (2024-08-19)
* RUN_TJPLAT-1732 - Fix test failures
* #258 Stop displaying the metabox when the order can't be found

# 4.2.2 (2024-08-01)
* WooCommerce tested up to 8.1.0
* WordPress 6.6.1 tested
16 changes: 13 additions & 3 deletions includes/admin/class-admin-meta-boxes.php
Original file line number Diff line number Diff line change
@@ -24,21 +24,31 @@ class Admin_Meta_Boxes {
* Admin_Meta_Boxes Constructor.
*/
public function __construct() {
add_action( 'add_meta_boxes', array( $this, 'add_order_meta_box' ), 30 );
add_action( 'add_meta_boxes', array( $this, 'add_order_meta_box' ), 30, 2 );
}

/**
* Add meta box to order post types.
*
* @param string $post_type Post type.
* @param \WP_Post $post Post object.
*/
public function add_order_meta_box() {
public function add_order_meta_box( $post_type, $post ) {
$wc_order = wc_get_order( $post->ID );

if ( ! $wc_order ) {
return;
}

foreach ( wc_get_order_types( 'order-meta-boxes' ) as $type ) {
add_meta_box(
'taxjar',
__( 'TaxJar', 'taxjar' ),
'\TaxJar\Order_Meta_Box::output',
$this->get_page_screen_id( $type ),
'normal',
'low'
'low',
array( 'order' => $wc_order )
);
}
}
7 changes: 4 additions & 3 deletions includes/admin/class-order-meta-box.php
Original file line number Diff line number Diff line change
@@ -25,10 +25,11 @@ class Order_Meta_Box {
* Output meta box contents.
*
* @param mixed $post WP Post.
* @param array $additional_data Additional data.
*/
public static function output( $post ) {
$order_id = $post->ID;
$order = wc_get_order( $order_id );
public static function output( $post, $additional_data ) {
$order = $additional_data['args']['order'];

$metadata = self::get_order_tax_calculation_metadata( $order );
wp_enqueue_script( 'accordion' );

8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ Contributors: taxjar, tonkapark, fastdivision
Tags: woocommerce, taxjar, tax, taxes, sales tax, tax calculation, sales tax compliance, sales tax filing
Requires at least: 5.4
Tested up to: 6.6.1
Stable tag: 4.2.2
Stable tag: 4.2.3
License: GPLv2 or later
URI: http://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 7.0.0
@@ -95,6 +95,12 @@ Our plans come with filings included, with additional filings available for purc

== Changelog ==

= 4.2.3 (2024-08-19) =
* WooCommerce tested up to 8.1.0
* WordPress 6.6.1 tested
* RUN_TJPLAT-1732 - Fix test failures
* #258 Stop displaying the metabox when the order can't be found

= 4.2.2 (2024-08-01) =
* WooCommerce tested up to 8.1.0
* WordPress 6.6.1 tested
4 changes: 2 additions & 2 deletions taxjar-woocommerce.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
* Plugin Name: TaxJar - Sales Tax Automation for WooCommerce
* Plugin URI: https://www.taxjar.com/woocommerce-sales-tax-plugin/
* Description: Save hours every month by putting your sales tax on autopilot. Automated, multi-state sales tax calculation, collection, and filing.
* Version: 4.2.2
* Version: 4.2.3
* Author: TaxJar
* Author URI: https://www.taxjar.com
* WC requires at least: 7.0.0
@@ -43,7 +43,7 @@
*/
final class WC_Taxjar {

static $version = '4.2.2';
static $version = '4.2.3';
public static $minimum_woocommerce_version = '7.0.0';

/**
18 changes: 9 additions & 9 deletions tests/framework/class-tj-wc-rest-unit-test-case.php
Original file line number Diff line number Diff line change
@@ -107,10 +107,10 @@ function test_simple_product_tax_on_api_order() {
$order = wc_get_order( $data['id'] );

$this->assertEquals( 201, $response->get_status() );
$this->assertEquals( 0.73, $order->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $order->get_total_tax(), '', 0.01 );

foreach ( $order->get_items() as $item ) {
$this->assertEquals( 0.73, $item->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $item->get_total_tax(), '', 0.01 );
}
}

@@ -225,14 +225,14 @@ function test_fee_tax_on_api_order() {
$order = wc_get_order( $data['id'] );

$this->assertEquals( 201, $response->get_status() );
$this->assertEquals( 7.98, $order->get_total_tax(), '', 0.01 );
$this->assertEquals( 8.2, $order->get_total_tax(), '', 0.01 );

foreach ( $order->get_items() as $item ) {
$this->assertEquals( 0.73, $item->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $item->get_total_tax(), '', 0.01 );
}

foreach ( $order->get_fees() as $fee ) {
$this->assertEquals( 7.25, $fee->get_total_tax() );
$this->assertEquals( 7.45, $fee->get_total_tax() );
}
}

@@ -267,10 +267,10 @@ function test_exempt_fee_on_api_order() {
$order = wc_get_order( $data['id'] );

$this->assertEquals( 201, $response->get_status() );
$this->assertEquals( 0.73, $order->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $order->get_total_tax(), '', 0.01 );

foreach ( $order->get_items() as $item ) {
$this->assertEquals( 0.73, $item->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $item->get_total_tax(), '', 0.01 );
}

foreach ( $order->get_fees() as $fee ) {
@@ -312,10 +312,10 @@ function test_batch_order_creation_through_api() {
foreach ( $data['create'] as $order_response ) {
$order = wc_get_order( $order_response['id'] );

$this->assertEquals( 0.73, $order->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $order->get_total_tax(), '', 0.01 );

foreach ( $order->get_items() as $item ) {
$this->assertEquals( 0.73, $item->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.75, $item->get_total_tax(), '', 0.01 );
}
}
}
10 changes: 5 additions & 5 deletions tests/specs/tax-calculation/test-admin-order-creation.php
Original file line number Diff line number Diff line change
@@ -58,8 +58,8 @@ public function test_order_with_single_line_item() {
$this->call_wc_ajax_calc_line_taxes();

$order = wc_get_order( $this->test_order->get_id() );
$this->assert_correct_line_tax( $order, 7.25 );
$this->assert_correct_totals( $order, 107.25, 7.25 );
$this->assert_correct_line_tax( $order, 7.45 );
$this->assert_correct_totals( $order, 107.45, 7.45 );
}

public function test_order_with_taxable_shipping() {
@@ -80,7 +80,7 @@ public function test_order_with_fee() {
$this->call_wc_ajax_calc_line_taxes();

$order = wc_get_order( $this->test_order->get_id() );
$this->assert_correct_totals( $order, 107.25, 7.25 );
$this->assert_correct_totals( $order, 107.45, 7.45 );
}

public function test_order_with_product_tax_code() {
@@ -139,8 +139,8 @@ public function test_order_with_discount() {

$order = wc_get_order( $this->test_order->get_id() );

$this->assert_correct_line_tax( $order, 6.53 );
$this->assert_correct_totals( $order, 96.53, 6.53 );
$this->assert_correct_line_tax( $order, 6.71 );
$this->assert_correct_totals( $order, 96.71, 6.71 );
}

public function test_order_without_nexus() {
44 changes: 22 additions & 22 deletions tests/specs/test-actions.php
Original file line number Diff line number Diff line change
@@ -113,8 +113,8 @@ function test_taxes_with_different_shipping_and_item_rates() {
$this->assertEquals( $item['line_tax'], 0.58, '', 0.01 );
}

$this->assertEquals( WC()->cart->get_shipping_tax(), 0.69, '', 0.01 );
$this->assertEquals( WC()->cart->get_total_tax(), 1.27, '', 0.01 );
$this->assertEquals( WC()->cart->get_shipping_tax(), 0.0, '', 0.01 );
$this->assertEquals( WC()->cart->get_total_tax(), 0.58, '', 0.01 );
}

function test_correct_taxes_with_exempt_shipping() {
@@ -210,12 +210,12 @@ function test_correct_taxes_with_local_pickup() {
WC()->session->set( 'chosen_shipping_methods', array( 'local_pickup' ) );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 0.73, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 0.43, '', 0.01 );
$this->assertEquals( WC()->cart->shipping_tax_total, 0, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 0.73, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 0.43, '', 0.01 );

foreach ( WC()->cart->get_cart() as $cart_item_key => $item ) {
$this->assertEquals( $item['line_tax'], 0.73, '', 0.01 );
$this->assertEquals( $item['line_tax'], 0.43, '', 0.01 );
}

WC()->session->set( 'chosen_shipping_methods', array() );
@@ -234,15 +234,15 @@ function test_correct_taxes_for_multiple_products() {
WC()->cart->add_to_cart( $extra_product, 2 );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 4.36, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 4.36, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 2.56, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 2.56, '', 0.01 );

foreach ( WC()->cart->get_cart() as $cart_item_key => $item ) {
$product = $item['data'];
$sku = $product->get_sku();

if ( 'SIMPLE2' == $sku ) {
$this->assertEquals( $item['line_tax'], 3.63, '', 0.01 );
$this->assertEquals( $item['line_tax'], 2.13, '', 0.01 );
}

if ( 'SIMPLE1' == $sku ) {
@@ -251,7 +251,7 @@ function test_correct_taxes_for_multiple_products() {
}

if ( version_compare( WC()->version, '3.2', '>=' ) ) {
$this->assertEquals( WC()->cart->get_total( 'amount' ), 64.36, '', 0.01 );
$this->assertEquals( WC()->cart->get_total( 'amount' ), 62.56, '', 0.01 );
}
}

@@ -357,11 +357,11 @@ function test_correct_taxes_for_duplicate_line_items() {
WC()->cart->add_to_cart( $product, 1, 0, [], [ 'duplicate' => true ] );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 1.46, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 1.46, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 0.86, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 0.86, '', 0.01 );

if ( version_compare( WC()->version, '3.2', '>=' ) ) {
$this->assertEquals( WC()->cart->get_total( 'amount' ), 21.46, '', 0.01 );
$this->assertEquals( WC()->cart->get_total( 'amount' ), 20.86, '', 0.01 );
}
}

@@ -638,19 +638,19 @@ function test_correct_taxes_for_product_exemption_threshold_reduced_rates() {
WC()->cart->add_to_cart( $reduced_product, 2 );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 14.75, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 14.75, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 12.56, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 12.56, '', 0.01 );

if ( version_compare( WC()->version, '3.2', '>=' ) ) {
$this->assertEquals( WC()->cart->get_total( 'amount' ), 150 + 50 + 14.75, '', 0.01 );
$this->assertEquals( WC()->cart->get_total( 'amount' ), 150 + 50 + 12.56, '', 0.01 );
}

foreach ( WC()->cart->get_cart() as $item_key => $item ) {
$product = $item['data'];
$sku = $product->get_sku();

if ( 'REDUCED1' == $sku ) {
$this->assertEquals( $item['line_tax'], 2.19, '', 0.01 );
$this->assertEquals( $item['line_tax'], 0.0, '', 0.01 );
}

if ( 'EXEMPTOVER1' == $sku ) {
@@ -695,11 +695,11 @@ function test_correct_taxes_for_product_exemption_threshold_reduced_rates_and_ot
WC()->cart->add_to_cart( $reduced_product, 2 );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 18.94, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 18.94, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 16.75, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 16.75, '', 0.01 );

if ( version_compare( WC()->version, '3.2', '>=' ) ) {
$this->assertEquals( WC()->cart->get_total( 'amount' ), 150 + 50 + 50 + 18.94, '', 0.01 );
$this->assertEquals( WC()->cart->get_total( 'amount' ), 150 + 50 + 50 + 16.75, '', 0.01 );
}

foreach ( WC()->cart->get_cart() as $item_key => $item ) {
@@ -742,11 +742,11 @@ function test_correct_taxes_for_discounts() {
WC()->cart->add_discount( $coupon );
WC()->cart->calculate_totals();

$this->assertEquals( WC()->cart->tax_total, 4.35, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 4.35, '', 0.01 );
$this->assertEquals( WC()->cart->tax_total, 2.55, '', 0.01 );
$this->assertEquals( WC()->cart->get_taxes_total(), 2.55, '', 0.01 );

if ( version_compare( WC()->version, '3.2', '>=' ) ) {
$this->assertEquals( WC()->cart->get_total( 'amount' ), 64.35, '', 0.01 );
$this->assertEquals( WC()->cart->get_total( 'amount' ), 62.55, '', 0.01 );
}
}

18 changes: 9 additions & 9 deletions tests/specs/test-customer-sync.php
Original file line number Diff line number Diff line change
@@ -353,11 +353,11 @@ function test_tax_calculation_with_customer_exemption() {
WC()->shipping->shipping_total = 10;
WC()->cart->calculate_totals();

$this->assertEquals( .73, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( .43, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( 0, WC()->cart->get_shipping_tax(), '', 0.01 );
$this->assertEquals( .73, WC()->cart->get_taxes_total(), '', 0.01 );
$this->assertEquals( .43, WC()->cart->get_taxes_total(), '', 0.01 );
foreach ( WC()->cart->get_cart() as $cart_item_key => $item ) {
$this->assertEquals( .73, $item['line_tax'], '', 0.01 );
$this->assertEquals( .43, $item['line_tax'], '', 0.01 );
}

// test tax calculation for exempt customer
@@ -421,11 +421,11 @@ function test_tax_calculation_with_previously_exempt_customer() {
WC()->customer = $customer;
WC()->cart->calculate_totals();

$this->assertEquals( 1.45, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( 0.85, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( 0, WC()->cart->get_shipping_tax(), '', 0.01 );
$this->assertEquals( 1.45, WC()->cart->get_taxes_total(), '', 0.01 );
$this->assertEquals( 0.85, WC()->cart->get_taxes_total(), '', 0.01 );
foreach ( WC()->cart->get_cart() as $cart_item_key => $item ) {
$this->assertEquals( 1.45, $item['line_tax'], '', 0.01 );
$this->assertEquals( 0.85, $item['line_tax'], '', 0.01 );
}

$record->delete_in_taxjar();
@@ -451,11 +451,11 @@ function test_exempt_customer_deleted_from_taxjar() {
WC()->shipping->shipping_total = 10;
WC()->cart->calculate_totals();

$this->assertEquals( .73, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( .43, WC()->cart->get_total_tax(), '', 0.01 );
$this->assertEquals( 0, WC()->cart->get_shipping_tax(), '', 0.01 );
$this->assertEquals( .73, WC()->cart->get_taxes_total(), '', 0.01 );
$this->assertEquals( .43, WC()->cart->get_taxes_total(), '', 0.01 );
foreach ( WC()->cart->get_cart() as $cart_item_key => $item ) {
$this->assertEquals( .73, $item['line_tax'], '', 0.01 );
$this->assertEquals( .43, $item['line_tax'], '', 0.01 );
}

TaxJar_Customer_Helper::delete_customer( $customer->get_id() );