2

I'm trying to set a product with different prices depending on quantity "chosen from drop-down"

But I have no idea how to create this. basically I have a product which comes in this quantities: 20, 32, 42, 56, 65, 75, 88 ,106, 126, 138 so user should select one of this options to have corresponding price, I cannot use the increment option as the quantity is not multiple.

2

2 Answers 2

1

You can add price based on qty using "Tier price" for product.

For adding tier price you need to open product->price tab and there is field call tier price.

5
  • yes, i have the tier price already, but what i want is the user in frontend to chose the specified quantity from a dropdown box, so they dont enter a number of product i dont want... Commented Jan 21, 2015 at 14:00
  • you can do once thing: $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); Based on qty you can create dropdown. Commented Jan 21, 2015 at 14:05
  • Thanks for your answer, but no, as i have other products which dont use the same option Commented Jan 21, 2015 at 14:11
  • 1
    If other product has other attribute set than you can add attribute set wise condition. Commented Jan 21, 2015 at 14:13
  • im sorry, but i dont get what you are saying, no offense Commented Jan 21, 2015 at 14:20
0

If the quantities you listed above are fixed, you can try adding following code to catalog/product/view/addtocart.phtml file.

<label for="qty"><?php echo $this->__('Qty:') ?></label>
<?php if ($_product->getSomeValue()): ?>
    <select id="qty" name="qty">
        <option value="20">20</option>
        <option value="32">32</option>
        <option value="32">45</option>
    </select>
<?php else: ?>
    <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<?php endif ?>

Note: $_product->getSomeValue() is just a dummy check, I'm assuming you have some way to distinguish regular qty from drop down qty products.

Would something like this work for you?

1
  • Thanks for your answer, what for you mean by dummy check? For the quantities i could use a tier price, also i need to be sure that this code should apply only for a specific category as other products won't use this. Commented Jan 22, 2015 at 9:48

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.