Commerce 1.6.0

Commerce 1.6.0-rc1 is now available. This release is considered a pre-release, so we recommend testing on a staging environment before updating production. This release has some notable changes.

TaxJar changes

For TaxJar users, this release includes a refactor that improves the tax accuracy.

Previously, Commerce looked up the tax separately for each item and shipping. As of 1.6, the full order is sent to TaxJar to deal with scenarios where the tax on shipping is affected by the items purchased.

Special thanks to LUX Medien for sponsoring this refactor.

To accommodate this change, if you use different product tax codes currently defined in the tax rules, those now need to be set on the product. This is a bit of a hassle to update if you have a lot of products, but is necessary in order to be able to get the right product tax codes to use at once.

We've also made it so taxes on shipping are now correctly applied when multiple rates apply to it. (Only for TaxJar.)

Product Form extensions

It's now possible to extend the product form from a module, without needing to build a full custom product type. This was necessary for the TaxJar extension and was a long-standing feature request so managed to squeeze that in.

To use this, your module needs to hook into the new \Commerce::EVENT_PRODUCT_FORM event. The event object provides you with the fields defined at that point, which may vary based on existing extension methods like custom product types and shipment types, and a few utility methods to help you manipulate that.

Here's an example of how to do that from the TaxJar module:

$dispatcher->addListener(\Commerce::EVENT_PRODUCT_FORM, function (\modmore\Commerce\Events\ProductForm $e) {
    $properties = $e->getProduct()->getProperties();
    $e->insertField(
        new modmore\Commerce\Admin\Widgets\Form\SelectField($this->commerce, [
            'name' => 'properties[product_category]',
            'label' => $this->adapter->lexicon('commerce.taxjar.product_category'),
            'description' => $this->adapter->lexicon('commerce.taxjar.product_category.description'),
            'value' => $properties['product_category'] ?? null,
            'options' => $this->getProductTaxCodeOptions(),
        ]),
        $e->getIndex('tax_group') + 1
    );
});

And more!

Here's the changelog for 1.6.0-rc1:

  • [dashboard] Add new Save and Close button to form modals [#96]
  • [modules] Allow unsetting fields with the Custom Basic Fields module, by providing an empty string as value [#1530]
  • [payments] Fix unpaid authorized orders showing as partially paid
  • [products] Add Commerce::EVENT_PRODUCT_FORM event that lets developers insert or change Product Form fields without the need for a full custom product type [#192]
  • [taxjar] Refactor TaxJar payment gateway to use full order when determining taxes. Previously, Commerce would ask TaxJar for individual tax rates for each item and shipping. Now, the full order is sent at once, boosting performance and ensuring scenarios where shipping is taxed based on the items are correctly calculated. Thanks to LUX Medien for sponsoring this work.
  • [taxjar] Move Product Category selection for TaxJar from the tax rule to products. This is necessary to allow submitting the full order at once, and also provides you more control of exemptions.
  • [taxjar] Merge tax rates if shipping is taxed to apply correctly

Dependency updates in this release:

  • symfony/polyfill-ctype updated from v1.30.0 to v1.31.0
  • symfony/polyfill-mbstring updated from v1.30.0 to v1.31.0
  • symfony/polyfill-php80 updated from v1.30.0 to v1.31.0
  • symfony/http-foundation updated from v5.4.40 to v5.4.42
  • composer/ca-bundle updated from 1.5.0 to 1.5.1
  • mollie/mollie-api-php updated from v2.69.0 to v2.72.0
  • symfony/translation updated from v5.4.40 to v5.4.42
  • phpoffice/phpspreadsheet updated from 1.29.0 to 1.29.1
  • stripe/stripe-php updated from v15.0.0 to v15.9.0
  • symfony/polyfill-php81 installed in version v1.31.0
  • twig/twig updated from v3.10.3 to v3.11.1