Skip to content

minicart twice on same page#40871

Open
aasim110 wants to merge 5 commits into
magento:2.4-developfrom
aasim110:38958-minicart-twice-on-samepage
Open

minicart twice on same page#40871
aasim110 wants to merge 5 commits into
magento:2.4-developfrom
aasim110:38958-minicart-twice-on-samepage

Conversation

@aasim110

@aasim110 aasim110 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description (*)

app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml:

Added support for dynamic data_block_name and scope parameters via block arguments (defaulting to 'minicart' and 'minicart_content').
Scoped the dropdown Dialog target to "[data-block=...] .showcart" and "[data-block=...]" to prevent selectors and click event handlers from colliding.

app/code/Magento/Checkout/Block/Cart/Sidebar.php:

Overrode getJsLayout() to detect and dynamically copy the configured product type renderers (itemRenderer mapping and child components) from the main minicart block to any secondary minicarts on the page

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js:

Refactored component to eliminate module-level state variables (sidebarInitialized, addToCartCalls, miniCart).
Introduced configurable minicartSelector property defaulting to '[data-block="minicart"]'.
Converted initSidebar to a component method that checks the initialization status dynamically on each element via .data('mageSidebar').
Setup element-specific event listeners in initialize utilizing the configured selector.

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js:

Changed target elements (such as updateButton, qtyInput, close/checkout button targets) to be queried relative to the event sender or container rather than using global ID/class selectors.
Preserved fallback compatibility with global selectors for cases where custom templates do not position buttons as immediate siblings of inputs.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Minicart cannot be used twice in the same page #38958

Manual testing scenarios (*)

  1. add mini cart header (default)
  2. add mini cart block in footer

@m2-assistant

m2-assistant Bot commented Jun 10, 2026

Copy link
Copy Markdown

Hi @aasim110. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@aasim110 aasim110 force-pushed the 38958-minicart-twice-on-samepage branch from 8bbb544 to 1f122eb Compare June 10, 2026 11:49
@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@aasim110 aasim110 force-pushed the 38958-minicart-twice-on-samepage branch from 26c6247 to 77d4c2a Compare June 10, 2026 23:58
@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@aasim110

Copy link
Copy Markdown
Contributor Author

@engcom-Bravo Kindly review this PR as all tests are completed and functional tests fails are not related to this PR

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Minicart cannot be used twice in the same page

2 participants