Skip to content

Commit

Permalink
Merge pull request #3740 from craftcms/5.3
Browse files Browse the repository at this point in the history
5.3
  • Loading branch information
brandonkelly authored Jan 30, 2025
2 parents d3a69de + 33a4ecd commit ce971ce
Show file tree
Hide file tree
Showing 160 changed files with 3,495 additions and 905 deletions.
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Release Notes for Craft Commerce

## Unreleased

### Store Management
- Archived gateways are now listed on the Gateways index page. ([#3839](https://github.com/craftcms/commerce/issues/3839))
- Added card view designers for products and variants. ([#3809](https://github.com/craftcms/commerce/pull/3809))
- Order conditions can now have “Coupon Code” and “Payment Gateway” rules. ([#3776](https://github.com/craftcms/commerce/discussions/3776), [#3722](https://github.com/craftcms/commerce/discussions/3722))
- Product variant conditions can now have a “Product” rule.
- Tax rates now have statuses. ([#3790](https://github.com/craftcms/commerce/discussions/3790))
- It’s now possible to restore soft-deleted product variants.
- Improved Craft Commerce navigation and breadcrumb labels.

### Administration
- The “Recipient”, “BCC’d Recipient”, and “CC’d Recipient” email settings now support being set to environment variables. ([#3738](https://github.com/craftcms/commerce/issues/3738))
- It’s now possible to view (but not edit) system and plugin settings on environments where `allowAdminChanges` is disabled.

### Development
- Added the `couponCode` order query param.
- Orders’ `makePrimaryShippingAddress` and `makePrimaryBillingAddress` property values now persist during checkout.
- The `commerce/update-cart` action now includes an `originalCart` key in JSON responses. ([#430](https://github.com/craftcms/commerce/issues/430))

### Extensibility
- Added support for registering custom tax ID validators.
- Added `craft\commerce\base\InventoryItemTrait`.
- Added `craft\commerce\base\InventoryItemTrait`.
- Added `craft\commerce\base\InventoryLocationTrait`.
- Added `craft\commerce\base\InventoryLocationTrait`.
- Added `craft\commerce\base\Purchasable::hasInventory()`.
- Added `craft\commerce\base\Purchasable::loadSales()`.
- Added `craft\commerce\base\TaxIdValidatorInterface`.
- Added `craft\commerce\controllers\BaseStoreManagementController::getStoreSwitch()`.
- Added `craft\commerce\elements\Purchasable::$allowOutOfStockPurchases`.
- Added `craft\commerce\elements\Purchasable::getIsOutOfStockPurchasingAllowed()`.
- Added `craft\commerce\elements\conditions\orders\CouponCodeConditionRule`.
- Added `craft\commerce\elements\conditions\variants\ProductConditionRule`.
- Added `craft\commerce\elements\db\OrderQuery::$couponCode`.
- Added `craft\commerce\elements\db\OrderQuery::couponCode()`.
- Added `craft\commerce\events\CartPurgeEvent`.
- Added `craft\commerce\events\PurchasableOutOfStockPurchasesAllowedEvent`.
- Added `craft\commerce\services\Gateways\getAllArchivedGateways()`.
- Added `craft\commerce\services\Inventory::updateInventoryLevel()`.
- Added `craft\commerce\services\Inventory::updateInventoryLevel()`.
- Added `craft\commerce\services\Inventory::updatePurchasableInventoryLevel()`.
- Added `craft\commerce\services\Inventory::updatePurchasableInventoryLevel()`.
- Added `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_OUT_OF_STOCK_PURCHASES_ALLOWED`.
- Added `craft\commerce\services\Purchasables::isPurchasableOutOfStockPurchasingAllowed()`.
- Added `craft\commerce\services\Taxes::EVENT_REGISTER_TAX_ID_VALIDATORS`.
- Added `craft\commerce\services\Taxes::getEnabledTaxIdValidators()`.
- Added `craft\commerce\services\Taxes::getTaxIdValidators()`.
- Added `craft\commerce\taxidvalidators\EuVatIdValidator`.

### System
- Craft Commerce now requires Craft CMS 5.6.0 or later.
- Fixed a bug where orders’ promotional prices could be calculated incorrectly when using sales.
- Fixed a bug where the `commerce/cart/update-cart` action wasn’t respecting `makePrimaryShippingAddress` and `makePrimaryBillingAddress` params for newly-created addresses. ([#3864](https://github.com/craftcms/commerce/pull/3864))
- Fixed a PHP error that could occur when viewing discounts. ([#3844](https://github.com/craftcms/commerce/issues/3844))

## 5.2.12.1 - 2025-01-23

- Fixed a JavaScript error that occurred when updating an order’s status for a non-primary store on order indexes.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prefer-stable": true,
"require": {
"php": "^8.2",
"craftcms/cms": "^5.2.0",
"craftcms/cms": "^5.6.0",
"dompdf/dompdf": "^2.0.2",
"ibericode/vat": "^1.2.2",
"iio/libmergepdf": "^4.0",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

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

6 changes: 3 additions & 3 deletions example-templates/dist/shop/_private/address/fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ Outputs address form fields for editing an address.
<hr class="my-2">
<div class="my-2">
{{ hiddenInput('isPrimaryBilling', 0) }}
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t }}</label>
</div>
<div class="my-2">
{{ hiddenInput('isPrimaryShipping', 0) }}
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t }}</label>
</div>
{% endif %}
</div>
Expand Down Expand Up @@ -251,4 +251,4 @@ document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}
});

document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').dispatchEvent(new Event('change'));
{% endjs %}
{% endjs %}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@

<button id="submit-button" type="submit">Submit Payment</button>




{# Force in some basic styling for the gateway-provided form markup (better to build your own form markup!) #}
{% include 'shop/checkout/_includes/base-payment-form-styles' %}

{% if cart.gateway.supportsPaymentSources() and currentUser %}
<div class="checkbox">
<label>
Expand Down
4 changes: 4 additions & 0 deletions example-templates/dist/shop/checkout/addresses.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ Outputs a form for collecting an order’s shipping and billing address.
}) }}

{% if currentUser and addresses|length %}
{{ hiddenInput('makePrimaryShippingAddress', 0) }}
<div class="mt-3">
<label>
{{ input('checkbox', 'makePrimaryShippingAddress', 1, {
id: 'makePrimaryShippingAddress',
checked: cart.makePrimaryShippingAddress
}) }}
{{ 'Make this my default shipping address'|t }}
</label>
Expand Down Expand Up @@ -79,10 +81,12 @@ Outputs a form for collecting an order’s shipping and billing address.
</div>

{% if currentUser and addresses|length %}
{{ hiddenInput('makePrimaryBillingAddress', 0) }}
<div class="mt-3">
<label>
{{ input('checkbox', 'makePrimaryBillingAddress', 1, {
id: 'makePrimaryBillingAddress',
checked: cart.makePrimaryBillingAddress,
}) }}
{{ 'Make this my default billing address'|t }}
</label>
Expand Down
11 changes: 10 additions & 1 deletion example-templates/dist/shop/products/_includes/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@
checked: loop.first,
class: not variant.getIsAvailable() ? 'opacity-10' : '',
disabled: not variant.availableForPurchase,
}) }}<span class="pl-1">{{ variant.sku }} {% if variant.inventoryTracked %}({{ variant.stock ? variant.stock ~ ' available' : 'out of stock'}}){% endif %}</span><span class="ml-auto">{% if variant.onPromotion %} <del class="text-gray-400 text-xs">{{ variant.price|currency(cart.currency) }}</del>{% endif %} {{ variant.salePrice|currency(cart.currency) }}</span>
}) }}
<span class="pl-1">{{ variant.sku }}
{% if variant.hasInventory and variant.inventoryTracked %}
({{ variant.stock ? variant.stock ~ ' available' : 'out of stock'}})
{% if variant.allowOutOfStockPurchases %}
<span class="text-xs text-gray-400">{{ "Continue selling when out of stock."|t }}</span>
{% endif %}
{% endif %}
</span>
<span class="ml-auto">{% if variant.onPromotion %} <del class="text-gray-400 text-xs">{{ variant.price|currency(cart.currency) }}</del>{% endif %} {{ variant.salePrice|currency(cart.currency) }}</span>
</label>
{% endfor %}
</div>
Expand Down
6 changes: 3 additions & 3 deletions example-templates/src/shop/_private/address/fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ Outputs address form fields for editing an address.
<hr class="my-2">
<div class="my-2">
{{ hiddenInput('isPrimaryBilling', 0) }}
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t }}</label>
</div>
<div class="my-2">
{{ hiddenInput('isPrimaryShipping', 0) }}
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t }}</label>
</div>
{% endif %}
</div>
Expand Down Expand Up @@ -251,4 +251,4 @@ document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}
});

