Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft Commerce

## Unreleased

- Fixed a PHP error on the dashboard that could occur for users without edit permissions on any site. ([#4347](https://github.com/craftcms/commerce/issues/4347))

## 5.7.3 - 2026-09-02

- Fixed a bug where `craft\commerce\elements\Order::setShippingAddress()` and `setBillingAddress()` weren’t setting custom field values. ([#4353](https://github.com/craftcms/commerce/issues/4353))
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/AverageOrderTotal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\AverageOrderTotal as AverageOrderTotalStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -45,9 +46,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_stat = new AverageOrderTotalStat(
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/NewCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\NewCustomers as NewCustomersStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -47,9 +48,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_stat = new NewCustomersStat(
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/widgets/RepeatCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\RepeatCustomers as RepeatingCustomersStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -45,9 +46,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->dateRange = !isset($this->dateRange) || !$this->dateRange ? RepeatingCustomersStat::DATE_RANGE_TODAY : $this->dateRange;
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TopCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TopCustomers as TopCustomersStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -60,9 +61,9 @@ class TopCustomers extends Widget
public function init(): void
{
if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_typeOptions = [
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TopProductTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TopProductTypes as TopProductTypesStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -60,9 +61,9 @@ class TopProductTypes extends Widget
public function init(): void
{
if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_typeOptions = [
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TopProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TopProducts as TopProductsStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -77,9 +78,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_typeOptions = [
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TopPurchasables.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TopPurchasables as TopPurchasablesStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -70,9 +71,9 @@ class TopPurchasables extends Widget
public function init(): void
{
if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->nameField = isset($this->nameField) ?: 'description';
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TotalOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TotalOrders as TotalOrdersStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -49,9 +50,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->dateRange = !isset($this->dateRange) || !$this->dateRange ? TotalOrdersStat::DATE_RANGE_TODAY : $this->dateRange;
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TotalOrdersByCountry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use craft\base\Widget;
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\Plugin;
use craft\commerce\stats\TotalOrdersByCountry as TotalOrdersByCountryStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -63,9 +64,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->_typeOptions = [
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/TotalRevenue.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\commerce\base\StatWidgetTrait;
use craft\commerce\behaviors\StoreBehavior;
use craft\commerce\helpers\Currency;
use craft\commerce\Plugin;
use craft\commerce\stats\TotalRevenue as TotalRevenueStat;
use craft\commerce\web\assets\commercewidgets\CommerceWidgetsAsset;
use craft\commerce\web\assets\statwidgets\StatWidgetsAsset;
Expand Down Expand Up @@ -71,9 +72,9 @@ public function init(): void
parent::init();

if (!(isset($this->storeId)) || !$this->storeId) {
/** @var Site|StoreBehavior $site */
/** @var Site|StoreBehavior|null $site */
$site = Cp::requestedSite();
$this->storeId = $site->getStore()->id;
$this->storeId = $site?->getStore()->id ?? Plugin::getInstance()->getStores()->getPrimaryStore()->id;
}

$this->dateRange = !isset($this->dateRange) || !$this->dateRange ? TotalRevenueStat::DATE_RANGE_TODAY : $this->dateRange;
Expand Down
Loading