Skip to content

[Forwardport] Prevent multiple add-to-cart initializations in case of ajax loaded product listing#13

Merged
vijay-wagento merged 1 commit into2.3-developfrom
2.3-develop-PR-port-15409
Jun 4, 2018
Merged

[Forwardport] Prevent multiple add-to-cart initializations in case of ajax loaded product listing#13
vijay-wagento merged 1 commit into2.3-developfrom
2.3-develop-PR-port-15409

Conversation

@vijay-wagento
Copy link
Copy Markdown
Owner

Original Pull Request

magento#15409

Description

catalogAddToCart widget initialize its functions for all suitable elements:

This commit fixes this by additional catalog-addtocart-initialized flag.

Manual testing scenarios

  1. Navigate to the category with products.

  2. Open developer console and execute the following script:

    jQuery('footer').append('<script type="text/x-magento-init">{"[data-role=tocart-form], .form.map.checkout": {"catalogAddToCart": {}}}</script>');
    jQuery('footer').trigger('contentUpdated');

    This scenario is a simplified case that may happen when some third-party widget loads ajax products listing on the page using standard listing template.

  3. Open "Network" tab and press "Add to cart" on some product.

  4. Two requests will be sent instead of one.

Contribution 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)
  • All automated tests passed successfully (all builds on Travis CI are green)

@vijay-wagento vijay-wagento merged commit b3596cb into 2.3-develop Jun 4, 2018
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

Successfully merging this pull request may close these issues.

2 participants