document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').dispatchEvent(new Event('change'));
{% endjs %}
{% endjs %}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@

<button id="submit-button" type="submit">Submit Payment</button>




{# Force in some basic styling for the gateway-provided form markup (better to build your own form markup!) #}
{% include '[[folderName]]/checkout/_includes/base-payment-form-styles' %}

{% if cart.gateway.supportsPaymentSources() and currentUser %}
<div class="checkbox">
<label>
Expand Down
4 changes: 4 additions & 0 deletions example-templates/src/shop/checkout/addresses.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ Outputs a form for collecting an order’s shipping and billing address.
}) }}

{% if currentUser and addresses|length %}
{{ hiddenInput('makePrimaryShippingAddress', 0) }}
<div class="mt-3">
<label>
{{ input('checkbox', 'makePrimaryShippingAddress', 1, {
id: 'makePrimaryShippingAddress',
checked: cart.makePrimaryShippingAddress
}) }}
{{ 'Make this my default shipping address'|t }}
</label>
Expand Down Expand Up @@ -79,10 +81,12 @@ Outputs a form for collecting an order’s shipping and billing address.
</div>

{% if currentUser and addresses|length %}
{{ hiddenInput('makePrimaryBillingAddress', 0) }}
<div class="mt-3">
<label>
{{ input('checkbox', 'makePrimaryBillingAddress', 1, {
id: 'makePrimaryBillingAddress',
checked: cart.makePrimaryBillingAddress,
}) }}
{{ 'Make this my default billing address'|t }}
</label>
Expand Down
4 changes: 2 additions & 2 deletions example-templates/src/shop/checkout/pay-static.twig
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
}) }}" class="[[classes.a]]">&larr; {{ 'Back'|t }}</a>

