You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Magento修改默认页面头部链接问题

How to Replace "My Cart" Text with a Font Awesome Icon in Magento

Hey there! I totally get how overwhelming Magento's file structure can feel when you're just starting out—official docs often skip over the "beginner-friendly" details, which is super frustrating. Let's break this fix down into simple, actionable steps:

Step 1: Confirm Your Active Theme

First, you need to know exactly which theme your store is using (never edit core files directly—we'll use theme inheritance to keep changes safe during upgrades):

  • Log into your Magento admin panel
  • Navigate to Content > Design > Configuration
  • Find your store view in the list, click Edit
  • Under the Theme section, note the vendor and theme name (e.g., Magento/luma or your custom theme like MyBrand/mycustomtheme)

Step 2: Locate the Minicart Template File

The "My Cart" text lives in the minicart template, part of the Magento_Checkout module. Here's how to find/access it properly:

  • Go to your theme's directory: app/design/frontend/[Vendor]/[Theme]/Magento_Checkout/templates/cart/
    • If this path doesn't exist, create the missing folders manually
  • If minicart.phtml isn't in this folder, copy the file from vendor/magento/module-checkout/view/frontend/templates/cart/minicart.phtml into your theme's cart folder (this preserves core files while letting you customize)

Step 3: Swap the Text for the Font Awesome Icon

Open minicart.phtml in your code editor and search for the line that outputs "My Cart". It will look like this:

<?= __('My Cart') ?>

Replace that line entirely with your Font Awesome icon code:

<i class="fas fa-shopping-cart"></i>

Optional: If you want to keep the text alongside the icon, use this instead:

<i class="fas fa-shopping-cart"></i> <?= __('My Cart') ?>

Step 4: Ensure Font Awesome is Loaded

If your theme doesn't already include Font Awesome, you'll need to add it to make the icon display:

  • Download the Font Awesome CSS files and place them in your theme's web/css directory
  • Open your theme's Magento_Theme/templates/html/head.phtml (create it if it doesn't exist) and add this line to load the CSS:
    <link rel="stylesheet" href="<?= $block->getViewFileUrl('css/fontawesome.min.css') ?>">
    

Step 5: Flush Magento Cache

Magento caches template files aggressively, so this step is non-negotiable:

  • Go back to the admin panel and navigate to System > Cache Management
  • Select all cache types, choose Flush Magento Cache from the dropdown, then click Submit

That's all! Refresh your storefront and you should see the shopping cart icon in place of the "My Cart" text.

内容的提问来源于stack exchange,提问作者Black

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:10:24