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);
}