Skip to content

Commit c2630f1

Browse files
committed
Merge branch 'release/4.5.0' into main
2 parents f41ca3a + 57fd136 commit c2630f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+263
-455
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
blank_issues_enabled: false
22
contact_links:
3-
- name: Feature Request
4-
url: https://github.com/craftcms/commerce/discussions/new?category=ideas
5-
about: Start a new discussion about your idea
63
- name: Documentation
7-
url: https://craftcms.com/docs/commerce/4.x/
4+
url: https://craftcms.com/docs
85
about: Read the official documentation
96
- name: Knowledge Base
107
url: https://craftcms.com/knowledge-base
11-
about: Find answers to common problems
8+
about: Find official answers to common problems
129
- name: Developer Support Services
1310
url: https://craftcms.com/support-services
1411
about: Priority developer support from the team that makes Craft
1512
- name: Craft Discord
1613
url: https://craftcms.com/discord
1714
about: Meet the community
18-
- name: Stack Exchange
15+
- name: Craft Stack Exchange
1916
url: https://craftcms.stackexchange.com/
2017
about: Get help and help others
18+
- name: 'Feature Request: Craft CMS'
19+
url: https://github.com/craftcms/cms/discussions/new?category=ideas
20+
about: Make a feature request or enhancement for Craft CMS
21+
- name: 'Feature Request: Craft Console / Plugin Store'
22+
url: https://github.com/craftcms/console/discussions/new?category=ideas
23+
about: Make a feature request or enhancement for Craft Console or the Plugin Store
24+
- name: 'Feature Request: Craft Cloud'
25+
url: https://github.com/craftcms/cloud/discussions/new?category=ideas
26+
about: Make a feature request or enhancement for Craft Cloud
27+
- name: 'Feature Request: Craft Commerce'
28+
url: https://github.com/craftcms/commerce/discussions/new?category=ideas
29+
about: Make a feature request or enhancement for Craft Commerce
30+
- name: 'Bug Report: Craft CMS'
31+
url: https://github.com/craftcms/cms/issues/new/choose
32+
about: Create a bug report for Craft CMS
33+
- name: 'Bug Report: Craft Console / Plugin Store'
34+
url: https://github.com/craftcms/console/issues/new/choose
35+
about: Create a bug report for Craft Console or the Plugin Store
36+
- name: 'Bug Report: Craft Cloud'
37+
url: https://craftcms.com/contact
38+
about: Create a bug report for Craft Cloud
39+
- name: 'Bug Report: Craft Commerce'
40+
url: https://github.com/craftcms/commerce/issues/new/choose
41+
about: Create a bug report for Craft Commerce

CHANGELOG.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Release Notes for Craft Commerce
22

