Skip to content

Commit 5b24bf8

Browse files
committed
#4267 error when marking inventory transfer as pending
1 parent c6f67e1 commit 5b24bf8

File tree

2 files changed

+16
-38
lines changed

2 files changed

+16
-38
lines changed

CHANGELOG.md

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

3+
## Unreleased
4+
5+
- Fixed a PHP error that occurred when marking an inventory transfer as pending. ([#4267](https://github.com/craftcms/commerce/issues/4267))
6+
37
## 5.6.1.1 - 2026-03-27
48

59
- Fixed a bug where PDF Link Duration didn’t save. ([#4265](https://github.com/craftcms/commerce/issues/4265))

src/models/inventory/UpdateInventoryLevelInTransfer.php

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,28 @@
33
namespace craft\commerce\models\inventory;
44

55
use craft\base\Model;
6-
use craft\commerce\base\InventoryItemTrait;
7-
use craft\commerce\base\InventoryLocationTrait;
86
use craft\commerce\enums\InventoryTransactionType;
9-
use craft\commerce\enums\InventoryUpdateQuantityType;
107

118
/**
129
* Update (Set and Adjust) Inventory Quantity model
1310
*
1411
* @since 5.0
1512
*/
16-
class UpdateInventoryLevelInTransfer extends Model
13+
class UpdateInventoryLevelInTransfer extends UpdateInventoryLevel
1714
{
18-
use InventoryItemTrait, InventoryLocationTrait;
19-
20-
/**
21-
* The type is the set of InventoryTransactionType values, plus the `onHand` type.
22-
* @var string The inventory update type.
23-
*/
24-
public string $type;
25-
26-
/**
27-
* Whether the update should be associated with a transfer.
28-
* @var int|null
29-
*/
30-
public ?int $transferId = null;
31-
32-
/**
33-
* @var InventoryUpdateQuantityType The action to perform on the inventory.
34-
*/
35-
public InventoryUpdateQuantityType $updateAction;
15+
protected function defineRules(): array
16+
{
17+
$rules = parent::defineRules();
3618

37-
/**
38-
* @var int The quantity to update.
39-
*/
40-
public int $quantity;
19+
// Update the `['type']` rule to online allow incoming
20+
foreach ($rules as &$item) {
21+
if ($item[0] !== ['type']) {
22+
continue;
23+
}
4124

42-
/**
43-
* @var string A note about the inventory update.
44-
*/
45-
public string $note = '';
25+
$item['range'] = [['type'], 'in', 'range' => [...InventoryTransactionType::incoming(), 'onHand']];
26+
}
4627

47-
protected function defineRules(): array
48-
{
49-
return array_merge(parent::defineRules(), [
50-
[['updateAction', 'quantity', 'inventoryLocationId', 'inventoryId', 'type'], 'required'],
51-
[['note'], 'string'],
52-
[['type'], 'in', 'range' => [...InventoryTransactionType::incoming(), 'onHand']],
53-
[['updateAction'], 'in', 'range' => InventoryUpdateQuantityType::values()],
54-
]);
28+
return $rules;
5529
}
5630
}

0 commit comments

Comments
 (0)