Stevebauman\Inventory\Traits\InventoryTransactionTrait::soldAmount PHP Метод

soldAmount() публичный Метод

Marks a new or open transaction as sold and removes the amount of the specified quantity from from the inventory stock.
public soldAmount ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string
    public function soldAmount($quantity, $reason = '', $cost = 0)
    {
        // Only allow a previous state of null or opened
        $this->validatePreviousState([null, $this::STATE_OPENED], $this::STATE_COMMERCE_SOLD);
        // Mark the current state sold
        $this->setAttribute('state', $this::STATE_COMMERCE_SOLD);
        $this->setAttribute('quantity', $quantity);
        if (empty($reason)) {
            $reason = $this->getTransactionReason('sold-amount');
        }
        return $this->processStockTakeAndSave($quantity, 'inventory.transaction.sold', $reason, $cost);
    }