shopify创建配送日期代码片段步骤-ESG跨境

shopify创建配送日期代码片段步骤

shopify新闻
shopify新闻
2022-03-28
点赞icon 0
查看icon 866

若要为配送日期选择器创建代码片段,请执行以下操作:

创建日期代码片段

若要为配送日期选择器创建代码片段,请执行以下操作:

PC:

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

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

  1. 在 Snippets 目录中,点击添加新代码片段

  2. 创建代码片段:

    1. 将代码片段命名为 delivery-date

    2. 点击创建代码片段。新的代码片段文件将在代码编辑器中打开。

苹果系统:

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

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

  1. 在 Snippets 目录中,点击添加新代码片段

  2. 创建代码片段:

    1. 将代码片段命名为 delivery-date

    2. 点击创建代码片段。新的代码片段文件将在代码编辑器中打开。

安卓系统:

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

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

  1. 在 Snippets 目录中,点击添加新代码片段

  2. 创建代码片段:

    1. 将代码片段命名为 delivery-date

    2. 点击创建代码片段。新的代码片段文件将在代码编辑器中打开。

  1. 在新的 delivery-date.liquid 代码片段中,粘贴以下代码:

```html {{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}

<div >   <p>     <label fo>Pick a delivery date:</label>     <input  type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />     <span > We do not deliver during the week-end.</span>   </p> </div> <script>   window.onload = function() {       if (window.jQuery) {         let $ = window.jQuery;         $(function() {           $("#date").datepicker({           minDate: +1,           maxDate: '+2M',           beforeShowDay: $.datepicker.noWeekends         });       });     }   } </script>
1. 点击**保存**。 ## 在购物车页面中包含代码片段 若要在购物车页面中包含配送日期代码片段,请执行以下操作: 1. 在 **Sections** 目录中,点击 `cart-template.liquid`。如果您的模板中没有此文件,则点击 **Templates** 目录中的 `cart.liquid`。 2. [查找](/manual/shopify-admin/productivity-tools/keyboard-shortcuts#find)代码中的结束 `</form>` 标记。在结束 `</form>` 标记上方的新行中,粘贴以下代码: ```liquid {% render 'delivery-date' %}
  1. 点击保存

您的购物车页面中现在将有一个配送日期输入字段。当您点击文本字段时,将出现日历:

此自定义设置中使用的日期选择器是 jQuery UI 库中的小组件。此博客文章介绍如何在日期选择器日历中禁用特定日期。

Create a delivery date snippet

To create a snippet for your delivery date picker:

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 Snippets directory, click Add a new snippet:

  2. Create the snippet:

    1. Name your snippet delivery-date.

    2. Click Create snippet. The new snippet file will open in the editor.

iPhone:

  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 Snippets directory, click Add a new snippet:

  2. Create the snippet:

    1. Name your snippet delivery-date.

    2. Click Create snippet. The new snippet file will open in the code editor.

Android:

  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 Snippets directory, click Add a new snippet:

  2. Create the snippet:

    1. Name your snippet delivery-date.

    2. Click Create snippet. The new snippet file will open in the code editor.

  1. In your new delivery-date.liquid snippet, paste the following code:

    {{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }} <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" defe></script> <div >   <p>     <label fo>Pick a delivery date:</label>     <input  type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />     <span  > We do not deliver during the week-end.</span>   </p> </div> <script>   window.onload = function() {       if (window.jQuery) {         let $ = window.jQuery;         $(function() {           $("#date").datepicker({           minDate: +1,           maxDate: '+2M',           beforeShowDay: $.datepicker.noWeekends         });       });     }   } </script>
  2. Click Save.

Include the snippet in your cart page

To include the delivery date snippet in your cart page:

  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 closing </form> tag in the code. On a new line above the closing </form> tag, paste the following code:

    {% render 'delivery-date' %}
  3. Click Save.

You now have a delivery date input field on your cart page. When you click inside the text field, a calendar will appear:

The date picker used in this customization is a widget from the jQuery UI library. This blog post explains how to disable specific dates in the date picker calendar.



特别声明:以上文章内容仅代表作者本人观点,不代表ESG跨境电商观点或立场。如有关于作品内容、版权或其它问题请于作品发表后的30日内与ESG跨境电商联系。

搜索 放大镜
韩国平台交流群
加入
韩国平台交流群
扫码进群
欧洲多平台交流群
加入
欧洲多平台交流群
扫码进群
美国卖家交流群
加入
美国卖家交流群
扫码进群
ESG跨境专属福利分享群
加入
ESG跨境专属福利分享群
扫码进群
拉美电商交流群
加入
拉美电商交流群
扫码进群
亚马逊跨境增长交流群
加入
亚马逊跨境增长交流群
扫码进群
《开店大全-全球合集》
《开店大全-主流平台篇》
《开店大全-东南亚篇》
《CD平台自注册指南》
《开店大全-俄罗斯篇》
《韩国站内推广指南》
《韩国热销品预测》
《开店大全-日韩篇》
《开店大全-拉美篇》
《开店大全-欧洲篇》
通过ESG入驻平台,您将解锁
绿色通道,更高的入驻成功率
专业1v1客户经理服务
运营实操指导
运营提效资源福利
平台官方专属优惠
联系顾问

平台顾问

平台顾问 平台顾问

微信扫一扫
马上联系在线顾问

icon icon

小程序

微信小程序

ESG跨境小程序
手机入驻更便捷

icon icon

返回顶部