如何在尺寸属性 magento 2 下方的产品详细信息页面中添加多个数量?

How to add multiple quantity in product detail page below size attribute magento 2?

如果可能的话,请告诉我如何在产品详细信息页面中添加多个数量,而不是我们在 magento 2.

中必须遵循的实施流程

 <?php $_product = $block->getProduct(); ?>
    <?php $buttonTitle = __('Add to Cart'); ?>
    <?php if ($_product->isSaleable()): ?>
 <div class="box-tocart">
<div class="fieldset">
    <?php if ($block->shouldRenderQuantity()): ?>
    <div class="field qty">
        <label class="label" for="qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></label>
        <div class="control">
            <input type="number"
                   name="qty"
                   id="qty"
                   maxlength="12"
                   value="<?php /* @escapeNotVerified */ echo $block->getProductDefaultQty() * 1 ?>"
                   title="<?php /* @escapeNotVerified */ echo __('Qty') ?>" class="input-text qty"
                   data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
                   />
        </div>
    </div>
    <?php endif; ?>
    <div class="actions">
        <button type="submit"
                title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
                class="action primary tocart"
                id="product-addtocart-button">
            <span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
        </button>
        <?php echo $block->getChildHtml('', true) ?>
    </div>
 </div>
</div>
 <?php endif; ?>
 <?php if ($block->isRedirectToCartEnabled()) : ?>
 <script type="text/x-magento-init">
  {
     "#product_addtocart_form": {
         "Magento_Catalog/product/view/validation": {
            "radioCheckboxClosest": ".nested"
         }
     }
  }
 </script>
 <?php else : ?>
   <script>
      require([
      'jquery',
      'mage/mage',
      'Magento_Catalog/product/view/validation',
       'Magento_Catalog/js/catalog-add-to-cart'
       ], function ($) {
       'use strict';

    $('#product_addtocart_form').mage('validation', {
        radioCheckboxClosest: '.nested',
        submitHandler: function (form) {
            var widget = $(form).catalogAddToCart({
                bindSubmit: false
            });

            widget.catalogAddToCart('submitForm', $(form));

            return false;
        }
    });
});

Bespoke/view/frontend/templates/product/view/addtocart.phtml 在这个文件中我们需要实现。

此代码适用于单个数量,我们必须按照上面的图片执行相同的操作。

如果我理解正确的话,您希望能够从可配置产品页面同时添加不同数量的多个配置。

为此,您可以创建一个带有控制器的新扩展,其行为类似于您在核心中找到的将项目添加到组中的控制器。

不同之处在于 there the products are added without information, instead of that you should use addProduct 并传递所有需要的信息。

如果你不想自己开发这个,你可以在网上查看扩展,快速 google 搜索让我找到了 something similar 你想要创建的东西,但是因为我不是开发该扩展的人,也不是我自己尝试过的人,我无法判断它是否有用。