Commerce Commerce 1.x Upgrades v1.11
Table of Contents
Commerce v1.11 is a big release with some exciting new features - most of these are opt-in and don’t affect your existing shops on upgrade, but they’re worth exploring!
Fixed Price Coupons refactored
Coupons with a fixed discount price have long had the issue that they add an extra item to the cart, and don’t properly handle taxes. For example given a €100 item with a €50 coupon, that would show €21 (21%) VAT, even though it should only be €10,50 over the remaining €50.
That has been fixed, and fixed discounts are now proportionally applied to items (as comOrderItemAdjustments) in the cart instead. The discounts now always apply before taxes.
This may affect cart rendering or custom reporting that expected the coupon item to be present. item.properties.is_fixed_coupon is also no longer being set.
UBL (XML) invoices added
Commerce v1.11 now supports generating invoices in UBL XML format. This adds onto the PDF invoice system but requires correct configuration. See the UBL Invoices documentation for details.
Products can now be deactivated
In addition to the (soft-)remove functionality, products can now be activated and deactivated, including automatically based on the time.
If you have any custom cataloging functionality or load products through something custom, you’ll want to include the logic to filter deactivated products. Something like this:
$now = time();
$c->where([
'active' => true,
]);
// activate_on must be 0 (not set) or <= now
$c->andCondition([
'activate_on:=' => 0,
'OR:activate_on:<=' => $now,
]);
// deactivate_on must be 0 (not set) or >= now
$c->andCondition([
'deactivate_on:=' => 0,
'OR:deactivate_on:>=' => $now,
]);
Email attachment handling changes
We’ve added the option to add attachments to emails sent from the status workflow. We also recently released an ItemUpload module that can be used to let users attach files to an order item, which also gets added as an email attachment.
The Mail event used to send emails has been updated to allow more flexible attachments:
- Defining custom filenames
- Using a relative url + media source
To ensure every attachment is handled the same way, the core invoices are now also attached through that Mail event, so modules could inspect or potentially change those attachments.
Minor logic changes in add to cart process
A new event has been added in v1.10 that allows cancelling an item being added to the cart, \Commerce::EVENT_ITEM_BEFORE_ADD_TO_CART.
To accommodate this new event, it’s good to know the \Commerce::EVENT_ITEM_ADDED_TO_CART event no longer fires if adding was cancelled (for example, in the EnforceStock module or custom logic).
When programmatically using \Commerce\Frontend\Steps\Cart::createOrderItem() to create cart items, that also no longer runs the \Commerce::EVENT_ITEM_ADDED_TO_CART event - that has been moved into the addProductToCart method.