Skip to content

Commit

Permalink
Merge pull request PrestaShop#35902 from boherm/PrestaShop#35888-fix-…
Browse files Browse the repository at this point in the history
…min-qty-in-front
  • Loading branch information
boherm authored Jun 13, 2024
2 parents 31f0dd2 + 4965d7a commit 1d31acb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/front/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ public function displayAjaxRefresh()
$product = $this->getTemplateVarProduct();
$minimalProductQuantity = $this->getProductMinimalQuantity($product);

// If the product is already in the cart, we can set the minimal quantity to 1
if ($product['cart_quantity'] >= $minimalProductQuantity) {
$minimalProductQuantity = 1;
}

ob_end_clean();
header('Content-Type: application/json');
$this->ajaxRender(json_encode([
Expand Down Expand Up @@ -1199,6 +1204,7 @@ public function getTemplateVarProduct()
$product['new'] = (int) $this->product->new;
$product['id_product_attribute'] = $this->getIdProductAttributeByGroupOrRequestOrDefault();
$product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
$product['cart_quantity'] = $this->context->cart->getProductQuantity($product['id_product'], $product['id_product_attribute'])['quantity'];
$product['quantity_wanted'] = $this->getRequiredQuantity($product);
$product['extraContent'] = $extraContentFinder->addParams(['product' => $this->product])->present();
$product['ecotax_tax_inc'] = $this->product->getEcotax(null, true, true);
Expand Down Expand Up @@ -1320,6 +1326,10 @@ protected function getRequiredQuantity($product)
$requiredQuantity = $product['minimal_quantity'];
}

if ($product['cart_quantity'] >= $requiredQuantity) {
return 0;
}

return $requiredQuantity;
}

Expand Down

0 comments on commit 1d31acb

Please sign in to comment.