Skip to content

Commit

Permalink
Merge pull request #3759 from craftcms/feature/pt-2306-5x-invalid-pur…
Browse files Browse the repository at this point in the history
…chasable-id-in-cp-create-order-when-order-set

Fixed #3756 purchasables incorrectly returning on order edit
  • Loading branch information
nfourtythree authored Nov 11, 2024
2 parents 1992203 + dca1815 commit 83b9a4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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 bug where purchasables were showing incorrectly on the Edit Order screen. ([#3756](https://github.com/craftcms/commerce/issues/3756))

## 5.2.2.1 - 2024-11-08

- Fixed a PHP error that could occur when retrieving a variant. ([#3754](https://github.com/craftcms/commerce/issues/3754))
Expand Down
8 changes: 8 additions & 0 deletions src/controllers/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ public function actionPurchasablesTable(): Response
'and',
'[[elements.id]] = [[purchasables.id]]',
])
// Make sure this purchasable is enabled for the site
->innerJoin(['es' => CraftTable::ELEMENTS_SITES], [
'and',
'[[es.elementId]] = [[purchasables.id]]',
'[[es.siteId]] = :siteId',
], [
':siteId' => $siteId,
])
->innerJoin(Table::PURCHASABLES_STORES . ' pstores', '[[purchasables.id]] = [[pstores.purchasableId]]')
->where(['elements.enabled' => true])
->andWhere(['pstores.storeId' => $store->id])
Expand Down

0 comments on commit 83b9a4c

Please sign in to comment.