I have a store which sells fresh and frozen food. We need customers to order a minimum of 8kgs of frozen produce to ensure product arrives in a frozen state.

We currently have product attributes called "Fresh" & "Frozen"

What's the best way to have a minimum order (by weight)? Eg dont allow the order if the amount of frozen food is under 8kg

1 Answer 1


I would enforce this constraint in the cart using an observer. That way, you can notify the customer before they start checkout (and not make them annoyed).

checkout_cart_save_before seems like a decent candidate to hook onto with an observer. Have the observer check the weight of the cart items and thrown an exception with a warning message using the checkout session to notify the customer about the weight restriction.

Some pseudocode..

// In Observer
$quote = $observer->getCart();
foreach ($quote->getAllVisibleItems() as $item) {  // Iterate through items listed in the cart only
    // Add up the weights
// Throw exception if added weight doesn't meet the restriction

Note that if you have parent-child products, make sure you retrieve the correct weight from the simple products you have. I think when you use configurable products, the simple product's attributes may not be used (e.g. price is pulled from the configurable product, if you buy a simple product associated with a configurable product).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.