Giter Site home page Giter Site logo

itonomy / magento2-bundle-products-change-qty Goto Github PK

View Code? Open in Web Editor NEW
12.0 8.0 12.0 89 KB

Allow quantity changes with the checkbox based options on bundle products.

License: MIT License

PHP 9.27% JavaScript 66.15% HTML 24.58%
magento2 magento2-module module bundle-products php

magento2-bundle-products-change-qty's Introduction

Magento 2 BundleProduct Change Qty

Latest Stable Version Total Downloads License

Allow customers to change the quantity on checkbox based bundle product options.

Magento, by default, doesn't allow customers to change the quantity of checkbox options on Bundle products. This module changes that.

Notes

  • Magento doesn't allow this by intended design, for more information, please refer to this issue. This module changes a core mechanic.
  • This module does not include any styling

Requirements

  • magento 2
  • php: ~7.0

Installation

  • Add the module to composer:

      composer require itonomy/bundleproductchangeqty
    
  • Run bin/magento setup:upgrade to enable the module.

  • Clear cache

      'php bin/magento c:f'
    

Usage

Checkbox template is overwritten, so with a default Magento installation it should look something like this.

Changelog

  • 1.0.0 First version module
  • 1.0.1 Quantity input for bundle options with only a single product is now visible as well. This compliments the module by providing even more customizability. Issue: #2

License

MIT

magento2-bundle-products-change-qty's People

Contributors

raphaelbronsveld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magento2-bundle-products-change-qty's Issues

Module is not working when we edit product from Cart or Wishlist

I have added this extension in my project and verify it's functionality. I have done some changes as per requirement. All extension is working properly while we add product in cart and wishlist.

But when User edit this product from cart or wishlist We face an error in vendor/magento/module-bundle/Block/Catalog/Product/View/Type/Bundle.php on line 189 I have fix this issue and User can see Bundle Options properly on edit Page.

Main issue is qty is not set as we have changed, It's changed with default qty which is set in Admin. Not different qty which User sets.

Please confirm this issue and let me know.

Edit item not working (bundle checkbox option with qty input)

Hello.

If I want edit item from minicart (click to Edit icon) or from my cart, than bundle options are not visibled because optionConfig is empty (null)

for example link (https://your_page/checkout/cart/configure/id/{{id-number}}/product_id/{{id-number2}}/)

Magento version 2.3.3
Console error

Uncaught TypeError: Cannot read property 'prices' of null
    at $.<computed>.<computed>.createPriceBundle (price-bundle.js:67)
    at $.<computed>.<computed>._create (widget.js:100)
    at $.<computed>.<computed>._createWidget (widget.js:260)
    at new $.<computed>.<computed> (widget.js:61)
    at HTMLFormElement.<anonymous> (widget.js:206)
    at Function.each (jquery.js:376)
    at jQuery.fn.init.each (jquery.js:142)
    at jQuery.fn.init.$.fn.<computed> [as priceBundle] (widget.js:201)
    at $.<computed>.<computed>._create (product-summary.js:42)
    at $.<computed>.<computed>._create (widget.js:100)

How to change input's value by custom button?

Hi,
thank you for this extension! I installed it and it works fine. But I use a custom style with plus and minus buttons to increase/decrease the value of the quantity input box. How can I make these buttons work with the current configuration of the bundle? Changing the value of the input box by using the buttons, the current bundle configuration is not changed...
Can you give an advise here?
Thank you!

Only 1 product in option: checkbox and quantity field are not shown

Hi there,

if you have only 1 product in a bundle option group, no checkbox and no quantity field is shown. So this product is always part of the bundle, you cannot remove it or change quantity. It only works with a product count > 1 per group. This behaviour does not make sense for me.

Best regards
Markus

Problem when add to cart

Hi, i have problem when Bundle Product is adding to cart, all child item quantity are set at 1 ? In your Model, class Type extends \Magento\Bundle\Model\Product\Type

protected function getQty($selection, $qtys, $selectionOptionId)
    {
        if ($selection->getSelectionCanChangeQty() && isset($qtys[$selectionOptionId])) {
            $qty = (float)$qtys[$selectionOptionId] > 0 ? $qtys[$selectionOptionId] : 1;

            var_dump($qty); /*is an array like array(2) { [1]=> string(1) "6" [2]=> string(1) "7" } array(2) { [1]=> string(1) "6" [2]=> string(1) "7" } [] */
        } elseif (isset($qtys[$selectionOptionId][$selection->getId()])) {
            $qty = (float)$qtys[$selectionOptionId][$selection->getId()] ? $qtys[$selectionOptionId][$selection->getId()] : 1;
        } else {
            $qty = (float)$selection->getSelectionQty() ? $selection->getSelectionQty() : 1;
        }

        $qty = (float) $qty; /* array are transforming in float value so 1 */

        return $qty;
    }
}

Quantity for checkbox option is not reflected for product items which have can_change_quantity property true

Quantity for checkbox option is not reflected for product items which have can_change_quantity property true.
For e.g. a bundle product has checkbox product sku and the product sku has can_change_quantity set to 1 (true),

protected function getQty($selection, $qtys, $selectionOptionId) { if ($selection->getSelectionCanChangeQty() && isset($qtys[$selectionOptionId])) { $qty = (float)$qtys[$selectionOptionId] > 0 ? $qtys[$selectionOptionId] : 1; } elseif (isset($qtys[$selectionOptionId][$selection->getId()])) { $qty = (float)$qtys[$selectionOptionId][$selection->getId()] ? $qtys[$selectionOptionId][$selection->getId()] : 1; } else { $qty = (float)$selection->getSelectionQty() ? $selection->getSelectionQty() : 1; } $qty = (float)$qty; return $qty; }

In this situation, it goes in the first if case since it has $selection->getSelectionCanChangeQty() which is true.
It does not get the qty value specified and hence it become qty 1

Please advise if you can set the can_change_quantity to 0 for all checkbox items and is not regressed wlesewhere till checkout or any fix can be applied to this piece of code for method getQty.

Thanks,
Girdar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.