Jump to content

Increment multiples


Recommended Posts

Hi,

To enforce a minimum quantity that increases in specific multiples (e.g., 2, 4, 6) in PrestaShop, you will likely need to adjust the logic in the cart and product controllers, as PrestaShop doesn't support quantity increments natively.

You can try modifying the multiple by overriding the cart class.

In your custom Cart.php override, add this function to check if the quantity matches the required multiple before it’s added to the cart.

public function updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = null, $operator = 'up', $id_address_delivery = 0, $shop = null, $auto_add_cart_rule = true)
{
$multiple = 5;

if ($quantity % $multiple != 0) {
$quantity = ceil($quantity / $multiple) * $multiple;
}

return parent::updateQty($quantity, $id_product, $id_product_attribute, $id_customization, $operator, $id_address_delivery, $shop, $auto_add_cart_rule);
}

Please modify the above code according to your needs as it might require some modifications.

Regards.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...