Stevebauman\Inventory\Traits\InventoryTransactionTrait::releaseAll PHP Method

releaseAll() public method

Releases an on-hold inventory transaction, placing all the quantity in the transaction back into the stock.
public releaseAll ( string $reason = '', integer | float | string $cost )
$reason string
$cost integer | float | string
    public function releaseAll($reason = '', $cost = 0)
    {
        /*
         * Only allow the previous state of on-hold
         */
        $this->validatePreviousState([$this::STATE_INVENTORY_ON_HOLD], $this::STATE_INVENTORY_RELEASED);
        $released = $this->getAttribute('quantity');
        $this->setAttribute('quantity', 0);
        $this->setAttribute('state', $this::STATE_INVENTORY_RELEASED);
        if (empty($reason)) {
            $reason = $this->getTransactionReason('released');
        }
        return $this->processStockPutAndSave($released, 'inventory.transaction.released', $reason, $cost);
    }