1

By default, when you go to the Cart, You see all the products you purchased on the left hand column and also all the products are linked to their individual product page.

I'd like to remove that link as some of the products in our store are not supposed to link out to their individual product pages. Been trying to locate that in my theme and store, but on luck. Any idea what file I can locate it to disable the link?

0

If you want to remove product link form product name on cart page, you need to copy:

Magento2Root/vendor/magento/module-checkout/view/frontend/templates/cart/item/default.phtml

to

app/design/frontend/{Package}/{theme}/Magento_Checkout/templates/cart/item/default.phtml

You can find product-item-name which has product URL, you can remove/edit from here.

<strong class="product-item-name">
    <?php if ($block->hasProductUrl()):?>
        <a href="<?= /* @escapeNotVerified */ $block->getProductUrl() ?>"><?= $block->escapeHtml($block->getProductName()) ?></a>
    <?php else: ?>
        <?= $block->escapeHtml($block->getProductName()) ?>
    <?php endif; ?>
</strong>

Update I

If you also want to remove link from minicart, You need to copy:

Magento2Root/vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html

to

app/design/frontend/{Package}/{theme}/Magento_Checkout/web/template/minicart/item/default.html

You can remove link form below code:

<a data-bind="attr: {href: product_url}, html: product_name"></a> 
  • Thanks! It worked! What about the mini-cart? Where would I locate that code? – Adam Bell Apr 21 at 3:19
  • welcome@AdamBell, Please see my updates in answer. – Pawan Apr 21 at 4:02
  • That’s what I thought it was. Since the a href was using a data-bind, I changed it to a span, removed the reference to href: product_url and resaved it and uploaded it from my child theme. Problem is I’m not seeing the change on the site even after flushing Magento cache. – Adam Bell Apr 21 at 14:07
  • @AdamBell, you also need to remove pub/static/frontend folder to see changes. – Pawan Apr 22 at 2:57
  • Tried that. Cleared Static Cache in Terminal as well. No luck. Never took the file change, so it's still showing the original a instead of the new span. – Adam Bell Apr 22 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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