0

My understanding of Grouped Products is a little limited, but as I understand it, a Grouped Product is simply a listing of products that I want to show to customers on one page.

If one or more items are added to the cart from that Grouped Product, they are added as individual line items.

Why then, would I not be able to add ANY individual line items to my cart from a Grouped Product page if ANY of the listed products are out of stock?

Example: a Grouped Product with 20 individual products listed on the page - one of those listed items is out of stock. This means I am unable to add any item on that page to the cart, with the message "This product is out of stock." displayed if I try.

If I add the out of stock product into stock and then try the same process again, I can add items to the cart just fine.

Is this another bug in Magento 2.1?

Anyone know of a fix, if so?

  • This does indeed seem to be a bug, it's like that in 2.2 as well, if you have "Display Out of Stock Products" set to "no" within the admin > Catalog > Inventory, then child products that are out of stock don't display and doesn't mess with the post array, I've just experienced this myself and found your post, so I'm looking at writing a module for moving them to a separate "out of stock" block as we want to display out of stock items – PhilS Mar 13 '18 at 14:27
0

I ended up just manipulating the grouped product template, it seems that the qty fields are all passed as an array, and as the "out of stock" items have no input field or value they throw a validation error.

I just added my own grouped.phtml in /app/design/frontend/<Vendor>/<Theme>/Magento_GroupedProduct/templates/product/view/type and copied the entire phtml file from the Magento core, with just the addition of a hidden field in the out of stock condition:

<div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
    <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
    <?php /** added in the qty of 0 as a hidden field */ ?>
    <input type="hidden" name="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]" 
            data-selector="super_group[<?= /* @escapeNotVerified */ $_item->getId() ?>]" value="0" 
            title="<?= /* @escapeNotVerified */ __('Qty') ?>"
            class="input-hidden qty"/>
</div>

Hopefully it'll help in some way, I'm sure it'll be fixed in 2.3.0 but this worked for me until then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.