0

I'm trying to change the dropdown quantity in this theme -

currently it shows a dropdown menu of 1 to 10+ - I'd like it to only show 10, 20, 30 etc so the user can only select 3 options (10, 20, 30)

How would I go about changing both below to achieve this?

Product Page - catalog/product/view/addtocart.phtml

<?php
/**
 * Intenso Premium Theme
 *
 * @category    design
 * @package     intenso_default
 * @copyright   Copyright (c) 2014-2015 Itactica (http://www.itactica.com)
 * @license     http://getintenso.com/license
 */
?>
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php $productData = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product); ?>
<?php
    $attributeOptions = array();
    if ($_product->isConfigurable()) {
        $productAttributeOptions = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
        foreach ($productAttributeOptions as $productAttribute) {
            $attributeOptions[] = $productAttribute['label'];
        }
    }
?>
<?php if($_product->isSaleable() && Mage::getStoreConfig('intenso/product_page/product_show_add_to_cart', Mage::app()->getStore())): ?>
<div class="buybox bg-box center">
    <?php if ($attributeOptions): ?>
        <p><?php echo $this->__('To buy, select <strong>%s</strong>',implode($this->__(' and '), $attributeOptions)) ?></p>
        <p class="small"><?php echo $this->__('Choose from options to the left') ?></p>
    <?php endif; ?>
    <?php if($_product->isGrouped()): ?>
        <p><?php echo $this->__('To buy, select quantities to the left') ?></strong></p>
    <?php endif; ?>
    <div class="add-to-cart">
        <?php if(!$_product->isGrouped()): ?>
        <div class="qty-wrapper">
        <label for="qty"><?php echo $this->__('Qty:') ?></label>
            <span id="qty-wrapper">
            <?php if ($this->helper('itactica_intenso')->qtyFieldIsDropdown() && ($this->getProductDefaultQty() * 1) < 10): ?>
                <select name="qty" id="qty" class="simulate-change">
                <?php for ($i=1; $i < 10; $i++): ?>
                    <option value="<?php echo $i; ?>"<?php if (($this->getProductDefaultQty() * 1) == $i): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
                <?php endfor; ?>
                <option value="10">10+</option>
                </select>
                <script>
                $("qty").observe('change', function(){
                    if ($(this).getValue() == 10) {
                        $("qty-wrapper").update('<input type="number" name="qty" id="qty" value="<?php echo $this->getProductDefaultQty() * 1 ?>" size="4" title="<?php echo $this->__('Qty') ?>" maxlength="10" class="qty-input-text" />');
                    }
                });
                </script>
            <?php else: ?>
                <input type="text" name="qty" id="qty" value="<?php echo $this->getProductDefaultQty() * 1 ?>" class="qty-input-text" />
            <?php endif; ?>
            </span>
        </div>
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>

        <?php echo $this->getChildHtml('', true, true) ?>
    </div>
</div>
<?php endif; ?>

Checkout - checkout/cart/item/default.phtml

<?php
/**
 * Intenso Premium Theme
 *
 * @category    design
 * @package     intenso_default
 * @copyright   Copyright (c) 2014 Itactica (http://www.itactica.com)
 * @license     http://getintenso.com/license
 */
