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

checkout() public method

Checks out the specified amount of quantity from the stock, waiting to be sold.
public checkout ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string
    public function checkout($quantity = 0, $reason = '', $cost = 0)
    {
        /*
         * Only allow a transaction that has a previous state of
         * null, opened and reserved to use the checkout function
         */
        $this->validatePreviousState([null, $this::STATE_OPENED, $this::STATE_COMMERCE_RESERVED], $this::STATE_COMMERCE_CHECKOUT);
        if ($this->isReservation()) {
            return $this->checkoutFromReserved();
        }
        $this->setAttribute('quantity', $quantity);
        $this->setAttribute('state', $this::STATE_COMMERCE_CHECKOUT);
        if (empty($reason)) {
            $reason = $this->getTransactionReason('checkout');
        }
        return $this->processStockTakeAndSave($quantity, 'inventory.transaction.checkout', $reason, $cost);
    }