shopify創(chuàng)建配送日期代碼片段步驟-ESG跨境

shopify創(chuàng)建配送日期代碼片段步驟

shopify新聞
shopify新聞
2022-03-28
點贊icon 0
查看icon 973

若要為配送日期選擇器創(chuàng)建代碼片段,請執(zhí)行以下操作:

創(chuàng)建日期代碼片段

若要為配送日期選擇器創(chuàng)建代碼片段,請執(zhí)行以下操作:

PC:

  1. 在 后臺中,轉(zhuǎn)到在線商店 > 模板

  2. 找到要編輯的模板,然后點擊操作 > 編輯代碼。

  1. 在 Snippets 目錄中,點擊添加新代碼片段。

  2. 創(chuàng)建代碼片段:

    1. 將代碼片段命名為 delivery-date

    2. 點擊創(chuàng)建代碼片段。新的代碼片段文件將在代碼編輯器中打開。

蘋果系統(tǒng):

  1. 在 Shopify 后臺中,轉(zhuǎn)到 > 模板

  2. 找到要編輯的模板,然后點擊操作 > 編輯代碼

  1. 在 Snippets 目錄中,點擊添加新代碼片段

  2. 創(chuàng)建代碼片段:

    1. 將代碼片段命名為 delivery-date。

    2. 點擊創(chuàng)建代碼片段。新的代碼片段文件將在代碼編輯器中打開。

安卓系統(tǒng):

  1. 在 Shopify 后臺中,轉(zhuǎn)到在線商店 > 模板。

  2. 找到要編輯的模板,然后點擊操作 > 編輯代碼。

  1. 在 Snippets 目錄中,點擊添加新代碼片段。

  2. 創(chuàng)建代碼片段:

    1. 將代碼片段命名為 delivery-date。

    2. 點擊創(chuàng)建代碼片段。新的代碼片段文件將在代碼編輯器中打開。

  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. 點擊**保存**。 ## 在購物車頁面中包含代碼片段 若要在購物車頁面中包含配送日期代碼片段,請執(zhí)行以下操作: 1. 在 **Sections** 目錄中,點擊 `cart-template.liquid`。如果您的模板中沒有此文件,則點擊 **Templates** 目錄中的 `cart.liquid`。 2. [查找](/manual/shopify-admin/productivity-tools/keyboard-shortcuts#find)代碼中的結(jié)束 `</form>` 標記。在結(jié)束 `</form>` 標記上方的新行中,粘貼以下代碼: ```liquid {% render 'delivery-date' %}
  1. 點擊保存。

您的購物車頁面中現(xiàn)在將有一個配送日期輸入字段。當您點擊文本字段時,將出現(xiàn)日歷:

此自定義設(shè)置中使用的日期選擇器是 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.



特別聲明:以上文章內(nèi)容僅代表作者本人觀點,不代表ESG跨境電商觀點或立場。如有關(guān)于作品內(nèi)容、版權(quán)或其它問題請于作品發(fā)表后的30日內(nèi)與ESG跨境電商聯(lián)系。

搜索 放大鏡
韓國平臺交流群
加入
韓國平臺交流群
掃碼進群
歐洲多平臺交流群
加入
歐洲多平臺交流群
掃碼進群
美國賣家交流群
加入
美國賣家交流群
掃碼進群
ESG跨境專屬福利分享群
加入
ESG跨境專屬福利分享群
掃碼進群
拉美電商交流群
加入
拉美電商交流群
掃碼進群
亞馬遜跨境增長交流群
加入
亞馬遜跨境增長交流群
掃碼進群
亞馬遜跨境增長交流群
加入
亞馬遜跨境增長交流群
掃碼進群
拉美電商交流群
加入
拉美電商交流群
掃碼進群
ESG獨家招商-PHH GROUP賣家交流群
加入
ESG獨家招商-PHH GROUP賣家交流群
掃碼進群
《TikTok官方運營干貨合集》
《TikTok綜合運營手冊》
《TikTok短視頻運營手冊》
《TikTok直播運營手冊》
《TikTok全球趨勢報告》
《韓國節(jié)日營銷指南》
《開店大全-全球合集》
《開店大全-主流平臺篇》
《開店大全-東南亞篇》
《CD平臺自注冊指南》
通過ESG入駐平臺,您將解鎖
綠色通道,更高的入駐成功率
專業(yè)1v1客戶經(jīng)理服務(wù)
運營實操指導(dǎo)
運營提效資源福利
平臺官方專屬優(yōu)惠

立即登記,定期獲得更多資訊

訂閱
聯(lián)系顧問

平臺顧問

平臺顧問 平臺顧問

微信掃一掃
馬上聯(lián)系在線顧問

icon icon

小程序

微信小程序

ESG跨境小程序
手機入駐更便捷

icon icon

返回頂部

【免費領(lǐng)取】全球跨境電商運營干貨 關(guān)閉
進行中
進行中
【活動報名】2024年歐洲多藍海平臺招商沙龍
官方親臨,拆解phh group/eMAG/worten三個平臺商機
立即報名
進行中
進行中
TikTok運營必備干貨包
包含8個TikTok最新運營指南(市場趨勢、運營手冊、節(jié)日攻略等),官方出品,專業(yè)全面!
免費領(lǐng)取
進行中
進行中
韓國電商節(jié)日營銷指南
10+韓國電商重要營銷節(jié)點詳細解讀;2024各節(jié)日熱度選品助力引爆訂單增長;8大節(jié)日營銷技巧輕松撬動大促流量密碼。
免費領(lǐng)取
進行中
進行中
全球平臺詳解——全球合集
涵括全球100+個電商平臺的核心信息,包括平臺精煉簡介、競爭優(yōu)勢、熱銷品類、入駐要求以及入駐須知等關(guān)鍵內(nèi)容。
立即領(lǐng)取
進行中
進行中
全球平臺詳解——主流平臺篇
火爆全球的跨境電商平臺合集,平臺優(yōu)勢、開店選品、入駐條件盡在掌握
立即領(lǐng)取
進行中
進行中
全球平臺詳解——拉美篇
涵蓋9大熱門拉美電商平臺,成熟的市場是跨境賣家的熱門選擇!
立即領(lǐng)取
進行中
進行中
全球平臺詳解——日韓篇
涵蓋10+日韓電商平臺,入駐條件一看就懂,優(yōu)勢熱銷品應(yīng)有盡有
立即領(lǐng)取
進行中
進行中
全球平臺詳解——歐洲篇
涵蓋20+歐洲電商平臺,詳細解讀優(yōu)勢、入駐條件、熱銷品等
立即領(lǐng)取