[Issue] Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option #870
Description
This issue is automatically created based on existing pull request: #868: Fixes: Bundle product with only one product in required bundle option not being added to cart with bundle option
Description (*)
Adding a bundle product to the cart from the product carousel/widget doesn’t let the product be added properly with the bundle option. The bundle product options are not added within the parent product. It shows a warning message in minicart like ‘Please specify product option(s)’. It doesn’t fail in all the cases, it only fails in a certain case where a bundle product has been created with a required bundle option & the bundle option contains only one product with the ‘is_default’ checkbox selected.
Screenshot 1:
Here you can see in the screenshot a bundle product has been created with a bundle option containing only one product in it & the option is required and the product is default select.
Screenshot 2:
After creating a bundle product, a product carousel has been added to the home page content by using a page-builder that includes the particular bundle product.
Screenshot 3:
As we have created a product carousel, a bundle product is visible on the home page in the product slider.
Screenshot 4:
When we click on the add-to-cart button, the product seems to be added to the cart & it doesn’t throw any error. And then if you check in the mini-cart, you will see a warning message like “Please specify product option(s).”
Related Pull Requests
Manual testing scenarios (*)
- Create a bundle product that contains one or more bundle options & each bundle option is required and must contain only one product that is default selected. (see screenshot 1)
- Create a product carousel using page-builder content that includes the newly created bundle product in the widget. (see screenshot 2). Here I've added the product carousel in home page content
- From the front end visit the page & try to add the bundle product from the product slider.(see screenshot 3)
- After clicking Add to Cart observe a warning message in minicart. (see screenshot 4).
Expected result (*)
The bundle product should be added to the cart with bundle options.
Actual result (*)
The bundle product isn’t being added to the cart with bundle options.
Additional Information (*)
File: Magento/PageBuilder/view/frontend/templates/catalog/product/widget/content/carousel.phtml
In the given carousel.phtml
file it doesn’t get the options data where the add-to-cart form is rendered for the particular product (see screenshot 5). As the options are not rendered, adding that product to the cart will only add the parent bundle product to the cart without any bundle options.
Solution (*)
We have to update the given carousel.phtml
to get the bundle options in the add-to-cart form. We can get the bundle product options by using the Magento\Catalog\ViewModel\Product\OptionsData
ViewModel. (see screenshot 6)
A separate function has been created in the block file of the carousel.phtml
(Magento\CatalogWidget\Block\Product\ProductsList
) to get the ViewModel that returns the object of Magento\Catalog\ViewModel\Product\OptionsData
. Refer the mentioned related PR.
The same issue happens with the product grid as well in the product slider added by page builder. That can be solved by this PR:
Checklist
- Pull request has a meaningful description of its purpose
- All commits are accompanied by meaningful commit messages
- All new or changed code is covered with unit/integration tests (if applicable)
- README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- All automated tests passed successfully (all builds are green)
Metadata
Assignees
Type
Projects
Status
Pull Request In Progress