购物车页面添加“继续购物”链接



您可以将继续购物链接添加到购物车页面,使客户在将产品添加到购物车后可轻松返回浏览产品。您可以选择添加一个链接,用于将客户定向回目录页面、您的主页或他们之前查看的最后一个产品系列页面。

向购物车页面添加“继续购物”链接

若要向您的购物车页面添加继续购物链接,请执行以下操作:

PC:

  1. 在 Shopify 后台中,转到在线商店 > 模板

  2. 找到要编辑的模板,然后点击操作 > 编辑代码

  1. 在 Sections 目录中,点击 cart-template.liquid。如果您的模板中没有此文件,则点击 Templates 目录中的 cart.liquid

  2. 通过搜索 name="checkout" 的文件来查找结账按钮的代码。结账按钮的代码行因模板而异,但会如下所示:

<button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  1. 下一步是粘贴新的代码行以创建继续购物链接。您粘贴的代码将取决于您希望链接转到的页面:

苹果系统:

  1. 在 Shopify 应用中,轻触商店

  2. 销售渠道部分中,轻触在线商店

  3. 轻触 Manage themes(管理模板)。

  4. 找到要编辑的模板,然后点击操作 > 编辑代码

  1. 在 Sections 目录中,点击 cart-template.liquid。如果您的模板中没有此文件,则点击 Templates 目录中的 cart.liquid

  2. 通过搜索 name="checkout" 的文件来查找结账按钮的代码。结账按钮的代码行因模板而异,但会如下所示:

<button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  1. 下一步是粘贴新的代码行以创建继续购物链接。您粘贴的代码将取决于您希望链接转到的页面:

安卓系统:

  1. 在 Shopify 应用中,轻触商店

  2. 销售渠道部分中,轻触在线商店

  3. 轻触 Manage themes(管理模板)。

  4. 找到要编辑的模板,然后点击操作 > 编辑代码

  1. 在 Sections 目录中,点击 cart-template.liquid。如果您的模板中没有此文件,则点击 Templates 目录中的 cart.liquid

  2. 通过搜索 name="checkout" 的文件来查找结账按钮的代码。结账按钮的代码行因模板而异,但会如下所示:

<button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  1. 下一步是粘贴新的代码行以创建继续购物链接。您粘贴的代码将取决于您希望链接转到的页面:

对于指向目录页面的链接

若要添加指向目录页面的链接,请将下方代码粘贴到结账按钮对应代码之前或之后的新行中:

<a href="/collections/all" title="Continue shopping">Continue shopping</a>

对于指向主页的链接

若要添加指向您的主页的链接,请将下方代码粘贴到结账按钮对应代码之前或之后的新行中:

<a href="/" title="Continue shopping">Continue shopping</a>

对于指向上一个查看的产品系列的链接

若要添加指向上一个查看的产品系列的链接,请将下方代码粘贴到结账按钮对应代码之前或之后的新行中:

<a   id="continue-shopping"   href=""   title="Continue shopping">   Continue shopping </a>
  1. 点击保存。如果您添加了指向目录页面或主页的链接,则操作已完成。如果您添加了指向上一个查看的产品系列的链接,则需要向您的模板代码中添加一些 JavaScript。然后继续按照后续步骤操作。

  2. 在 Layout 目录中,点击 theme.liquid

  3. 在文件底部附近查找结束 </body> 标记。将以下代码粘贴到结束 </body> 标记上方:

<script>   if(Storage !== undefined) {     var defaultLink = "/collections/all";     {% if template contains 'collection' %}       sessionStorage.collection = "{{ collection.url }}";     {% endif %}     {% if template contains 'cart' %}       if( !sessionStorage.collection ) {         sessionStorage.collection = defaultLink;       }       document.getElementById("continue-shopping").href = sessionStorage.collection;     {% endif %}     } </script>
  1. 点击保存

添加按钮样式(可选)

如果您使用免费的 Shopify 模板,则可以将样式应用于继续购物链接,使它呈现按钮的外观。通过向按钮链接的代码中添加类属性,您可以使您的按钮与模板中其他按钮的样式匹配。所有免费 Shopify 模板都对主按钮样式使用相同的类名称,并且大多数此类模板对辅助按钮样式使用相同的类名称。

若要向“继续购物”链接应用主要按钮样式,请执行以下操作:

将属性 class="btn" 添加到您已粘贴的代码行中,以便添加继续购物链接。您的代码应如下所示:

<a href="/collections/all" title="Continue shopping" class="btn">   Continue shopping </a>

若要向“继续购物”链接应用辅助按钮样式,请执行以下操作:

备注:添加此类对 Boundless 没有影响。

如果您使用的是 Supply 以外的免费模板,请将属性 class="btn--secondary" 添加到您已粘贴的代码行中,以便添加继续购物链接。您的代码应如下所示:

<a href="/collections/all" title="Continue shopping" class="btn--secondary">   Continue shopping </a>

如果您使用 Supply,请将属性 class="btn-secondary" 添加到您已粘贴的代码行,以便添加继续购物链接。您的代码应如下所示:

<a href="/collections/all" title="Continue shopping" class="btn-secondary">   Continue shopping </a>

Shopify商户官网原文详情:

Add a continue shopping link to your cart



You can add a Continue shopping link to your cart page that allows customers to easily return to browsing products after adding something to the cart. You can choose to add a link that will take customers back to your catalog page, back to your home page, or back to the last collection page that they were looking at.

Add a Continue shopping link to your cart page

To add a Continue shopping link to your cart page:

PC:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.

  2. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:

    <button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  3. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to:

    For a link that goes to your catalog page

    To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the Checkout button:

    <a href="/collections/all" title="Continue shopping">Continue shopping</a>

iPhone:

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.

  2. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:

    <button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  3. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to:

    For a link that goes to your catalog page

    To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the Checkout button:

    <a href="/collections/all" title="Continue shopping">Continue shopping</a>

Android:

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Sections directory, click cart-template.liquid. If your theme doesn't have this file, then click cart.liquid in the Templates directory.

  2. Find the code for the Checkout button by searching the file for name="checkout". The line of code for the checkout button varies theme to theme, but will look something like this:

    <button type="submit" id="checkout" name="checkout" class="btn">   {{ 'cart.general.checkout' | t }} </button>
  3. The next step is to paste a new line of code to create a Continue shopping link. The code that you paste will depend on which page you would like the link to go to:

    For a link that goes to your catalog page

    To add a link that goes to your catalog page, paste the following code on a new line either before or after the code for the Checkout button:

    <a href="/collections/all" title="Continue shopping">Continue shopping</a>
  1. For a link that goes to your home page

    To add a link that goes to your home page, paste the following code on a new line either before or after the code for the Checkout button:

    <a href="/" title="Continue shopping">Continue shopping</a>

    For a link that goes to the last collection viewed

    To add a link that goes to the last collection viewed, paste the following code on a new line either before or after the code for the Checkout button:

    <a   id="continue-shopping"   href=""   title="Continue shopping">   Continue shopping </a>
  2. Click Save. If you added a link that goes to either your catalog page or your home page, then you are done. If you added a link that goes to the last collection viewed, then you will need to add some JavaScript to your theme code. Continue to follow the next steps.

  3. In the Layout directory, click theme.liquid.

  4. Find the closing </body> tag, near the bottom of the file. Paste the following code above the closing </body> tag:

    <script>   if(Storage !== undefined) {     var defaultLink = "/collections/all";     {% if template contains 'collection' %}       sessionStorage.collection = "{{ collection.url }}";     {% endif %}     {% if template contains 'cart' %}       if( !sessionStorage.collection ) {         sessionStorage.collection = defaultLink;       }       document.getElementById("continue-shopping").href = sessionStorage.collection;     {% endif %}     } </script>
  5. Click Save.

Add button styling (optional)

If you use a free Shopify theme, then you can apply styling to your Continue shopping link to make it look like a button. By adding a class attribute to the code for your button link, you can make your button match the style of the other buttons in your theme. All free Shopify themes use the same class name for primary button styles, and most use the same class name for secondary button styles.

To apply primary button styling to your Continue shopping link:

Add the attribute class="btn" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn">   Continue shopping </a>

To apply secondary button styling to your Continue shopping link:



If you use a free theme that is not Supply, then add the attribute class="btn--secondary" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn--secondary">   Continue shopping </a>

If you use Supply, then add the attribute class="btn-secondary" to the line of code that you pasted to add a Continue shopping link. Your code should look like this:

<a href="/collections/all" title="Continue shopping" class="btn-secondary">   Continue shopping </a>

文章内容来源:Shopify商户官方网站


(本文内容根据网络资料整理,出于传递更多信息之目的,不代表连连国际赞同其观点和立场)