0

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

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

1

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>.',
    $block->getData('product_name'),
    $block->getData('cart_url')
), ['a']);

I have copied that file into custom theme:

app/design/frontend/VENDOR/THEME_NAME/Magento_Checkout/templates/messages/addCartSuccessMessage.phtml

Changed code as below:

<?= $block->escapeHtml(__(
    'You added %1 to your <a href="%2" target="_top">shopping cart</a>.',
    $block->getData('product_name'),
    $block->getData('cart_url')
), ['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.