質問

I added dropdown for product qty box in addtocart.phtml like below:

<div class="field qty">
        <label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>               
        <select name="qty" id="qty" title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" 
               class="input-text qty" data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>">
               <?php $i = 1 ; ?>
                <?php 
                 while( $i < 500) { ?>
                    <option value="<?php echo $block->getProductDefaultQty() * $i; ?>"><?php echo $block->getProductDefaultQty() * $i; ?></option>
                    <?php $i++; ?>
                 <?php } ?>
        </select>

    </div>

But I also want to implement same in updatecart.html in magento 2. How to do that?

enter image description here

役に立ちましたか?

解決

You are doing correctly.

First copy updatecart.phtml file from vendor/magento/module-checkout/view/frontend/templates/cart/item/configure/updatecart.phtml file and put it in your theme at app/design/frontend/[Vendor]/[Theme]/Magento_Checkout/templates/cart/item/configure/updatecart.phtml.

code as per requirement.

Just replace div in that file

<div class="field qty">
   <label class="label" for="qty">
       <span><?= /* @escapeNotVerified */ __('Qty') ?></span>
   </label>
   <div class="control">
       <select name="qty" id="qty" title="<?php echo __('Qty') ?>" 
            class="input-text qty" data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>">
                <?php $i = 1 ; ?>
                <?php 
                while( $i < 500) { ?>
                    <option value="<?php echo $block->getProductDefaultQty() * $i; ?>"><?php echo $block->getProductDefaultQty() * $i; ?></option>
                    <?php $i++; ?>
                <?php } ?>
        </select>
    </div>
</div>
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top