3

How to Update price automatically when quantity changed on the product page?

I am updating the qty input type to dropdown through below code and I want when I change the qty in dropdown price to be updated...

 <td class="col qty" data-th="<?php echo $block->escapeHtml(__('Qty')); ?>">
       <div class="field qty">
                <select id="cart-<?php /* @escapeNotVerified */
                echo $_item->getId() ?>-qty" name="cart[<?php /* @escapeNotVerified */
                echo $_item->getId() ?>][qty]" title="<?php echo $block->escapeHtml(__('Qty')); ?>" data - cart - item -
                        id="<?php /* @escapeNotVerified */
                        echo $_item->getSku() ?>">
                    <?php for ($i = 1; $i <= $qty; $i++): ?>
                        <option value="<?php echo $i; ?>"<?php if ($i == $block->getQty()) {
                            echo 'selected';
                        } ?>><?php echo $i; ?></option>
                        <//?php $i = $i + 4; ?>
                    <?php endfor; ?>
                </select>
            </div>
        </div>
    </td>
4
  • it mean discount or any else? Dec 9 '16 at 7:42
  • No i added + and - button in quantity so i want to update price when quantity increase and decreases so help meregards
    – sangan
    Dec 9 '16 at 7:47
  • @sangan, post your code, so that we will find answers from that.
    – Bojjaiah
    Dec 9 '16 at 9:03
  • still i did't updated ..just i made qty input type as dropdown so then whenever we select qty price to be update..??
    – sangan
    Mar 30 '17 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.