Skip to content

Issue with configurable products in widgets, not added to cart #19315

Closed
@jcourtei

Description

@jcourtei

Preconditions (*)

Version 2.2.6 (Community Edition).

Steps to reproduce (*)

  1. Create a product attribute, for example Size with several values (S, M and L). This attribute must have property "use in product listing" set to Yes.
  2. Create a product that uses this attribute with a configuration setting. Define different quantities for each values. Set this product as new for the current month.
  3. Create a block with a widget for new products (choose the grid template) and add this block at any page.
  4. On this page click on Add to cart (from a computer, not smartphone) for this new product.

Expected result (*)

User should see the product page with the message "You need to choose options for your item."

Actual result (*)

User is redirected to the cart page and the product is not added to the cart.

I think the issue is in vendor/magento/module-catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml.
I replaced :
<?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
with :
<?php if (!$_item->getTypeInstance()->isPossibleBuyFromList($_item)): ?>
This way it is consistent with Magento\Catalog\Block\Product\AbstractProduct->getAddToCartUrl(), since this method uses isPossibleBuyFromList() to choose the url.

Several templates are concerned with this issue :

  • vendor/magento/module-catalog-widget/view/frontend/templates/product/widget/content/grid.phtml (for the widget "Catalog Products List")
  • vendor/magento/module-catalog/view/frontend/templates/product/widget/new/content/new_grid.phtml (for the widget "Catalog New Products List" with "New Products Grid Template")
  • vendor/magento/module-catalog/view/frontend/templates/product/widget/new/content/new_list.phtml (for the widget "Catalog New Products List" with "New Products List Template")
  • vendor/magento/module-catalog/view/frontend/templates/product/widget/new/column/new_default_list.phtml (for the widget "Catalog New Products List" with "New Products Images and Names Template")

Metadata

Metadata

Assignees

Labels

Component: CatalogComponent: CatalogWidgetFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions