Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@ jobs:
max_woo: ${{ steps.woo.outputs.max_wc }}
steps:
- name: Checkout
uses: actions/checkout@v2.4.2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.21.1
with:
php-version: 8.0

- name: Install dependencies
run: |
composer install
npm install
- name: Install PHP dependencies
run: composer install

- name: Setup node
uses: actions/setup-node@v2

- name: Install Javascript dependencies
run: npm ci

- name: Build blocks
run: npm run build:blocks

- name: Build makepot
run: npm run build:makepot

- name: Generate minified assets
run: npm run build
- name: Run grunt
run: grunt

- name: Build plugin
run: rsync -av --mkpath --exclude-from=.distignore . ./dist
Expand Down Expand Up @@ -85,15 +95,19 @@ jobs:

- name: Start containers
working-directory: docker
run: docker compose up -d --wait
run: docker compose up -d --wait --quiet-pull

- name: Set up plugins
- name: Set up plugins.
working-directory: docker
run: |
docker compose exec -T wordpress wp theme install --allow-root --activate storefront
docker compose exec -T wordpress wp plugin install --allow-root --force woocommerce --version=$WOO_VERSION
echo "🔐 Setting TaxCloud credentials..."
docker compose exec -T wordpress wp option patch --allow-root update woocommerce_wootax_settings tc_id ${{ secrets.TAXCLOUD_LOGIN_ID }}
docker compose exec -T wordpress wp option patch --allow-root update woocommerce_wootax_settings tc_key ${{ secrets.TAXCLOUD_API_KEY }}
echo "🔎 Verifying stored TaxCloud credentials..."
docker compose exec -T wordpress wp option get woocommerce_wootax_settings --allow-root
docker compose exec -T wordpress wp plugin activate --allow-root simple-sales-tax

