Skip to content

Commit

Permalink
Merge branch 'release/4.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Nov 1, 2023
2 parents bdca33a + 6e6384f commit b2756ca
Show file tree
Hide file tree
Showing 33 changed files with 207 additions and 56 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release Notes for Craft Commerce

## 4.3.2 - 2023-10-31

- Product GraphQL queries now support `promotable`, `freeShipping`, `defaultSku`, `defaultHeight`, `defaultLength`, `defaultWidth`, and `defaultWeight` arguments. ([#3307](https://github.com/craftcms/commerce/pull/3307))
- Product GraphQL queries now support `promotable`, `freeShipping`, `defaultSku`, `defaultHeight`, `defaultLength`, `defaultWidth`, `defaultWeight`, and `defaultVariant` fields. ([#3307](https://github.com/craftcms/commerce/pull/3307))
- Fixed a bug where it was possible to select soft-deleted tax categories.
- Fixed a PHP error that occurred when sending an email with a missing PDF filename format. ([#3309](https://github.com/craftcms/commerce/issues/3309))
- Fixed a PHP error that occurred when viewing soft-deleted orders. ([#3308](https://github.com/craftcms/commerce/issues/3308))
- Fixed a bug where saving a shipping zone could fail if a tax zone existed with the same name. ([#3317](https://github.com/craftcms/commerce/issues/3317))
- Fixed a bug where `craft\commerce\services\LineItems::getLineItemById()` wasn’t decoding the snapshot data. ([#3253](https://github.com/craftcms/commerce/issues/3253))

## 4.3.1 - 2023-10-18

- Added the `commerce/gateways/list` command.
Expand All @@ -15,6 +25,7 @@
- Fixed a bug where sales’ and discounts’ timestamps weren’t getting populated. ([#3298](https://github.com/craftcms/commerce/issues/3298))
- Fixed a bug where the `commerce/upgrade` command could create duplicate inactive users. ([#3286](https://github.com/craftcms/commerce/issues/3286))
- Fixed a bug where `commerce/payments/pay` JSON responses were missing the `redirect` key. ([#3265](https://github.com/craftcms/commerce/issues/3265))
- Fixed a bug where gateway URLs could be malformed. ([#3299](https://github.com/craftcms/commerce/issues/3299))

## 4.3.0 - 2023-09-13

Expand Down Expand Up @@ -50,6 +61,7 @@
- Fixed a bug where Commerce wasn’t invoking `craft\services\Elements::EVENT_AUTHORIZE_*` event handlers.
- Fixed a bug where discounts’ per user usage counters weren’t getting migrated properly when upgrading to Commerce 4.
- Fixed a bug where address changes weren’t being synced to carts that were using them. ([#3178](https://github.com/craftcms/commerce/issues/3178))
- Fixed a SQL error that could occur when fetching emails. ([#3267](https://github.com/craftcms/commerce/pull/3267))
- Fixed an XSS vulnerability.

## 4.2.11 - 2023-06-05
Expand Down
6 changes: 3 additions & 3 deletions example-templates/dist/shop/_private/address/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{% set primaryShippingAddressId = primaryShippingAddressId ?? null %}
{% set showDelete = showDelete ?? false %}
{% set showAdd = showAdd ?? false %}
{% set addUrl = '/shop/customer/addresses/edit?redirect=' ~ craft.app.request.fullPath %}
{% set addUrl = siteUrl('shop/customer/addresses/edit?redirect=' ~ craft.app.request.pathInfo) %}

{% if currentUser %}
<div class="my-6 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 xl:grid-cols-3 gap-4">
{% for address in addresses %}
{% set editUrl = '/shop/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.fullPath %}
{% set editUrl = 'shop/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.pathInfo %}
<div class="block border border-gray-200 bg-white rounded-lg shadow-sm hover:shadow-md p-4 w-full relative">
{% tag selectable ? 'label' : 'div' with {
class: 'block relative address-select js-address-select',
Expand Down Expand Up @@ -62,7 +62,7 @@
</div>
{% endfor %}
{% if showAdd %}
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative">
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative" style="min-height: 100px;">
<div class="absolute top-0 left-0 right-0 bottom-0 flex items-center">
<div class="flex items-center justify-center h-full p-4 w-full group">
<span class="group-hover:underline">Add Address</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="bg-gray-900">
<div class="container mx-auto p-6 md:flex justify-content-between align-content-center">
<h1 class="text-3xl">
<a href="{{ siteUrl('/shop') }}" class="text-white">
<a href="{{ siteUrl('shop') }}" class="text-white">
{{- siteName ~ ' Shop' -}}
</a>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion example-templates/dist/shop/cart/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Outputs cart.
</form>
{% else %}
<p>{{ 'Empty cart. Add items on the {link} page.'|t({
link: tag('a', { href: url('/shop/products'), text: 'products', class: 'underline' })
link: tag('a', { href: url('shop/products'), text: 'products', class: 'underline' })
})|raw }}</p>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion example-templates/dist/shop/cart/load.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Outputs form for collecting a cart number to be loaded.
<form method="post" action="">
{{ csrfInput() }}
{{ actionInput('commerce/cart/load-cart') }}
{{ redirectInput('/shop/cart') }}
{{ redirectInput('shop/cart') }}

<h1 class="text-xl font-bold">
{{- 'Load Cart'|t -}}
Expand Down
2 changes: 1 addition & 1 deletion example-templates/dist/shop/checkout/pay-static.twig
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
>
{{ csrfInput() }}
{{ hiddenInput('action', 'commerce/payments/pay') }}
{{ redirectInput('/shop/customer/order?number=' ~ cart.number ~ '&success=true') }}
{{ redirectInput('shop/customer/order?number=' ~ cart.number ~ '&success=true') }}
{{ hiddenInput('cancelUrl', craft.app.request.getUrl()|hash) }}
{{ hiddenInput('email', email) }}
{{ hiddenInput('number', cart.number) }}
Expand Down
2 changes: 1 addition & 1 deletion example-templates/dist/shop/checkout/register-signin.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{{- 'Checkout'|t -}}
</h2>
<div class="mt-3">
<a href="{{ url('/shop/checkout/addresses') }}" class="text-blue-500 hover:text-blue-600">
<a href="{{ url('shop/checkout/addresses') }}" class="text-blue-500 hover:text-blue-600">
{{ 'Or continue as guest'|t }} &rarr;
</a>
</div>
Expand Down
8 changes: 4 additions & 4 deletions example-templates/dist/shop/customer/cards.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{% if paymentSource.id != currentUser.primaryPaymentSourceId %}
<form method="post" action="">
{{ csrfInput() }}
{{ redirectInput('/shop/customer/cards') }}
{{ redirectInput('shop/customer/cards') }}
{{ actionInput('commerce/payment-sources/set-primary-payment-source') }}
{{ hiddenInput('id', paymentSource.id) }}
{{ tag('button', {
Expand All @@ -45,7 +45,7 @@
{% endif %}
<form method="post" action="">
{{ csrfInput() }}
{{ redirectInput('/shop/customer/cards') }}
{{ redirectInput('shop/customer/cards') }}
{{ actionInput('commerce/payment-sources/delete') }}
{{ hiddenInput('id', paymentSource.id) }}
{{ tag('button', {
Expand Down Expand Up @@ -118,8 +118,8 @@
{{ actionInput('commerce/payment-sources/add') }}
{{ hiddenInput('gatewayId', gateway.id) }}
{{ hiddenInput('successMessage', 'Added payment source.'|hash) }}
{{ hiddenInput('cancelUrl', '/shop/customer/cards'|hash) }}
{{ redirectInput('/shop/customer/cards') }}
{{ hiddenInput('cancelUrl', 'shop/customer/cards'|hash) }}
{{ redirectInput('shop/customer/cards') }}

{% set params = {} %}

Expand Down
2 changes: 1 addition & 1 deletion example-templates/dist/shop/customer/index.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{% redirect '/shop/customer/orders' %}
{% redirect 'shop/customer/orders' %}
2 changes: 1 addition & 1 deletion example-templates/dist/shop/customer/orders.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% endset %}

{% if not currentUser %}
{% redirect '/shop/customer/sign-in' %}
{% redirect 'shop/customer/sign-in' %}
{% endif %}


Expand Down
6 changes: 3 additions & 3 deletions example-templates/src/shop/_private/address/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{% set primaryShippingAddressId = primaryShippingAddressId ?? null %}
{% set showDelete = showDelete ?? false %}
{% set showAdd = showAdd ?? false %}
{% set addUrl = '/[[folderName]]/customer/addresses/edit?redirect=' ~ craft.app.request.fullPath %}
{% set addUrl = siteUrl('[[folderName]]/customer/addresses/edit?redirect=' ~ craft.app.request.pathInfo) %}

{% if currentUser %}
<div class="my-6 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 xl:grid-cols-3 gap-4">
{% for address in addresses %}
{% set editUrl = '/[[folderName]]/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.fullPath %}
{% set editUrl = '[[folderName]]/customer/addresses/edit?addressId=' ~ address.id ~ '&redirect=' ~ craft.app.request.pathInfo %}
<div class="block border border-gray-200 bg-white rounded-lg shadow-sm hover:shadow-md p-4 w-full relative">
{% tag selectable ? 'label' : 'div' with {
class: 'block relative address-select js-address-select',
Expand Down Expand Up @@ -62,7 +62,7 @@
</div>
{% endfor %}
{% if showAdd %}
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative">
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative" style="min-height: 100px;">
<div class="absolute top-0 left-0 right-0 bottom-0 flex items-center">
<div class="flex items-center justify-center h-full p-4 w-full group">
<span class="group-hover:underline">Add Address</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="bg-gray-900">
<div class="container mx-auto p-6 md:flex justify-content-between align-content-center">
<h1 class="text-3xl">
<a href="{{ siteUrl('/[[folderName]]') }}" class="text-white">
<a href="{{ siteUrl('[[folderName]]') }}" class="text-white">
{{- siteName ~ ' Shop' -}}
</a>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion example-templates/src/shop/cart/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Outputs cart.
</form>
{% else %}
<p>{{ 'Empty cart. Add items on the {link} page.'|t({
link: tag('a', { href: url('/[[folderName]]/products'), text: 'products', class: 'underline' })
link: tag('a', { href: url('[[folderName]]/products'), text: 'products', class: 'underline' })
})|raw }}</p>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion example-templates/src/shop/cart/load.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Outputs form for collecting a cart number to be loaded.
<form method="post" action="">
{{ csrfInput() }}
{{ actionInput('commerce/cart/load-cart') }}
{{ redirectInput('/[[folderName]]/cart') }}
{{ redirectInput('[[folderName]]/cart') }}

<h1 class="text-xl font-bold">
{{- 'Load Cart'|t -}}
Expand Down
2 changes: 1 addition & 1 deletion example-templates/src/shop/checkout/pay-static.twig
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
>
{{ csrfInput() }}
{{ hiddenInput('action', 'commerce/payments/pay') }}
{{ redirectInput('/[[folderName]]/customer/order?number=' ~ cart.number ~ '&success=true') }}
{{ redirectInput('[[folderName]]/customer/order?number=' ~ cart.number ~ '&success=true') }}
{{ hiddenInput('cancelUrl', craft.app.request.getUrl()|hash) }}
{{ hiddenInput('email', email) }}
{{ hiddenInput('number', cart.number) }}
Expand Down
2 changes: 1 addition & 1 deletion example-templates/src/shop/checkout/register-signin.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{{- 'Checkout'|t -}}
</h2>
<div class="mt-3">
<a href="{{ url('/[[folderName]]/checkout/addresses') }}" class="[[classes.a]]">
<a href="{{ url('[[folderName]]/checkout/addresses') }}" class="[[classes.a]]">
{{ 'Or continue as guest'|t }} &rarr;
</a>
</div>
Expand Down
8 changes: 4 additions & 4 deletions example-templates/src/shop/customer/cards.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{% if paymentSource.id != currentUser.primaryPaymentSourceId %}
<form method="post" action="">
{{ csrfInput() }}
{{ redirectInput('/[[folderName]]/customer/cards') }}
{{ redirectInput('[[folderName]]/customer/cards') }}
{{ actionInput('commerce/payment-sources/set-primary-payment-source') }}
{{ hiddenInput('id', paymentSource.id) }}
{{ tag('button', {
Expand All @@ -45,7 +45,7 @@
{% endif %}
<form method="post" action="">
{{ csrfInput() }}
{{ redirectInput('/[[folderName]]/customer/cards') }}
{{ redirectInput('[[folderName]]/customer/cards') }}
{{ actionInput('commerce/payment-sources/delete') }}
{{ hiddenInput('id', paymentSource.id) }}
{{ tag('button', {
Expand Down Expand Up @@ -118,8 +118,8 @@
{{ actionInput('commerce/payment-sources/add') }}
{{ hiddenInput('gatewayId', gateway.id) }}
{{ hiddenInput('successMessage', 'Added payment source.'|hash) }}
{{ hiddenInput('cancelUrl', '/[[folderName]]/customer/cards'|hash) }}
{{ redirectInput('/[[folderName]]/customer/cards') }}
{{ hiddenInput('cancelUrl', '[[folderName]]/customer/cards'|hash) }}
{{ redirectInput('[[folderName]]/customer/cards') }}

{% set params = {} %}

Expand Down
2 changes: 1 addition & 1 deletion example-templates/src/shop/customer/index.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{% redirect '/[[folderName]]/customer/orders' %}
{% redirect '[[folderName]]/customer/orders' %}
2 changes: 1 addition & 1 deletion example-templates/src/shop/customer/orders.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% endset %}

{% if not currentUser %}
{% redirect '/[[folderName]]/customer/sign-in' %}
{% redirect '[[folderName]]/customer/sign-in' %}
{% endif %}


Expand Down
4 changes: 2 additions & 2 deletions src/adjusters/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function adjust(Order $order): array

foreach ($lineItems as $item) {
$purchasable = $item->getPurchasable();
if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable)) {
if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable, $order)) {
$nonShippableItems[$item->id] = $item->id;
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public function adjust(Order $order): array
}

$freeShippingFlagOnProduct = $item->purchasable->hasFreeShipping();
$shippable = Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable());
$shippable = Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable(), $order);
if (!$freeShippingFlagOnProduct && !$hasFreeShippingFromDiscount && $shippable) {
$adjustment = $this->_createAdjustment($shippingMethod, $rule);

Expand Down
2 changes: 1 addition & 1 deletion src/base/ShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getPriceForOrder(Order $order): float

foreach ($lineItems as $item) {
$purchasable = $item->getPurchasable();
if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable)) {
if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable, $order)) {
$nonShippableItems[$item->id] = $item->id;
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/base/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
use craft\base\conditions\ConditionInterface;
use craft\base\Model as BaseModel;
use craft\commerce\elements\conditions\addresses\ZoneAddressCondition;
use craft\commerce\records\TaxZone as TaxZoneRecord;
use craft\elements\Address;
use craft\helpers\Json;
use craft\validators\UniqueValidator;
use DateTime;
use yii\base\InvalidConfigException;

Expand Down Expand Up @@ -89,16 +87,4 @@ public function setCondition(ZoneAddressCondition|string|array|null $condition):

$this->_condition = $condition;
}

/**
* @inheritdoc
*/
protected function defineRules(): array
{
return [
[['name'], 'required'],
[['condition'], 'required'],
[['name'], UniqueValidator::class, 'targetClass' => TaxZoneRecord::class, 'targetAttribute' => ['name']],
];
}
}
15 changes: 11 additions & 4 deletions src/elements/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
* @property string $recalculationMode the mode of recalculation.
* @property string $origin
* @property int|null $customerId The order customer ID
* @property-read ShippingMethod[] $availableShippingMethods
* @property-read bool $activeCart Is the current order the same as the active cart
* @property-read User|null $customer
* @property-read Gateway $gateway
Expand Down Expand Up @@ -149,7 +148,7 @@
* @property float $totalTaxIncluded
* @property float $totalTax
* @property float $totalShippingCost
* @property ShippingMethodOption[] $availableShippingMethodOptions
* @property-read ShippingMethodOption[] $availableShippingMethodOptions
* @property-read float|int $totalAuthorized
* @property float $paymentAmount
* @property-read null|string $loadCartUrl
Expand Down Expand Up @@ -2888,7 +2887,11 @@ public function getShippingAddress(): ?AddressElement
{
if (!isset($this->_shippingAddress) && $this->shippingAddressId) {
/** @var AddressElement|null $address */
$address = AddressElement::find()->ownerId($this->id)->id($this->shippingAddressId)->one();
$address = AddressElement::find()
->owner($this)
->id($this->shippingAddressId)
->one();

$this->_shippingAddress = $address;
}

Expand Down Expand Up @@ -2982,7 +2985,11 @@ public function getBillingAddress(): ?AddressElement
{
if (!isset($this->_billingAddress) && $this->billingAddressId) {
/** @var AddressElement|null $address */
$address = AddressElement::find()->ownerId($this->id)->id($this->billingAddressId)->one();
$address = AddressElement::find()
->owner($this)
->id($this->billingAddressId)
->one();

$this->_billingAddress = $address;
}

Expand Down
Loading

0 comments on commit b2756ca

Please sign in to comment.