3+
## 4.5.0 - 2024-02-26
4+
5+
- Removed the Lite edition.
6+
- Deprecated `craft\commerce\models\ShippingMethod::isLite`.
7+
- Deprecated `craft\commerce\models\ShippingRule::isLite`.
8+
- Deprecated `craft\commerce\models\TaxRate::isLite`.
9+
- Deprecated `craft\commerce\models\LiteShippingSettings`.
10+
- Deprecated `craft\commerce\models\LiteTaxSettings`.
11+
- Deprecated `craft\commerce\controllers\LiteShippingController`.
12+
- Deprecated `craft\commerce\controllers\LiteTaxController`.
13+
- Deprecated `craft\commerce\services\ShippingMethods::getLiteShippingMethod()`. `getAllShippingMethods()` should be used instead.
14+
- Deprecated `craft\commerce\services\ShippingMethods::saveLiteShippingMethod()`. `saveShippingMethod()` should be used instead.
15+
- Deprecated `craft\commerce\services\ShippingRules::getLiteShippingRule()`. `getAllShippingRules()` should be used instead.
16+
- Deprecated `craft\commerce\services\ShippingRules::saveLiteShippingRule()`. `saveShippingRule()` should be used instead.
17+
- Deprecated `craft\commerce\services\TaxRates::getLiteTaxRate()`. `getAllTaxRates()` should be used instead.
18+
- Deprecated `craft\commerce\services\TaxRates::saveLiteTaxRate()`. `saveTaxRate()` should be used instead.
19+
- Fixed a SQL error that occurred when running the `commerce/upgrade` command on PostgreSQL. ([#3380](https://github.com/craftcms/commerce/pull/3380))
20+
321
## 4.4.1.1 - 2024-01-12
422

523
- Fixed a PHP error that occurred when saving a sale. ([#3364](https://github.com/craftcms/commerce/issues/3364))
@@ -25,7 +43,7 @@
2543
- Improved the performance of variant queries’ `hasProduct` and `hasVariant` params. ([#3325](https://github.com/craftcms/commerce/pull/3325))
2644
- Order statuses with long names no longer wrap on the Orders index page. ([#3335](https://github.com/craftcms/commerce/issues/3335))
2745
- Fixed a bug where carts could get duplicate validation errors. ([3334](https://github.com/craftcms/commerce/issues/3334))
28-
- Fixed a bug where tab selection was inconsistent on Edit Order pages.
46+
- Fixed a bug where tab selection was inconsistent on Edit Order pages.
2947
- Fixed a bug where sales weren’t respecting elements’ site statuses. ([#3328](https://github.com/craftcms/commerce/issues/3328))
3048
- Fixed a bug where soft-deleted order statuses and line item statuses weren’t getting restored when applying project config changes. ([#3164](https://github.com/craftcms/commerce/issues/3164))
3149
- Fixed a bug where carts weren’t getting restored after signing in.
@@ -98,7 +116,7 @@
98116

99117
## 4.2.11 - 2023-06-05
100118

101-
- Fixed a bug where “Send Email” option text wasn’t getting translated. ([#3172](https://github.com/craftcms/commerce/issues/3172))
119+
- Fixed a bug where “Send Email” option text wasn’t getting translated. ([#3172](https://github.com/craftcms/commerce/issues/3172))
102120
- Fixed a bug where discounts’ user condition values weren’t getting migrated properly when upgrading to Commerce 4. ([#3176](https://github.com/craftcms/commerce/issues/3176))
103121

104122
## 4.2.10 - 2023-05-31
@@ -156,7 +174,7 @@
156174
- Fixed a PHP error that occurred if `null` was passed to `craft\commerce\services\Discounts::getDiscountByCode()`. ([#3045](https://github.com/craftcms/commerce/issues/3045))
157175
- Fixed a bug where a large number of shipping rule category queries could be executed.
158176
- Fixed a PHP error that occurred if a product was re-saved before it had finished propagating to all sites. ([#1954](https://github.com/craftcms/commerce/issues/1954))
159-
- Fixed a PHP error that occurred if `craft\commerce\services\ProductTypes::getEditableProductTypes()` was called when no user was logged in.
177+
- Fixed a PHP error that occurred if `craft\commerce\services\ProductTypes::getEditableProductTypes()` was called when no user was logged in.
160178
- Fixed a PHP error that occurred when saving an invalid shipping method.
161179
- Fixed a bug where gateways’ “Enabled for customers to select during checkout” setting wasn’t properly supporting environment variables. ([#3052](https://github.com/craftcms/commerce/issues/3052))
162180
- Fixed a PHP error that could occur when entering values on an Edit Discount page. ([#3067](https://github.com/craftcms/commerce/issues/3067))
@@ -294,7 +312,7 @@
294312
- Fixed a SQL error that occurred when restoring a soft-deleted product. ([#2982](https://github.com/craftcms/commerce/issues/2982))
295313
- Fixed a bug where the Edit Product page wasn’t handling site selection changes properly. ([#2971](https://github.com/craftcms/commerce/issues/2971))
296314
- Fixed a bug where it wasn't possible to add variants to a sale from the Edit Product page. ([#2976](https://github.com/craftcms/commerce/issues/2976))
297-
- Fixed a bug where primary addresses weren’t being automatically set on the Edit Order page. ([#2963](https://github.com/craftcms/commerce/issues/2963))
315+
- Fixed a bug where primary addresses weren’t being automatically set on the Edit Order page. ([#2963](https://github.com/craftcms/commerce/issues/2963))
298316
- Fixed a bug where it wasn’t possible to change the default order status. ([#2915](https://github.com/craftcms/commerce/issues/2915))
299317

300318
## 4.1.2 - 2022-09-15
@@ -314,7 +332,7 @@
314332
- Fixed a bug where Edit Subscription pages were blank. ([#2913](https://github.com/craftcms/commerce/issues/2913))
315333
- Fixed a bug where `craft\commerce\elements\Order::hasMatchingAddresses()` wasn’t checking the `fullName` property. ([#2917](https://github.com/craftcms/commerce/issues/2917))
316334
- Fixed a bug where discounts’ Purchase Total values weren’t getting saved.
317-
- Fixed a bug where discounts’ shipping address conditions were being saved as billing address conditions. ([#2938](https://github.com/craftcms/commerce/issues/2938))
335+
- Fixed a bug where discounts’ shipping address conditions were being saved as billing address conditions. ([#2938](https://github.com/craftcms/commerce/issues/2938))
318336
- Fixed an error that occurred when exporting orders using the “Expanded” export type. ([#2953](https://github.com/craftcms/commerce/issues/2953))
319337
- Fixed a bug where it wasn’t possible to clear out variants’ min and max quantities. ([#2954](https://github.com/craftcms/commerce/issues/2954))
320338

example-templates/dist/shop/_private/layouts/includes/footer.twig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ Outputs the global site footer.
44
55
@var currentUser \craft\elements\User
66
#}
7-
{% if craft.commerce.edition == 'lite' %}
8-
<div class="bg-red-800 text-white">
9-
<div class="container mx-auto p-6">
10-
{{ 'You’re limited to one cart item at a time with Craft Commerce <span class="{classes}"> {edition}</span>. <a href="{url}" class="underline">Learn more</a>.'|t({
11-
classes: 'bg-white text-red-700 tracking-wide px-2 py-1 mx-1 rounded',
12-
edition: craft.commerce.edition|upper,
13-
url: 'https://craftcms.com/docs/commerce/4.x/editions.html',
14-
})|raw }}
15-
</div>
16-
</div>
17-
{% endif %}
187

198
<div class="bg-gray-500 text-white">
209
<div class="container mx-auto p-6">

example-templates/src/shop/_private/layouts/includes/footer.twig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ Outputs the global site footer.
44
55
@var currentUser \craft\elements\User
66
#}
7-
{% if craft.commerce.edition == 'lite' %}
8-
<div class="bg-[[dangerColor]]-800 text-white">
9-
<div class="container mx-auto p-6">
10-
{{ 'You’re limited to one cart item at a time with Craft Commerce <span class="{classes}"> {edition}</span>. <a href="{url}" class="underline">Learn more</a>.'|t({
11-
classes: 'bg-white text-red-700 tracking-wide px-2 py-1 mx-1 rounded',
12-
edition: craft.commerce.edition|upper,
13-
url: 'https://craftcms.com/docs/commerce/4.x/editions.html',
14-
})|raw }}
15-
</div>
16-
</div>
17-
{% endif %}
187

198
<div class="bg-gray-500 text-white">
209
<div class="container mx-auto p-6">

example-templates/src/shop/checkout/options.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<form action="" method="post">
3434
{{ csrfInput() }}
3535
{{ actionInput('commerce/cart/update-cart') }}
36-
{{ redirectInput(siteUrl('shop/checkout/payment')) }}
36+
{{ redirectInput(siteUrl('[[folderName]]/checkout/payment')) }}
3737
{{ successMessageInput('Options saved.') }}
3838

3939
{% set user = cart.email ? craft.users.email(cart.email).one() : null %}

src/Plugin.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
class Plugin extends BasePlugin
149149
{
150150
// Edition constants
151-
public const EDITION_LITE = 'lite';
152151
public const EDITION_PRO = 'pro';
153152

154153
public static function config(): array
@@ -201,15 +200,14 @@ public static function config(): array
201200
public static function editions(): array
202201
{
203202
return [
204-
self::EDITION_LITE,
205203
self::EDITION_PRO,
206204
];
207205
}
208206

209207
/**
210208
* @inheritDoc
211209
*/
212-
public string $schemaVersion = '4.2.8';
210+
public string $schemaVersion = '4.5.0';
213211

214212
/**
215213
* @inheritdoc
@@ -334,22 +332,22 @@ public function getCpNavItem(): ?array
334332
];
335333
}
336334

337-
if (self::getInstance()->is(self::EDITION_PRO, '>=')) {
338-
if (Craft::$app->getUser()->checkPermission('commerce-manageShipping')) {
339-
$ret['subnav']['shipping'] = [
340-
'label' => Craft::t('commerce', 'Shipping'),
341-
'url' => 'commerce/shipping',
342-
];
343-
}
344335

345-
if (Craft::$app->getUser()->checkPermission('commerce-manageTaxes')) {
346-
$ret['subnav']['tax'] = [
347-
'label' => Craft::t('commerce', 'Tax'),
348-
'url' => 'commerce/tax',
349-
];
350-
}
336+
if (Craft::$app->getUser()->checkPermission('commerce-manageShipping')) {
337+
$ret['subnav']['shipping'] = [
338+
'label' => Craft::t('commerce', 'Shipping'),
339+
'url' => 'commerce/shipping',
340+
];
351341
}
352342

343+
if (Craft::$app->getUser()->checkPermission('commerce-manageTaxes')) {
344+
$ret['subnav']['tax'] = [
345+
'label' => Craft::t('commerce', 'Tax'),
346+
'url' => 'commerce/tax',
347+
];
348+
}
349+
350+
353351
if (Craft::$app->getUser()->checkPermission('commerce-manageStoreSettings')) {
354352
$ret['subnav']['store-settings'] = [
355353
'label' => Craft::t('commerce', 'Store Settings'),

src/base/ShippingMethod.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace craft\commerce\base;
99

10+
use Craft;
1011
use craft\commerce\base\Model as BaseModel;
1112
use craft\commerce\elements\Order;
1213
use craft\commerce\errors\NotImplementedException;
1314
use craft\commerce\Plugin;
15+
use craft\errors\DeprecationException;
1416
use DateTime;
1517

1618
/**
@@ -23,6 +25,7 @@
2325
* @property-read array $shippingRules
2426
* @property-read bool $isEnabled
2527
* @property-read string $type
28+
* @property bool $isLite
2629
*/
2730
abstract class ShippingMethod extends BaseModel implements ShippingMethodInterface
2831
{
@@ -59,10 +62,28 @@ abstract class ShippingMethod extends BaseModel implements ShippingMethodInterfa
5962
public ?DateTime $dateUpdated = null;
6063

6164
/**
62-
* @var bool Is this the shipping method for the lite edition.
65+
* @return bool
66+
* @throws DeprecationException
67+
* @since 4.5.0
68+
* @deprecated in 4.5.0.
6369
*/
64-
public bool $isLite = false;
70+
public function getIsLite(): bool
71+
{
72+
Craft::$app->getDeprecator()->log(__METHOD__, 'ShippingMethod::getIsLite() is deprecated.');
73+
return false;
74+
}
6575

76+
/**
77+
* @param bool $isLite
78+
* @return void
79+
* @throws DeprecationException
80+
* @since 4.5.0
81+
* @deprecated in 4.5.0.
82+
*/
83+
public function setIsLite(bool $isLite): void
84+
{
85+
Craft::$app->getDeprecator()->log(__METHOD__, 'ShippingMethod::setIsLite() is deprecated.');
86+
}
6687

6788
/**
6889
* @inheritdoc

src/console/controllers/UpgradeController.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -888,32 +888,32 @@ private function _migrateAddresses()
888888
WHERE NOT EXISTS (
889889
SELECT 1
890890
FROM $ordersTable AS o1
891-
WHERE o1.v3billingAddressId = a.id
891+
WHERE o1."v3billingAddressId" = a.id
892892
)
893893
AND NOT EXISTS (
894894
SELECT 1
895895
FROM $ordersTable AS o2
896-
WHERE o2.v3shippingAddressId = a.id
896+
WHERE o2."v3shippingAddressId" = a.id
897897
)
898898
AND NOT EXISTS (
899899
SELECT 1
900900
FROM $ordersTable AS o2
901-
WHERE o2.v3estimatedBillingAddressId = a.id
901+
WHERE o2."v3estimatedBillingAddressId" = a.id
902902
)
903903
AND NOT EXISTS (
904904
SELECT 1
905905
FROM $ordersTable AS o2
906-
WHERE o2.v3shippingAddressId = a.id
906+
WHERE o2."v3shippingAddressId" = a.id
907907
)
908908
AND NOT EXISTS (
909909
SELECT 1
910910
FROM $ordersTable AS o2
911-
WHERE o2.v3estimatedShippingAddressId = a.id
911+
WHERE o2."v3estimatedShippingAddressId" = a.id
912912
)
913913
AND NOT EXISTS (
914914
SELECT 1
915915
FROM $customersAddressesTable AS ca
916-
WHERE ca.addressId = a.id
916+
WHERE ca."addressId" = a.id
917917
);
918918
SQL;
919919

@@ -1194,10 +1194,10 @@ public function _migrateCustomers(): void
11941194
$this->stdout(' Updating all orders with the email of its real user.');
11951195
if ($isPsql) {
11961196
$sql = <<<SQL
1197-
update $ordersTable [[o]]
1198-
set [[o.email]] = [[u.email]]
1199-
from $customersTable [[cu]], $usersTable [[u]], $ordersTable [[o]]
1200-
where [[o.v3customerId]] = [[cu.id]]
1197+
update $ordersTable [[o1]]
1198+
set [[email]] = [[u.email]]
1199+
from $customersTable [[cu]], $usersTable [[u]], $ordersTable [[o2]]
1200+
where [[o2.v3customerId]] = [[cu.id]]
12011201
and [[cu.v3userId]] = [[u.id]]
12021202
SQL;
12031203
} else {
@@ -1251,7 +1251,7 @@ public function _migrateCustomers(): void
12511251
if ($isPsql) {
12521252
$sql = <<<SQL
12531253
update $customersTable [[cu]]
1254-
set [[cu.customerId]] = [[cu.v3userId]]
1254+
set [[customerId]] = [[cu.v3userId]]
12551255
where [[cu.v3userId]] is not null
12561256
SQL;
12571257
} else {
@@ -1267,10 +1267,10 @@ public function _migrateCustomers(): void
12671267
$this->stdout(' Updating all orders with their correct user ID.');
12681268
if ($isPsql) {
12691269
$sql = <<<SQL
1270-
update $ordersTable [[o]]
1271-
set [[o.customerId]] = [[u.userId]]
1272-
from $usersTable [[u]], $ordersTable [[o]]
1273-
where [[o.email]] = [[u.email]]
1270+
update $ordersTable [[o1]]
1271+
set [[customerId]] = [[u.id]]
1272+
from $usersTable [[u]], $ordersTable [[o2]]
1273+
where [[o2.email]] = [[u.email]]
12741274
SQL;
12751275
} else {
12761276
$sql = <<<SQL
@@ -1371,12 +1371,12 @@ public function stdoutlast($string)
13711371
*/
13721372
private function _getBatchUpdateQueryWithParams($tableName, $byField, $fieldValues, $params)
13731373
{
1374-
$str = 'UPDATE `' . $this->db->getSchema()->getRawTableName($tableName) . '` SET ';
1374+
$str = 'UPDATE ' . $this->db->quoteTableName($this->db->getSchema()->getRawTableName($tableName)) . ' SET ';
13751375
$row = [];
13761376
$bind = [];
13771377

13781378
foreach (array_keys($params) as $param) {
1379-
$rowStr = '`' . $param . '` = (CASE `' . $byField . '` ';
1379+
$rowStr = $this->db->quoteColumnName($param) . ' = (CASE ' . $this->db->quoteColumnName($byField) . ' ';
13801380
$cel = [];
13811381
foreach ($fieldValues as $fieldValue) {
13821382
if (array_key_exists($fieldValue, $params[$param])) {

src/controllers/DiscountsController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ public function init(): void
5959
{
6060
parent::init();
6161

62-
if (Plugin::getInstance()->is(Plugin::EDITION_PRO, '<')) {
63-
throw new ForbiddenHttpException('Managing discounts is not permitted on the Lite edition.');
64-
}
65-
6662
$this->requirePermission('commerce-managePromotions');
6763
}
6864

0 commit comments

Comments
 (0)