Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/customer-condition-rule-element-se…
Browse files Browse the repository at this point in the history
…lect
  • Loading branch information
lukeholder authored Oct 17, 2023
2 parents 3e80ffc + cff0b7b commit bdc0e89
Show file tree
Hide file tree
Showing 11 changed files with 880 additions and 414 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Fixed a bug where the delete button would be shown for users that do not have permission to delete on the Product edit page. ([#3285](https://github.com/craftcms/commerce/issues/3285))
- Fixed a bug where deleted shipping categories were still available for selection. ([#3272](https://github.com/craftcms/commerce/issues/3272))
- Fixed a bug where the customer condition rule wasn’t loading correctly. ([#3291](https://github.com/craftcms/commerce/issues/3291))
- Fixed an error that could occur when rendering a PDF. ([#2633](https://github.com/craftcms/commerce/issues/2633))
- Fixed a bug where duplicate inactive users could be created when using the `commerce/upgrade` command. ([#3286](https://github.com/craftcms/commerce/issues/3286))

## 4.3.0 - 2023-09-13

Expand Down
981 changes: 613 additions & 368 deletions composer.lock

Large diffs are not rendered by default.

21 changes: 4 additions & 17 deletions example-templates/dist/shop/_private/address/fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -198,30 +198,17 @@ Outputs address form fields for editing an address.
{% if showPrimaryCheckboxes %}
<hr class="my-2">
<div class="my-2">
{{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }}
<label>{{ input('checkbox', 'isPrimaryBillingBox', 1, { checked: address.isPrimaryBilling, 'data-primary-input': 'isPrimaryBilling' }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
{{ hiddenInput('isPrimaryBilling', 0) }}
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
</div>
<div class="my-2">
{{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }}
<label>{{ input('checkbox', 'isPrimaryShippingBox', 1, { checked: address.isPrimaryShipping, 'data-primary-input': 'isPrimaryShipping' }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
{{ hiddenInput('isPrimaryShipping', 0) }}
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
</div>
{% endif %}
</div>

{% js %}
{% if showPrimaryCheckboxes %}
document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => {
el.addEventListener('change', ev => {
let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`);
if (ev.target.checked) {
primaryInput.value = 1;
} else {
primaryInput.value = 0;
}
});
});
{% endif %}

document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => {
const countryCode = ev.target.value;
const stateSelect = document.querySelector('select#{{ 'administrativeArea'|namespaceInputId(addressName) }}');
Expand Down
20 changes: 16 additions & 4 deletions example-templates/dist/shop/_private/address/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<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 %}
<div class="block border border-gray-200 bg-white rounded-lg shadow-sm hover:shadow-md p-4 w-full">
<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',
data: {
Expand Down Expand Up @@ -49,12 +49,24 @@
{% endif %}
</span>
{% endtag %}
{% if primaryBillingAddressId == address.id or primaryShippingAddressId == address.id %}
<div class="absolute top-0 right-0 pr-4 pt-4">
{% if primaryBillingAddressId == address.id %}
<span title="{{ 'Primary billing address'|t }}">💳</span>
{% endif %}
{% if primaryShippingAddressId == address.id %}
<span title="{{ 'Primary shipping address'|t }}">📦</span>
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
{% if showAdd %}
<a href="{{ addUrl }}" class="block rounded-lg hover:shadow-md w-full">
<div class="flex items-center justify-center h-full border border-gray-200 bg-white rounded-lg shadow-sm p-4 w-full group hover:shadow-md">
<span class="group-hover:underline">Add Address</span>
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative">
<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>
</div>
</div>
</a>
{% endif %}
Expand Down
21 changes: 4 additions & 17 deletions example-templates/src/shop/_private/address/fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -198,30 +198,17 @@ Outputs address form fields for editing an address.
{% if showPrimaryCheckboxes %}
<hr class="my-2">
<div class="my-2">
{{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }}
<label>{{ input('checkbox', 'isPrimaryBillingBox', 1, { checked: address.isPrimaryBilling, 'data-primary-input': 'isPrimaryBilling' }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
{{ hiddenInput('isPrimaryBilling', 0) }}
<label>{{ input('checkbox', 'isPrimaryBilling', 1, { checked: address.isPrimaryBilling }) }} {{ 'Use as the primary billing address'|t('commerce') }}</label>
</div>
<div class="my-2">
{{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }}
<label>{{ input('checkbox', 'isPrimaryShippingBox', 1, { checked: address.isPrimaryShipping, 'data-primary-input': 'isPrimaryShipping' }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
{{ hiddenInput('isPrimaryShipping', 0) }}
<label>{{ input('checkbox', 'isPrimaryShipping', 1, { checked: address.isPrimaryShipping }) }} {{ 'Use as the primary shipping address'|t('commerce') }}</label>
</div>
{% endif %}
</div>

{% js %}
{% if showPrimaryCheckboxes %}
document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => {
el.addEventListener('change', ev => {
let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`);
if (ev.target.checked) {
primaryInput.value = 1;
} else {
primaryInput.value = 0;
}
});
});
{% endif %}

document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => {
const countryCode = ev.target.value;
const stateSelect = document.querySelector('select#{{ 'administrativeArea'|namespaceInputId(addressName) }}');
Expand Down
20 changes: 16 additions & 4 deletions example-templates/src/shop/_private/address/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<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 %}
<div class="block border border-gray-200 bg-white rounded-lg shadow-sm hover:shadow-md p-4 w-full">
<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',
data: {
Expand Down Expand Up @@ -49,12 +49,24 @@
{% endif %}
</span>
{% endtag %}
{% if primaryBillingAddressId == address.id or primaryShippingAddressId == address.id %}
<div class="absolute top-0 right-0 pr-4 pt-4">
{% if primaryBillingAddressId == address.id %}
<span title="{{ 'Primary billing address'|t }}">💳</span>
{% endif %}
{% if primaryShippingAddressId == address.id %}
<span title="{{ 'Primary shipping address'|t }}">📦</span>
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
{% if showAdd %}
<a href="{{ addUrl }}" class="block rounded-lg hover:shadow-md w-full">
<div class="flex items-center justify-center h-full border border-gray-200 bg-white rounded-lg shadow-sm p-4 w-full group hover:shadow-md">
<span class="group-hover:underline">Add Address</span>
<a href="{{ addUrl }}" class="block rounded-lg border border-gray-200 bg-white hover:shadow-md w-full relative">
<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>
</div>
</div>
</a>
{% endif %}
Expand Down
7 changes: 6 additions & 1 deletion src/base/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public function getWebhookUrl(array $params = []): string

$url = UrlHelper::actionUrl('commerce/webhooks/process-webhook', $params);

return StringHelper::replace($url, Craft::$app->getConfig()->getGeneral()->cpTrigger . '/', '');
// Remove the cpTrigger from the url if it's there.
if (Craft::$app->getConfig()->getGeneral()->cpTrigger) {
$url = StringHelper::replace($url, Craft::$app->getConfig()->getGeneral()->cpTrigger . '/', '');
}

return $url;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/console/controllers/UpgradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,8 @@ public function _migrateCustomers(): void
->leftJoin(['u' => $usersTable], 'o.email = u.email')
->where(['u.email' => null])
->andWhere(['not', ['o.email' => null]])
->andWhere(['not', ['o.email' => '']])
->groupBy(['[[o.email]]'])
->column();
$this->stdoutlast(' Done. Found ' . count($guestEmails) . ' guest emails.', Console::FG_GREEN);

Expand Down
2 changes: 1 addition & 1 deletion src/events/MailEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ class MailEvent extends CancelableEvent
/**
* @var array Order data at the time the email sends.
*/
public array $orderData;
public ?array $orderData;
}
2 changes: 1 addition & 1 deletion src/services/Pdfs.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public function renderPdfForOrder(Order $order, string $option = '', string $tem
$view = Craft::$app->getView();
$originalLanguage = Craft::$app->language;
$originalFormattingLanguage = Craft::$app->formattingLocale;
$pdfLanguage = $pdf->getRenderLanguage($order);
$pdfLanguage = $pdf?->getRenderLanguage($order) ?? $originalLanguage;

// TODO add event
Locale::switchAppLanguage($pdfLanguage);
Expand Down
Loading

0 comments on commit bdc0e89

Please sign in to comment.