JavaScript API - 網路商店
AI 概覽
說明 Globo Preorder 在您的佈景主題中提供的 JavaScript API,以及如何為自訂或更新後的佈景主題重新定義其選擇器。
- 應用程式在您的佈景主題中載入後,即可透過
window.Globo.Preorder使用此 API。 - 變更款式後,呼叫
Globo.Preorder.initPreorder()即可重新載入商品頁面上的預購表單。 - 在
theme.liquid的</body>之前加入指令碼,並使用window.GloboPreorderParams.selectors覆寫選擇器。 - 表格列出每個選擇器鍵值、其類型、適用的頁面(購物車、商品、商品系列、快速檢視)以及指向的目標。
摘要由 AI 產生,可能有誤,請以下方完整指南為準。
Globo Preorder 提供 JavaScript API,可在您的 Shopify 佈景主題中進行自訂整合。當我們的應用程式載入到您的佈景主題時,即可透過 window.Globo.Preorder 物件存取此 API。
1. 全域變數
window.Globo.Preorder// Use it with function app, after app loaded or window loaded// Example reload preorder form in product page after variant change// Use: Globo.Preorder.initPreorder();window.GloboPreorderParams// Defined selectors, classes, postion display2. 定義選擇器 - 整合佈景主題
根據預設,應用程式會定義選擇器,以便在正確的位置正確顯示;不過,佈景主題可能有更新版本,或有應用程式尚未支援的自訂佈景主題。您可以使用變數 window.GloboPreorderParams 重新定義選擇器。
- 前往
theme.liquid,在</body>之前新增 Javascript 程式碼 - 在商品頁面覆寫選擇器
productAddToCartTextElement的範例
<script>window.GloboPreorderParams = window.GloboPreorderParams || {};window.GloboPreorderParams.selectors = window.GloboPreorderParams.selectors || {};window.GloboPreorderParams.selectors.productAddToCartTextElement = 'span[data-add-to-cart-text], .add-to-cart-text'; // class of the text element added to cart on product page</script>3 鍵值清單
window.GloboPreorderParams.selectors
| 鍵值 | 類型 | 頁面 | 定義 |
|---|---|---|---|
cartFormSelector | string | 購物車 | 購物車容器 |
cartRowSelector | string | 購物車 | 購物車品項列 |
cartElementHandle | string | 購物車 | 商品 handle 元素,必須位於 cartRowSelector 元素內。 |
cartQuantitySelector | string | 購物車 | 商品數量容器,必須位於 cartRowSelector 元素內 |
cartInputQuantitySelector | string | 購物車 | 商品數量輸入欄位 |
cartPositionLimitMessage | string | 購物車 | 顯示商品限購訊息的位置 |
cartProductParentSelector | string | 購物車 | 用於在購物車頁面顯示品項徽章。 |
cartProductTitleSelector | string | 購物車 | 用於在購物車頁面顯示品項徽章。 |
minusQuantitySelector | string | 商品 | 當輸入的數量達到上限時,停用數量減少按鈕的點擊 |
addQuantitySelector | string | 商品 | 當輸入的數量達到上限時,停用數量增加按鈕的點擊 |
productDetailSelector | string | 商品 | 商品詳情容器 |
productDetailImagesSelector | string | 商品 | 商品詳情圖片選擇器 |
productImageSelectors | array | product collection | 商品圖片選擇器 |
pricePositionSelectors | string | 商品 | 顯示預購標籤的商品價格位置 |
priceSelectors | string | 商品 | 商品價格外層容器 |
productForm | array | 商品 | 商品加入購物車的表單動作 |
paymentButton | string | 商品 | 付款按鈕選擇器 |
productVariantActivator | string | 商品 | 商品子類選擇器,新增 click、change 事件監聽器並重新渲染預購狀態 |
variantSelector | string | 商品 | 商品子類 ID 選擇器 [name="id"] |
productQuantityWrapperSelector | string | 商品 | 商品數量外層容器,用於顯示限購訊息 |
productQuantitySelector | string | 商品 | 數量輸入欄位選擇器 |
productAddToCartSelector | string | 商品 | 加入購物車按鈕選擇器, |
productAddToCartBtn | array | 商品、快速檢視 | 加入購物車按鈕 |
productAddToCartTextElement | string | 商品、快速檢視 | 加入購物車文字 |
spinnerAtcElement | string | 商品 | 隱藏商品加入購物車中的載入動畫選擇器 |
productSoldOutBadge | string | 商品 | 當商品顯示預購時,隱藏已售完徽章的選擇器 |
productPositionMessage | string | 商品 | 在文字上方顯示訊息的位置 |
productPositionLimitMessage | string | 商品 | 顯示數量限制警告訊息的位置 |
productPositionPaymentOption | string | 商品 | 顯示付款選項的位置 |
productPositionBis | string | 商品 | 顯示到貨通知按鈕的位置 |
這個頁面有幫助嗎?
感謝您的意見回饋! 告訴我們缺少了什麼
回報問題