?>
<?php
$_item = $this->getItem();
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();
$canApplyMsrp = Mage::helper('catalog')->canApplyMsrp($_item->getProduct(), Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type::TYPE_BEFORE_ORDER_CONFIRM);
?>
<tr>
    <td><?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?></td>
    <td>
        <?php if ($this->hasProductUrl()):?><a href="<?php echo $this->getProductUrl() ?>" title="<?php echo $this->escapeHtml($this->getProductName()) ?>" class="product-image for-small"><?php endif;?><img src="<?php echo $this->getProductThumbnail()->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($this->getProductName()) ?>" /><?php if ($this->hasProductUrl()):?></a><?php endif;?>
        <h2 class="product-name">
        <?php if ($this->hasProductUrl()):?>
            <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a>
        <?php else: ?>
            <?php echo $this->escapeHtml($this->getProductName()) ?>
        <?php endif; ?>
        </h2>
        <?php if ($_options = $this->getOptionList()):?>
        <dl class="item-options clearfix">
            <?php foreach ($_options as $_option) : ?>
            <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
            <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                <?php if (isset($_formatedOptionValue['full_view'])): ?>
                <div class="truncated_full_value">
                    <dl class="item-options">
                        <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                        <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
                    </dl>
                </div>
                <?php endif; ?>
            </dd>
            <?php endforeach; ?>
        </dl>
        <?php endif;?>
        <?php if ($messages = $this->getMessages()): ?>
        <?php foreach ($messages as $message): ?>
            <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
        <?php endforeach; ?>
        <?php endif; ?>
        <?php $addInfoBlock = $this->getProductAdditionalInformationBlock(); ?>
        <?php if ($addInfoBlock): ?>
            <?php echo $addInfoBlock->setItem($_item)->toHtml() ?>
        <?php endif;?>
        <?php if ($isVisibleProduct): ?>
        <a href="<?php echo $this->getConfigureUrl() ?>" title="<?php echo $this->__('Edit item parameters') ?>" class="btn-edit"><?php echo $this->__('Edit') ?></a>
        <?php endif ?>
        <a href="<?php echo $this->getDeleteUrl()?>" title="<?php echo $this->__('Remove item')?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove item')?></a>
    </td>
    <?php /*if ($this->helper('wishlist')->isAllowInCart()) : ?>
    <td class="a-center">
        <?php if ($isVisibleProduct): ?>
            <a href="<?php echo $this->helper('wishlist')->getMoveFromCartUrl($_item->getId()); ?>" class="link-wishlist use-ajax"><?php echo $this->__('Move'); ?></a>
        <?php endif ?>
    </td>
    <?php endif*/ ?>
    <?php if ($canApplyMsrp): ?>
        <td class="a-right"<?php if ($this->helper('tax')->displayCartBothPrices()): ?> colspan="2"<?php endif; ?>>
            <span class="cart-price">
                <span class="cart-msrp-unit"><?php echo $this->__('See price before order confirmation.'); ?></span>
                <?php $helpLinkId = 'cart-msrp-help-' . $_item->getId(); ?>
                <a id="<?php echo $helpLinkId ?>" href="#" class="map-help-link" data-reveal-id="map-popup"><?php echo $this->__("What's this?"); ?></a>
                <script type="text/javascript">
                    Catalog.Map.addHelpLink($('<?php echo $helpLinkId ?>'), "<?php echo $this->__('What\'s this?') ?>");
                </script>
            </span>
        </td>
    <?php else: ?>

        <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <td class="a-right">
            <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                <span class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
            <?php else: ?>
                <span class="cart-price">
            <?php endif; ?>
                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                    <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?>
                <?php else: ?>
                    <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()) ?>
                <?php endif; ?>

            </span>

            <?php if (Mage::helper('weee')->getApplied($_item)): ?>

                <div class="cart-tax-info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </div>

                <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                    <div class="cart-tax-total" onclick="taxToggle('eunit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
                        <span class="weee"><?php echo Mage::helper('weee')->__('Total'); ?>: <?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
                    </div>
                <?php endif; ?>
            <?php endif; ?>
        </td>
        <?php endif; ?><!-- inclusive price starts here -->
        <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <td>
            <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
            <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                <span class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
            <?php else: ?>
                <span class="cart-price">
            <?php endif; ?>

                <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                    <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
                <?php else: ?>
                    <?php echo $this->helper('checkout')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?>
                <?php endif; ?>

            </span>
            <?php if (Mage::helper('weee')->getApplied($_item)): ?>

                <div class="cart-tax-info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;">
                    <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                        <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
                            <span class="weee"><?php echo $tax['title']; ?>: <?php echo Mage::helper('checkout')->formatPrice($tax['amount_incl_tax'],true,true); ?></span>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </div>

                <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
                    <div class="cart-tax-total" onclick="taxToggle('unit-item-tax-details<?php echo $_item->getId(); ?>', this, 'cart-tax-total-expanded');">
                        <span class="weee"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>: <?php echo $this->helper('checkout')->formatPrice($_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
                    </div>
                <?php endif; ?>
            <?php endif; ?>
        </td>
        <?php endif; ?>
    <?php endif; ?>
    <td id="qty-wrapper-<?php echo $_item->getId() ?>" class="qty-wrapper">
        <?php if ($this->getQty() < 10): ?>
            <select name="cart[<?php echo $_item->getId() ?>][qty]" id="cart[<?php echo $_item->getId() ?>][qty]" class="simulate-change">
                <?php for ($i=1; $i < 10; $i++): ?>
                    <option value="<?php echo $i ?>"<?php if ($this->getQty() == $i): ?> selected="selected"<?php endif; ?>><?php echo $i ?></option>
                <?php endfor; ?>
                <option value="10">10+</option>
            </select>
            <script type="text/javascript">
                var updateButton<?php echo $_item->getId() ?> = true;
                $("cart[<?php echo $_item->getId() ?>][qty]").observe('change', function(){
                    if ($(this).getValue() == 10) {
                        $("qty-wrapper-<?php echo $_item->getId() ?>").update('<input type="number" min="0" name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" maxlength="10" class="input-text qty" />');
                    }
                    if (updateButton<?php echo $_item->getId() ?> && $(this).getValue() != <?php echo $this->getQty() ?>) {
                        $("qty-wrapper-<?php echo $_item->getId() ?>").insert('<button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update tiny"><span><?php echo $this->__('Update'); ?></span></button>');
                        updateButton<?php echo $_item->getId() ?> = false;
                    }
                    if ($(this).getValue() == <?php echo $this->getQty() ?> && !updateButton<?php echo $_item->getId() ?>) {
                        $("qty-wrapper-<?php echo $_item->getId() ?>").select('.button').first().remove();
                        updateButton<?php echo $_item->getId() ?> = true;
                    }
                });
            </script>
        <?php else: ?>
            <input name="cart[<?php echo $_item->getId() ?>][qty]" id="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="3" />
            <script type="text/javascript">
                var updateButton<?php echo $_item->getId() ?> = true;
                $("cart[<?php echo $_item->getId() ?>][qty]").observe('keyup', function(){
                    if (($(this).getValue() < <?php echo $this->getQty() ?> || $(this).getValue() > <?php echo $this->getQty() ?>) && $(this).getValue() != '') {
                        if (!$("qty-wrapper-<?php echo $_item->getId() ?>").select('.button').first()) {
                            $("qty-wrapper-<?php echo $_item->getId() ?>").insert('<button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update tiny"><span><?php echo $this->__('Update'); ?></span></button>');
                        }
                        updateButton<?php echo $_item->getId() ?> = false;
                    } else {
                        if ($("qty-wrapper-<?php echo $_item->getId() ?>").select('.button').first()) {
                            $("qty-wrapper-<?php echo $_item->getId() ?>").select('.button').first().remove();
                            updateButton<?php echo $_item->getId() ?> = true;
                        }
                    }
                });
            </script>
        <?php endif; ?>
    </td>
</tr>

1 Answer 1

1

It is not clear which dropdown you are talking about in your question. But I can see a select element which you had been talking about in your question. So please replace this part of code :

<select name="qty" id="qty" class="simulate-change">
            <?php for ($i=1; $i < 10; $i++): ?>
                <option value="<?php echo $i; ?>"<?php if (($this->getProductDefaultQty() * 1) == $i): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
            <?php endfor; ?>
            <option value="10">10+</option>
            </select>

with this code:

<select name="qty" id="qty" class="simulate-change">
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="30">30</option>
</select>

in addtocart.phtml file

1
  • Also change it in checkout/cart/item/default.phtml Commented Feb 4, 2017 at 8:30

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.