Skip to content

Commit

Permalink
Merge branch 'release/7.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bporcelli committed Oct 14, 2022
2 parents 684d114 + 0e6ce7e commit 8251edc
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build/
releases/
cypress/downloads/
cypress/videos/
cypress/screenshots/
*.min.js
*.min.css
!jquery.hideseek.min.js
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ Changelog for Simple Sales Tax

Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

= [7.0.2] - 2022-10-14 =

Fixed:
- Fatal error on checkout page when destination address is incomplete

Changed:
- Bump tested WooCommerce version to 7.0
- Bump tested WordPress version to 6.1

= [7.0.1] - 2022-08-04 =

Fixed:
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'https://sst.local',
baseUrl: 'http://sst.local',
},
}
64 changes: 53 additions & 11 deletions includes/abstracts/class-sst-abstract-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ protected function do_lookup() {
$packages = array();

foreach ( $this->create_packages() as $package ) {
if ( ! $this->should_do_lookup( $package ) ) {
continue;
}

if ( ! $this->is_destination_valid( $package ) ) {
// Wait for a complete destination address.
continue;
}

if ( ! $this->is_origin_valid( $package ) ) {
SST_Logger::add(
__(
'Failed to calculate sales tax: Shipping origin address is invalid.',
'simple-sales-tax'
)
);
continue;
}

$package['request'] = $this->get_lookup_for_package( $package );

$hash = $this->get_package_hash( $package );
Expand Down Expand Up @@ -147,13 +166,9 @@ protected function do_lookup() {
*
* @param array $package Package to perform tax lookup for.
*
* @return bool|array False if the package is not ready for lookup, or the updated package otherwise.
* @return array Updated package.
*/
protected function do_package_lookup( $package ) {
if ( ! $this->ready_for_lookup( $package ) ) {
return false;
}

try {
$package['response'] = TaxCloud()->Lookup( $package['request'] );
$package['cart_id'] = key( $package['response'] );
Expand Down Expand Up @@ -424,18 +439,45 @@ protected function get_origin_for_product( $item, $destination ) {
}

/**
* Can we perform a lookup for the given package?
* Is the package origin address valid?
*
* @param array $package WooCommerce shipping package.
*
* @return bool
* @since 5.0
* @since 7.0.2
*/
protected function is_origin_valid( $package ) {
return (
isset( $package['origin'] ) &&
$package['origin'] instanceof TaxCloud\Address
);
}

/**
* Is the package destination address valid?
*
* @param array $package WooCommerce shipping package.
*
* @return bool
* @since 7.0.2
*/
protected function ready_for_lookup( $package ) {
$dest_valid = isset( $package['destination'] ) && SST_Addresses::is_valid( $package['destination'] );
$origin_valid = isset( $package['origin'] ) && $package['origin'] instanceof TaxCloud\Address;
protected function is_destination_valid( $package ) {
return (
isset( $package['destination'] ) &&
SST_Addresses::is_valid( $package['destination'] )
);
}

return $origin_valid && $dest_valid;
/**
* Can we perform a lookup for the given package?
*
* @param array $package WooCommerce shipping package.
*
* @return bool
* @since 7.0.2
*/
protected function should_do_lookup( $package ) {
return true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/class-simplesalestax.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class SimpleSalesTax {
*
* @var string
*/
public $version = '7.0.1';
public $version = '7.0.2';

/**
* The singleton plugin instance.
Expand Down
13 changes: 6 additions & 7 deletions includes/class-sst-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ public function __call( $name, $args = array() ) {
* @param array $package Shipping package.
*
* @return bool
* @since 5.0
* @since 7.0.2
*/
protected function ready_for_lookup( $package ) {
if ( 'pending' !== $this->get_taxcloud_status() || 0 < $this->order->get_total_refunded() ) {
return false;
}

return parent::ready_for_lookup( $package );
protected function should_do_lookup( $package ) {
return (
'pending' === $this->get_taxcloud_status() &&
0 === (int) $this->order->get_total_refunded()
);
}

/**
Expand Down
24 changes: 14 additions & 10 deletions languages/simple-sales-tax.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the same license as the Simple Sales Tax package.
msgid ""
msgstr ""
"Project-Id-Version: Simple Sales Tax 7.0.1\n"
"Project-Id-Version: Simple Sales Tax 7.0.2\n"
"Report-Msgid-Bugs-To: https://github.com/bporcelli/simplesalestax/issues\n"
"POT-Creation-Date: 2022-08-04 16:30:36+00:00\n"
"POT-Creation-Date: 2022-10-14 15:29:54+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand All @@ -29,12 +29,16 @@ msgstr ""
msgid "Failed to calculate sales tax: %s"
msgstr ""

#: includes/abstracts/class-sst-abstract-cart.php:312
#: includes/abstracts/class-sst-abstract-cart.php:129
msgid "Failed to calculate sales tax: Shipping origin address is invalid."
msgstr ""

#: includes/abstracts/class-sst-abstract-cart.php:327
#. translators: WooCommerce product ID.
msgid "Failed to calculate sales tax: no origin address for product %d."
msgstr ""

#: includes/abstracts/class-sst-abstract-cart.php:358
#: includes/abstracts/class-sst-abstract-cart.php:373
msgid ""
"Origin address for shipping package is invalid. Using default origin "
"address from Simple Sales Tax settings."
Expand Down Expand Up @@ -269,32 +273,32 @@ msgid ""
"address yet."
msgstr ""

#: includes/class-sst-order.php:313 includes/class-sst-order.php:861
#: includes/class-sst-order.php:312 includes/class-sst-order.php:860
#: includes/sst-update-functions.php:573
msgid "Fee"
msgstr ""

#: includes/class-sst-order.php:621
#: includes/class-sst-order.php:620
#. translators: WooCommerce order ID
msgid "Failed to capture order %d: already captured."
msgstr ""

#: includes/class-sst-order.php:633
#: includes/class-sst-order.php:632
#. translators: WooCommerce order ID
msgid "Failed to capture order %d: order was refunded."
msgstr ""

#: includes/class-sst-order.php:663
#: includes/class-sst-order.php:662
#. translators: 1 - WooCommerce order ID, 2 - Error message from TaxCloud
msgid "Failed to capture order %1$d: %2$s."
msgstr ""

#: includes/class-sst-order.php:704
#: includes/class-sst-order.php:703
#. translators: WooCommerce order ID
msgid "Can't refund order %d: order must be completed first."
msgstr ""

#: includes/class-sst-order.php:785
#: includes/class-sst-order.php:784
#. translators: 1 - WooCommerce order ID, 2 - Error message from TaxCloud
msgid "Failed to refund order %1$d: %2$s."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simplesalestax",
"version": "7.0.1",
"version": "7.0.2",
"description": "A TaxCloud integration for WooCommerce.",
"scripts": {
"build": "grunt",
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: taxcloud, bporcelli
Tags: woocommerce, taxcloud, tax, taxes, sales tax, tax calculation, sales tax compliance, sales tax filing, sales tax reporting
Requires at least: 4.5
Tested up to: 6.0
Stable tag: 7.0.1
Tested up to: 6.1
Stable tag: 7.0.2
Requires PHP: 5.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
6 changes: 3 additions & 3 deletions simple-sales-tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* Author: TaxCloud
* Author URI: https://taxcloud.com
* GitHub Plugin URI: https://github.com/bporcelli/simplesalestax
* Version: 7.0.1
* Version: 7.0.2
* Text Domain: simple-sales-tax
* Domain Path: /languages/
*
* Requires at least: 4.5.0
* Tested up to: 6.0.0
* Tested up to: 6.1.0
* WC requires at least: 3.0.0
* WC tested up to: 6.8.0
* WC tested up to: 7.0.0
*
* @category Plugin
* @copyright Copyright © 2022 The Federal Tax Authority, LLC
Expand Down

0 comments on commit 8251edc

Please # to comment.