條件運算子參考
為徽章建立目標規則時,可使用的所有條件欄位與運算子。
目標規則是由三個部分組成的一列:欄位、運算子和值。可用的運算子會依您選擇的欄位而不同:文字欄位提供 contains 和 starts with,數值欄位提供 is greater than,依此類推。
您可以在徽章編輯器的 Products 分頁中,選取 Products matching conditions 後建立這些規則。
欄位下拉選單分為數個區段。
| Field | 比對內容 |
|---|---|
| Product title | 商品名稱。 |
| Product type | Shopify 的商品類型欄位。 |
| Product vendor | 供應商名稱。 |
| Product price | 目前價格。 |
| Product compare price | 原價。 |
| Product sale price | 折扣後價格。 |
| Product option | 商品選項,例如尺寸或顏色。 |
| Product tag | 商品上的任何標籤。 |
| Product weight | 商品重量。 |
| Product created | 商品建立至今的天數。 |
| Product published | 商品發佈至今的天數。 |
| Product inventory | 庫存數量和庫存狀態。 |
| Product metafield | 商品中繼欄位的值。 |
| Field | 比對內容 |
|---|---|
| Product variants | 商品是否有款式。 |
| Variant inventory | 各個款式的庫存數量。 |
| Variant metafield | 款式中繼欄位的值。 |
商品系列條件
Section titled “商品系列條件”| Field | 比對內容 |
|---|---|
| Collections | 商品所屬的商品系列。 |
| Field | 比對內容 |
|---|---|
| Sami discount | 套用應用程式 Discounts 頁面中任一折扣的商品。 |
Sami discount 只有一個運算子(is equal to),其值為一個折扣。您可以用它讓徽章只在該折扣進行期間顯示,並透過 {sami_discount_*} 變數,在徽章文字中填入該折扣本身的數值。請參閱動態變數參考。
商品評價條件
Section titled “商品評價條件”| Field | 比對內容 |
|---|---|
| Product review app | 評分或評價數量在您的評價應用程式中達到所設門檻的商品。 |
Product review app 只有一個運算子(is equal to),其值為一個評價應用程式:Judge.me、Loox、Junip、CWILL(Trustoo)、LAI Product Reviews 或 AG Product Reviews。決定是否符合條件的比較方式,由下方說明的各自欄位來設定。
一個徽章只能有一個評價應用程式條件;一旦使用,其他列中的這個選項就會呈現灰色。請參閱顯示來自評價應用程式的徽章。
依欄位類型區分的運算子
Section titled “依欄位類型區分的運算子”商品標題、類型、供應商、選項、標籤。
| Operator | 意義 |
|---|---|
| is equal to | 與您輸入的值完全相符。 |
| is not equal to | 與該值不符。 |
| starts with | 以您輸入的文字開頭。 |
| ends with | 以您輸入的文字結尾。 |
| contains | 在任何位置包含您輸入的文字。 |
| does not contain | 不包含該文字。 |
商品價格、原價、折扣價、重量。
| Operator | 意義 |
|---|---|
| is equal to | 與您輸入的數字完全相同。 |
| is not equal to | 除您輸入的數字以外的任何數字。 |
| is greater than | 高於您輸入的數字。 |
| is less than | 低於您輸入的數字。 |
| Operator | 意義 |
|---|---|
| in stock | 商品目前有庫存。 |
| out of stock | 庫存已降為零。 |
| continue selling when out of stock | 商品設定為庫存為零後仍繼續銷售。 |
| stock availability is greater than | 庫存高於您輸入的門檻。 |
| stock availability is less than | 庫存低於您輸入的門檻。 |
前三個運算子不需要輸入值,運算子本身就是條件。
Product created、Product published。其值是從今天往回算的 day(s) 天數,而不是日曆日期。
| Operator | 意義 |
|---|---|
| is less than | 建立或發佈至今少於 N 天,適用於「新品」徽章。 |
| is greater than | 建立或發佈至今超過 N 天。 |
| is in range | 落在兩個天數之間。 |
| Operator | 意義 |
|---|---|
| is equal to / is not equal to | 與指定的款式數量比較。 |
| products with variants | 商品有多個款式。 |
| product has no variants | 商品只有單一的預設款式。 |
商品評價指標
Section titled “商品評價指標”Product review app 有自己的一組欄位,選擇應用程式後會顯示在條件清單下方。
| Field | 選項 |
|---|---|
| Review condition | Number of reviews:商品的評價數量。Product rating:平均星等評分。 |
| Operator | is equal to、is greater than、is less than。 |
| Enter value | Product rating 可輸入 0 至 5,間隔為 0.1;Number of reviews 可輸入整數。此欄位為必填,留空將無法儲存。 |
使用 Add conditions 新增所需的列數,然後透過上方的 Products must match 選項按鈕決定這些條件的合併方式:
all conditions (AND)
Section titled “all conditions (AND)”每一列都必須成立。縮小比對範圍。
範例: Product type is equal to “T-Shirt” 且 Product vendor is equal to “Nike” → 僅限 Nike T 恤。
any condition (OR)
Section titled “any condition (OR)”符合任一列即可。擴大比對範圍。
範例: Product tag is equal to “new-arrival” 或 Product tag is equal to “featured” → 具有任一標籤的商品。
- 依屬性指定商品:逐步設定屬性條件。
- 指定特定商品:改為手動挑選個別商品。
- 顯示來自評價應用程式的徽章:評價條件及其變數的完整說明。
- 方案比較:查看您的方案包含哪些條件。