Skip to content

Commit

Permalink
Fixed a display error for inventory items
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Oct 8, 2024
1 parent d28cf74 commit 4117834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fixed a bug where inventory items could appear with blank descriptions on the Inventory management screen. ([#3706](https://github.com/craftcms/commerce/issues/3706))
- Fixed a bug where additional buttons defined with `Order::EVENT_DEFINE_ADDITIONAL_BUTTONS` weren’t displayed on the Edit Order screen. ([#3692](https://github.com/craftcms/commerce/issues/3692))
- Fixed a bug where email errors weren’t displayed on the Edit Order screen. ([#3693](https://github.com/craftcms/commerce/issues/3693))

Expand Down
7 changes: 5 additions & 2 deletions src/controllers/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use craft\commerce\db\Table;
use craft\commerce\enums\InventoryTransactionType;
use craft\commerce\enums\InventoryUpdateQuantityType;
use craft\commerce\helpers\Purchasable as PurchasableHelper;
use craft\commerce\models\inventory\InventoryManualMovement;
use craft\commerce\models\inventory\UpdateInventoryLevel;
use craft\commerce\models\InventoryItem;
Expand Down Expand Up @@ -278,11 +279,13 @@ public function actionInventoryLevelsTableData(): Response
$inventoryItemDomId = sprintf("edit-$id-link-%s", mt_rand());
if ($purchasable) {
$inventoryLevel['purchasable'] = Cp::chipHtml($purchasable, ['labelHtml' => $purchasable->getDescription(), 'showActionMenu' => !$purchasable->getIsDraft() && $purchasable->canSave($currentUser)]);
$inventoryLevel['sku'] = Html::tag('span', Html::a($purchasable->getSkuAsText(), "#", ['id' => "$inventoryItemDomId", 'class' => 'code']));
} else {
$inventoryLevel['purchasable'] = '';
$inventoryLevel['purchasable'] = $inventoryLevel['description'];
}
if (PurchasableHelper::isTempSku($inventoryLevel['sku'])) {
$inventoryLevel['sku'] = '';
}
$inventoryLevel['sku'] = Html::tag('span', Html::a($inventoryLevel['sku'], "#", ['id' => "$inventoryItemDomId", 'class' => 'code']));
$inventoryLevel['id'] = $id;

$view->registerJsWithVars(fn($id, $params, $inventoryLevelsManagerContainerId) => <<<JS
Expand Down

0 comments on commit 4117834

Please sign in to comment.