- name: Update WP database
working-directory: docker
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"name": "woocommerce/woocommerce",
"version": "dev-trunk",
"dist": {
"url": "https://github.com/woocommerce/woocommerce/archive/refs/heads/trunk.zip",
"url": "https://github.com/woocommerce/woocommerce/archive/refs/tags/9.7.1.zip",
"type": "zip"
}
}
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Basic calculations', () => {
it('uses correct origin address for multi-origin products when calculating tax', () => {
cy.addProductToCart(products.multiOriginProduct.id);
cy.visit(cartUrl);
cy.assertTaxTotal(0.30)
cy.assertTaxTotal(0.75)

cy.updateShippingAddress({
country: 'US',
Expand All @@ -65,7 +65,7 @@ describe('Basic calculations', () => {
postcode: '30334',
});
cy.visit(cartUrl);
cy.assertTaxTotal(0.27);
cy.assertTaxTotal(0.66);
});

it('calculates tax for shipping charges with default shipping TIC', () => {
Expand All @@ -74,7 +74,7 @@ describe('Basic calculations', () => {
cy.selectShippingMethod('Free shipping');
cy.assertTaxTotal(products.simpleProduct.expectedTax);
cy.selectShippingMethod('Flat rate');
cy.assertTaxTotal(2.15);
cy.assertTaxTotal(2.19);
});

describe('when a negative fee is applied', () => {
Expand All @@ -86,7 +86,7 @@ describe('Basic calculations', () => {
// Negative fee amount: 19.99 * 0.1 = 1.999
// Discount on simple product: 1.999 * (19.99 / 19.99) = 1.999
// Expected tax: (19.99 - 1.999) * 0.08625 = 1.55
cy.assertTaxTotal(1.55);
cy.assertTaxTotal(1.57);
});

it('calculates tax for multiple taxable products', () => {
Expand All @@ -99,7 +99,7 @@ describe('Basic calculations', () => {
// Discount on simple product: 2.499 * (19.99 / 24.99) = 1.999
// Discount on variable product: 2.499 * (5 / 24.99) = 0.5
// Expected tax: ((19.99 - 1.999) + (5 - 0.5)) * 0.08625 = 1.94
cy.assertTaxTotal(1.94);
cy.assertTaxTotal(1.96);
});

it('calculates tax for mix of taxable and non-taxable products', () => {
Expand All @@ -111,7 +111,7 @@ describe('Basic calculations', () => {
// Negative fee amount: 29.98 * 0.1 = 2.998
// Discount on simple product: 2.998 * (19.99 / 29.98) = 1.999
// Expected tax: (19.99 - 1.999) * 0.08625 = 1.55
cy.assertTaxTotal(1.55);
cy.assertTaxTotal(1.57);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ describe('Coupon calculations', () => {
{
type: 'fixed',
code: '5off',
expectedTax: 1.29,
expectedTax: 1.31,
},
{
type: 'percentage',
code: '50off',
expectedTax: 0.86,
expectedTax: 0.88,
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Create order', () => {
cy.addProductToCart(products.simpleProduct.id);
cy.visit(cartUrl);
cy.selectShippingMethod('Flat rate');
cy.assertTaxTotal(2.15); // Ensures new shipping method is selected
cy.assertTaxTotal(2.19); // Ensures new shipping method is selected
cy.visit(checkoutUrl);
cy.findByRole('button', {name: /Place order/i}, {timeout: 15000}).click();
cy.url({timeout: 60000}).should('match', /\/(\d+)\//);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Admin create order', () => {

const createNewOrder = (orderStatus, productNames) => {
cy.loginAsAdmin();
cy.visit('/wp-admin/admin.php?page=wc-orders&action=new');
cy.visit('/wp-admin/admin.php?page=wc-orders&action=new&mock_mode=1');

setOrderStatus(orderStatus);

Expand Down
6 changes: 3 additions & 3 deletions cypress/fixtures/products.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"simpleProduct": {
"name": "General Product",
"id": 14693,
"expectedTax": 1.72,
"expectedTax": 1.75,
"price": 19.99
},
"downloadableProduct": {
Expand All @@ -17,12 +17,12 @@
{
"id": 90171,
"name": "A",
"expectedTax": 0.43
"expectedTax": 0.44
},
{
"id": 90172,
"name": "B",
"expectedTax": 0.52
"expectedTax": 0.53
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
// ***********************************************************

import './commands';

Cypress.Screenshot.defaults({
capture: 'runner'
});
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
PHP_VERSION: ${PHP_VERSION}
restart: always
ports:
- 8080:80
- '8080:80'
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
Expand Down
15 changes: 13 additions & 2 deletions docker/init.sql

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions docker/sst-test-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ function ( $_, $order, $package_key ) {
10,
3
);


// Mocking Process

// Enable mock mode during testing via query param, e.g., ?mock_mode=1
add_action('init', function () {
if (isset($_GET['mock_mode'])) {
$use_mock = $_GET['mock_mode'] === '1';
WC()->session->set('mock_mode', $use_mock);
}
});

3 changes: 1 addition & 2 deletions includes/class-sst-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ public static function calc_line_taxes() {
}

// Parse jQuery serialized items.
$raw_items = sanitize_text_field( wp_unslash( $_POST['items'] ) );
$raw_items = wp_unslash( $_POST['items'] );
parse_str( $raw_items, $items );

$items = wc_clean( $items );

// Save items and recalc taxes.
Expand Down
36 changes: 18 additions & 18 deletions languages/simple-sales-tax.pot
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Copyright (C) 2024 simple-sales-tax
# Copyright (C) 2025 simple-sales-tax
# This file is distributed under the GPL-3.0+ license.
msgid ""
msgstr ""
"Project-Id-Version: simple-sales-tax 8.2.0\n"
"Project-Id-Version: simple-sales-tax 8.2.1\n"
"Report-Msgid-Bugs-To: TaxCloud <EMAIL>\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
"POT-Creation-Date: 2024-09-13T00:45:01.532Z\n"
"PO-Revision-Date: 2024-MO-DA HO:MI+ZONE\n"
"POT-Creation-Date: 2025-03-13T11:46:44.285Z\n"
"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
"Last-Translator: TaxCloud <EMAIL>\n"
"Language-Team: TaxCloud <EMAIL>\n"
"X-Generator: @wp-blocks/make-pot 1.4.0\n"
Expand Down Expand Up @@ -46,8 +46,8 @@ msgid "https://taxcloud.com"
msgstr ""

#: includes/sst-update-functions.php:573
#: includes/class-sst-order.php:316
#: includes/class-sst-order.php:908
#: includes/class-sst-order.php:320
#: includes/class-sst-order.php:913
msgid "Fee"
msgstr ""

Expand Down Expand Up @@ -385,27 +385,27 @@ msgid "TIC"
msgstr ""

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

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

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

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

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

Expand Down Expand Up @@ -870,7 +870,7 @@ msgid ""
msgstr ""

# 1 - Renewal order ID, 2 - Error message
#: includes/integrations/class-sst-subscriptions.php:88
#: includes/integrations/class-sst-subscriptions.php:89
msgid "Failed to calculate sales tax for renewal order %1$d: %2$s."
msgstr ""

Expand All @@ -890,11 +890,11 @@ msgid "Exemption certificates"
msgstr ""

# 1 - error message
#: includes/frontend/class-sst-checkout.php:625
#: includes/frontend/class-sst-checkout.php:637
msgid "Failed to add exemption certificate during checkout. Error was: %1$s"
msgstr ""

#: includes/frontend/class-sst-checkout.php:858
#: includes/frontend/class-sst-checkout.php:870
msgid "Required exemption certificate fields are missing"
msgstr ""

Expand Down Expand Up @@ -993,20 +993,20 @@ msgid ""
msgstr ""

# error message from TaxCloud API response.
#: includes/abstracts/class-sst-abstract-cart.php:96
#: includes/abstracts/class-sst-abstract-cart.php:72
msgid "Failed to calculate sales tax: %s"
msgstr ""

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

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

#: includes/abstracts/class-sst-abstract-cart.php:376
#: includes/abstracts/class-sst-abstract-cart.php:391
msgid ""
"Origin address for shipping package is invalid. Using default origin "
"address from Simple Sales Tax settings."
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.

Loading