magesuite / theme-creativeshop

Open Software License 3.0
38 stars 24 forks source link

Bundle Product price calculation incorrect #76

Open tim-breitenstein-it opened 3 years ago

tim-breitenstein-it commented 3 years ago

If the qty option for a bundle product is disabled and the default qty for this product is greater than 1 the bundle price calculation is not working correct.

The theme checks if the option canChangeQty and if not the whole qty box is not displayed.

The magento bundle price calculation needs this qty box to work correct.

https://github.com/magesuite/theme-creativeshop/blob/next/src/Magento_Bundle/templates/catalog/product/view/type/bundle/option/radio.phtml#L73

https://github.com/magesuite/theme-creativeshop/blob/next/src/Magento_Bundle/templates/catalog/product/view/type/bundle/option/select.phtml#L45

Also the logic is incorrect:

                if($canChangeQty): ?>
                    ....
                    /**
                     * Will never reached => always not disabled !!!
                     */
                    <?php $disabled = !$canChangeQty ? ' disabled="disabled"' : ''; ?>
                    ....

Solution:

                <?php if ($canChangeQty) { ?>

                    <?= $this->getLayout()
                        ->createBlock('Magento\Framework\View\Element\Template')
                        ->setInputName('bundle_option_qty[' . $option->getId() . ']')
                        ->setAdditionalInputCssClasses(' input-text qty')
                        ->setInputInitialValue($defaultQty)
                        ->setInputAdditionalParams('id="bundle-option-' . $option->getId() . '-qty-input" data-selector="bundle_option_qty[' . $option->getId() . ']" data-min-value="1" min="1"')
                        ->setDecrementIconUrl($block->getVar('qty_increment/icons/decrement', 'MageSuite_ThemeHelpers'))
                        ->setIncrementIconUrl($block->getVar('qty_increment/icons/increment', 'MageSuite_ThemeHelpers'))
                        ->setTemplate($block->getVar('qty_increment/template', 'MageSuite_ThemeHelpers'))
                        ->toHtml();
                    ?>

                <?php } else { ?>

                    <?= $this->getLayout()
                        ->createBlock('Magento\Framework\View\Element\Template')
                        ->setInputName('bundle_option_qty[' . $option->getId() . ']')
                        ->setAdditionalInputCssClasses(' input-text qty qty-disabled')
                        ->setInputInitialValue($defaultQty)
                        ->setInputAdditionalParams('id="bundle-option-' . $option->getId() . '-qty-input" data-selector="bundle_option_qty[' . $option->getId() . ']" data-min-value="1" min="1" disabled="disabled"')
                        ->setTemplate($block->getVar('qty_increment/template', 'MageSuite_ThemeHelpers'))
                        ->toHtml();
                    ?>

                <?php }
                ?>