Skip to content

Commit

Permalink
[*] MO - powatag : added error if product quantity is lower than mini…
Browse files Browse the repository at this point in the history
…mal quantity
  • Loading branch information
tbigueres committed Nov 20, 2014
1 parent ec01d2c commit fe2b95e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/v1/classes/PowaTagOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ private function addProductsToCart($cart, $codeCountry)
$variantAmount = $variant->finalPrice->amount;

$id_product_attribute = false;
$combination = false;

if ($id_product_attribute = PowaTagProductAttributeHelper::getCombinationByCode($product->id, $variant->code))
{
$combination = new Combination($id_product_attribute);
$priceAttribute = $product->getPrice($this->display_taxes, $id_product_attribute);
$qtyInStock = PowaTagProductQuantityHelper::getProductQuantity($product, $id_product_attribute);
}
Expand Down Expand Up @@ -407,6 +409,16 @@ private function addProductsToCart($cart, $codeCountry)

return false;
}
if($p->quantity < $product->minimal_quantity || ($combination && $combination->minimal_quantity > $product->minimal_quantity))
{
$this->addError(sprintf($this->module->l('Quantity < minimal quantity for product')), PowaTagAbstract::$NOT_IN_STOCK);

if (PowaTagAPI::apiLog())
PowaTagLogs::initAPILog('Add product to cart', PowaTagLogs::ERROR, "Product : ".$this->error['message']);

return false;
}


$cart->updateQty($p->quantity, $product->id, $id_product_attribute);

Expand Down

0 comments on commit fe2b95e

Please sign in to comment.