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

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

Marks a transaction as returned and places the stock that was taken back into the inventory.
public returnedAll ( string $reason = '', integer | float | string $cost )
$reason string
$cost integer | float | string
    public function returnedAll($reason = '', $cost = 0)
    {
        /*
         * Only allow returns when the transaction state is
         * sold, reserved, checkout, or returned partial
         */
        $this->validatePreviousState([$this::STATE_COMMERCE_SOLD, $this::STATE_COMMERCE_RESERVED, $this::STATE_COMMERCE_CHECKOUT, $this::STATE_COMMERCE_RETURNED_PARTIAL], $this::STATE_COMMERCE_RETURNED);
        // Set the state to returned
        $this->setAttribute('state', $this::STATE_COMMERCE_RETURNED);
        $current = $this->getAttribute('quantity');
        /*
         * Set the quantity to zero because we are
         * returning all of the stock
         */
        $this->setAttribute('quantity', 0);
        if (empty($reason)) {
            $reason = $this->getTransactionReason('returned');
        }
        return $this->processStockPutAndSave($current, 'inventory.transaction.removed', $reason, $cost);
    }