Question

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?

Was it helpful?

Solution

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> 
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top