I can not redirect to the shopping cart link outside the iframe. It still redirect but it stays in the iframe. magento 2.2.6 when i click shopping cart enter image description here

result : enter image description here

I want it redirect to shopping cart but not in iframe. Can anyone help me ?

2 Answers 2


If you can manage the iframe content, you should change the link redirection and manage the parent location with it.

The way to do it is: window.top.location.href = "/your-url-link-redirect";

Check: https://stackoverflow.com/questions/580669/redirect-parent-window-from-an-iframe-action


I had a same issue while I was working. I checked and found that there is template file for displaying message for product is added successfully.

Message is:

You added PRODUCT_NAME to your shopping cart.

File: vendor/magento/module-checkout/view/frontend/templates/messages/addCartSuccessMessage.phtml

I have checked code it's as below:

<?= $block->escapeHtml(__(
    'You added %1 to your <a href="%2">shopping cart</a>.',
), ['a']);

I have copied that file into custom theme:


Changed code as below:

<?= $block->escapeHtml(__(
    'You added %1 to your <a href="%2" target="_top">shopping cart</a>.',
), ['a']);

After that I have checked that it's working as expected. Clicking on the shopping cart link, page redirects to cart page in the browser rather then in the iframe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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