<div class="gateway-payment-form max-w-3/4">
{% namespace cart.gateway.handle|commercePaymentFormNamespace %}
{{ cart.gateway.getPaymentFormHtml(params)|raw }}
{% namespace gateway.handle|commercePaymentFormNamespace %}
{{ gateway.getPaymentFormHtml(params)|raw }}
{% endnamespace %}
</div>

Expand Down
11 changes: 10 additions & 1 deletion example-templates/src/shop/products/_includes/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@
checked: loop.first,
class: not variant.getIsAvailable() ? 'opacity-10' : '',
disabled: not variant.availableForPurchase,
}) }}<span class="pl-1">{{ variant.sku }} {% if variant.inventoryTracked %}({{ variant.stock ? variant.stock ~ ' available' : 'out of stock'}}){% endif %}</span><span class="ml-auto">{% if variant.onPromotion %} <del class="text-gray-400 text-xs">{{ variant.price|currency(cart.currency) }}</del>{% endif %} {{ variant.salePrice|currency(cart.currency) }}</span>
}) }}
<span class="pl-1">{{ variant.sku }}
{% if variant.hasInventory and variant.inventoryTracked %}
({{ variant.stock ? variant.stock ~ ' available' : 'out of stock'}})
{% if variant.allowOutOfStockPurchases %}
<span class="text-xs text-gray-400">{{ "Continue selling when out of stock."|t }}</span>
{% endif %}
{% endif %}
</span>
<span class="ml-auto">{% if variant.onPromotion %} <del class="text-gray-400 text-xs">{{ variant.price|currency(cart.currency) }}</del>{% endif %} {{ variant.salePrice|currency(cart.currency) }}</span>
</label>
{% endfor %}
</div>
Expand Down
22 changes: 18 additions & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static function editions(): array
/**
* @inheritDoc
*/
public string $schemaVersion = '5.2.9.1';
public string $schemaVersion = '5.3.0.4';

/**
* @inheritdoc
Expand All @@ -279,6 +279,11 @@ public static function editions(): array
*/
public CmsEdition $minCmsEdition = CmsEdition::Pro;

/**
* @inheritdoc
*/
public bool $hasReadOnlyCpSettings = true;

use CommerceServices;
use Variables;
use Routes;
Expand All @@ -304,7 +309,6 @@ public function init(): void
$this->_registerGqlQueries();
$this->_registerGqlComponents();
$this->_registerGqlEagerLoadableFields();
$this->_registerLinkTypes();
$this->_registerCacheTypes();
$this->_registerGarbageCollection();

Expand All @@ -315,6 +319,7 @@ public function init(): void
$this->_registerWidgets();
$this->_registerElementExports();
$this->_defineFieldLayoutElements();
$this->_registerLinkTypes();
$this->_registerRedactorLinkOptions();
$this->_registerCKEditorLinkOptions();
} else {
Expand Down Expand Up @@ -351,6 +356,14 @@ public function getSettingsResponse(): mixed
return Craft::$app->getResponse()->redirect(UrlHelper::cpUrl('commerce/settings/general'));
}

/**
* @inheritdoc
*/
public function getReadOnlySettingsResponse(): mixed
{
return Craft::$app->getResponse()->redirect(UrlHelper::cpUrl('commerce/settings/general'));
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -428,9 +441,10 @@ public function getCpNavItem(): ?array
];
}

if (Craft::$app->getUser()->getIsAdmin() && Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
if (Craft::$app->getUser()->getIsAdmin()) {
$ret['subnav']['settings'] = [
'label' => Craft::t('commerce', 'System Settings'),
'ariaLabel' => Craft::t('commerce', 'Commerce Settings'),
'label' => Craft::t('app', 'Settings'),
'url' => 'commerce/settings/general',
];
}
Expand Down
Loading

0 comments on commit ce971ce

Please sign in to comment.