Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle Product price calculation incorrect #76

Open
tim-breitenstein-it opened this issue Apr 28, 2021 · 0 comments
Open

Bundle Product price calculation incorrect #76

tim-breitenstein-it opened this issue Apr 28, 2021 · 0 comments

Comments

@tim-breitenstein-it
Copy link

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 }
                ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant