@zohofinance/commerce 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/package.json +2 -2
- package/ts-dist/mocks/init-theme/.claude/CLAUDE.md +6 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/SKILL.md +242 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/figma.md +81 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/screenshot.md +54 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/inputs/url.md +88 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/spec-table.md +102 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/accessibility.md +110 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/performance.md +127 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/tokens.md +87 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-section-from-design.20260528/verification/visual-diff.md +123 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/SKILL.md +605 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/design-tokens.md +105 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/page-json-contract.md +58 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/qa-accessibility.md +35 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/reference-lookup.md +94 -0
- package/ts-dist/mocks/init-theme/.claude/skills/.archive/zcommerce-theme-builder.20260528/section-anatomy.md +109 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/SKILL.md +313 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/agent-hierarchy.md +142 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/ask-developer.md +113 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/bootstrap.md +260 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/build-metrics.md +89 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/code-quality.md +186 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/common-pages-agent.md +97 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/dev-server-and-urls.md +127 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/exemplars.md +79 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/figma-discovery.md +138 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/figma-extraction.md +132 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/image-sources.md +84 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/inputs/guidelines-frame.md +178 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/page-builder.md +322 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/page-orchestrator.md +199 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/parallel-fanout.md +152 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/a11y.mjs +129 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/lint-section.mjs +502 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/perf.mjs +134 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/pixel-diff.mjs +206 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/scripts/record-build-metrics.mjs +118 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/section-builder.md +131 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/subagent-escalation.md +75 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/transcription-rules.md +98 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/verification.md +227 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/visual-verify-loop.md +117 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/_index.md +4 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/assets.md +105 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/best-practices.md +212 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/custom-scripts.md +294 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/i18n.md +155 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/introduction.md +91 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/layouts.md +158 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/pages.md +156 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/_index.md +4 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/filters.md +419 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/global-objects.md +415 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/schema-types.md +926 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/reference/tags.md +259 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/sections.md +203 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/setup-guide.md +424 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/snippets.md +70 -0
- package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/theme-structure.md +252 -0
- package/ts-dist/mocks/init-theme/.cursor/PLAYBOOK.md +144 -0
- package/ts-dist/mocks/init-theme/.cursor/README.md +6 -0
- package/ts-dist/mocks/init-theme/.cursor/agents/figma-desktop-mobile-parallel.md +48 -0
- package/ts-dist/mocks/init-theme/.cursor/agents/visual-compare.md +221 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/add-field.md +83 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/add-theme-setting.md +200 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/assemble-page.md +72 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/audit-page.md +57 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/build-page-sections.md +110 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/build-section.md +418 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/build-theme.md +307 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/compare-section.md +358 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/create-theme.md +77 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/extract-tokens.md +43 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/fix-section.md +92 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/impact.md +50 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-a11y.md +66 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-i18n.md +110 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-layout.md +127 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-performance.md +72 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-section.md +84 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-sections.md +48 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/qa-theme.md +85 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/redesign-section.md +177 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/refactor-section.md +185 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/sync-theme-settings.md +132 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/validate-page.md +60 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/validate-section-group.md +88 -0
- package/ts-dist/mocks/init-theme/.cursor/commands/validate-theme-settings.md +119 -0
- package/ts-dist/mocks/init-theme/.cursor/examples/design-instructions-template.md +151 -0
- package/ts-dist/mocks/init-theme/.cursor/mcp.json +18 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/README.md +160 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/accessibility.mdc +24 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/add-field.mdc +222 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/add-theme-setting.mdc +39 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/assemble-page.mdc +130 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/audit-page.mdc +92 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/build-section.mdc +178 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/build-theme.mdc +47 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/compare-section.mdc +94 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/create-theme.mdc +78 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/css.mdc +137 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/design-spec-extraction.mdc +255 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/extract-tokens.mdc +43 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/figma-mcp-resolution.mdc +40 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/fix-section.mdc +154 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/general.mdc +30 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/i18n.mdc +85 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/javascript.mdc +85 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/liquid-no-hardcoded-strings.mdc +42 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/liquid.mdc +171 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/mobile-desktop-setting-meta.mdc +34 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/naming-convention.mdc +64 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/pages.mdc +120 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/performance.mdc +51 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/qa-section.mdc +134 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/redesign-section.mdc +147 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/schema-sync.mdc +110 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/schema.mdc +360 -0
- package/ts-dist/mocks/init-theme/.cursor/rules/share-urls.mdc +68 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/browser-verify.md +128 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/design-tokens.md +105 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/page-json-contract.md +87 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/qa-accessibility.md +35 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/reference-lookup.md +88 -0
- package/ts-dist/mocks/init-theme/.cursor/skills/section-anatomy.md +173 -0
package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/custom-scripts.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Custom Scripts"
|
|
3
|
+
weight: 14
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Custom Scripts
|
|
7
|
+
|
|
8
|
+
Zoho Commerce provides pre-built JavaScript libraries for common storefront functionality. These scripts are provided by Zoho Commerce and should be included in your theme to leverage built-in actions without boilerplate code.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Instead of implementing cart operations, product interactions, and analytics tracking from scratch, theme developers can include Zoho-provided scripts and use the exported functions directly.
|
|
13
|
+
|
|
14
|
+
## Available Scripts
|
|
15
|
+
|
|
16
|
+
### 1. Storefront Actions Script
|
|
17
|
+
|
|
18
|
+
The storefront actions script provides JavaScript functions for common e-commerce operations.
|
|
19
|
+
|
|
20
|
+
**CDN URL:**
|
|
21
|
+
```
|
|
22
|
+
https://cdn.example.com/storefront-actions/latest/storefront-actions.js
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Inclusion:**
|
|
26
|
+
```html
|
|
27
|
+
<script src="https://cdn.example.com/storefront-actions/latest/storefront-actions.js" defer></script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Exported Functions:**
|
|
31
|
+
|
|
32
|
+
#### addToCart(variantId, orgId, sectionName, quantity, productId)
|
|
33
|
+
|
|
34
|
+
Add a product variant to cart and get updated section rendering.
|
|
35
|
+
|
|
36
|
+
**Parameters:**
|
|
37
|
+
- `variantId`: The variant ID to add
|
|
38
|
+
- `orgId`: Organization ID
|
|
39
|
+
- `sectionName`: Section to re-render (e.g., "cart-summary")
|
|
40
|
+
- `quantity`: Number of items
|
|
41
|
+
- `productId`: Product ID (optional, for analytics)
|
|
42
|
+
|
|
43
|
+
**Returns:** JSON with rendered section HTML
|
|
44
|
+
|
|
45
|
+
**Example:**
|
|
46
|
+
```javascript
|
|
47
|
+
const result = await addToCart('var123', 'org456', 'cart-items', 1, 'prod789');
|
|
48
|
+
console.log(result.sections.cartItems); // Updated HTML
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### quickViewProduct(productId, sectionName, listId, listTitle)
|
|
52
|
+
|
|
53
|
+
Fetch and display quick view of a product.
|
|
54
|
+
|
|
55
|
+
**Parameters:**
|
|
56
|
+
- `productId`: ID of product to preview
|
|
57
|
+
- `sectionName`: Section to display (e.g., "product-quick-view")
|
|
58
|
+
- `listId`: List/collection ID (default: 'home-page')
|
|
59
|
+
- `listTitle`: List/collection title (default: 'Home Page')
|
|
60
|
+
|
|
61
|
+
**Returns:** JSON with rendered section HTML
|
|
62
|
+
|
|
63
|
+
**Example:**
|
|
64
|
+
```javascript
|
|
65
|
+
const result = await quickViewProduct('prod123', 'product-modal', 'featured', 'Featured Products');
|
|
66
|
+
document.getElementById('modal').innerHTML = result.sections.productModal;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### removeFromCart(variantId, sectionName, productId)
|
|
70
|
+
|
|
71
|
+
Remove a variant from cart and get updated sections.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `variantId`: Variant to remove
|
|
75
|
+
- `sectionName`: Section to re-render
|
|
76
|
+
- `productId`: Product ID (optional, for analytics)
|
|
77
|
+
|
|
78
|
+
**Returns:** JSON with updated section HTML
|
|
79
|
+
|
|
80
|
+
**Example:**
|
|
81
|
+
```javascript
|
|
82
|
+
await removeFromCart('var123', 'cart-items', 'prod789');
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### updateCartQuantity(variantId, quantity, sectionName, productId)
|
|
86
|
+
|
|
87
|
+
Update cart item quantity.
|
|
88
|
+
|
|
89
|
+
**Parameters:**
|
|
90
|
+
- `variantId`: Variant ID
|
|
91
|
+
- `quantity`: New quantity (0 to remove)
|
|
92
|
+
- `sectionName`: Section to re-render
|
|
93
|
+
- `productId`: Product ID (optional)
|
|
94
|
+
|
|
95
|
+
**Returns:** JSON with updated section HTML
|
|
96
|
+
|
|
97
|
+
**Example:**
|
|
98
|
+
```javascript
|
|
99
|
+
await updateCartQuantity('var123', 3, 'cart-items', 'prod789');
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### postCheckoutAddress(body)
|
|
103
|
+
|
|
104
|
+
Submit shipping/billing address during checkout.
|
|
105
|
+
|
|
106
|
+
**Parameters:**
|
|
107
|
+
- `body`: Object containing:
|
|
108
|
+
- `shipping_address`: Address object or ID
|
|
109
|
+
- `billing_address`: Address object or ID
|
|
110
|
+
- `is_consent_agreed`: Boolean
|
|
111
|
+
|
|
112
|
+
**Returns:** JSON with response or error
|
|
113
|
+
|
|
114
|
+
#### postShippingMethod(shippingMethodId)
|
|
115
|
+
|
|
116
|
+
Select shipping method during checkout.
|
|
117
|
+
|
|
118
|
+
**Parameters:**
|
|
119
|
+
- `shippingMethodId`: ID of selected shipping method
|
|
120
|
+
|
|
121
|
+
**Returns:** JSON response
|
|
122
|
+
|
|
123
|
+
#### postPaymentMethod(paymentMethodId, body)
|
|
124
|
+
|
|
125
|
+
Submit payment method during checkout.
|
|
126
|
+
|
|
127
|
+
**Parameters:**
|
|
128
|
+
- `paymentMethodId`: ID of payment method
|
|
129
|
+
- `body`: Payment details object
|
|
130
|
+
|
|
131
|
+
**Returns:** JSON response
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 2. Analytics Script
|
|
136
|
+
|
|
137
|
+
The analytics script tracks user interactions for conversion tracking and marketing attribution.
|
|
138
|
+
|
|
139
|
+
**CDN URL:**
|
|
140
|
+
```
|
|
141
|
+
https://cdn.example.com/analytics/latest/analytics.js
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Inclusion:**
|
|
145
|
+
```html
|
|
146
|
+
<script src="https://cdn.example.com/analytics/latest/analytics.js" defer></script>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Exported Functions:**
|
|
150
|
+
|
|
151
|
+
The analytics script automatically tracks page views and exports functions for custom events:
|
|
152
|
+
|
|
153
|
+
#### pushAddToCartEventToAnalytics(variantId, quantity, productId)
|
|
154
|
+
|
|
155
|
+
Track when user adds item to cart.
|
|
156
|
+
|
|
157
|
+
**Example:**
|
|
158
|
+
```javascript
|
|
159
|
+
window.pushAddToCartEventToAnalytics('var123', 2, 'prod789');
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### pushRemoveFromCartToAnalytics(variantId, quantity, productId)
|
|
163
|
+
|
|
164
|
+
Track item removal from cart.
|
|
165
|
+
|
|
166
|
+
**Example:**
|
|
167
|
+
```javascript
|
|
168
|
+
window.pushRemoveFromCartToAnalytics('var123', 1, 'prod789');
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### pushSearchToAnalytics(searchQuery)
|
|
172
|
+
|
|
173
|
+
Track search interactions.
|
|
174
|
+
|
|
175
|
+
**Example:**
|
|
176
|
+
```javascript
|
|
177
|
+
window.pushSearchToAnalytics('summer dresses');
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### pushSelectListItemToAnalytics(productId, listData)
|
|
181
|
+
|
|
182
|
+
Track product selection from list/collection.
|
|
183
|
+
|
|
184
|
+
**Parameters:**
|
|
185
|
+
- `productId`: Selected product
|
|
186
|
+
- `listData`: Object with `id` and `title`
|
|
187
|
+
|
|
188
|
+
**Example:**
|
|
189
|
+
```javascript
|
|
190
|
+
window.pushSelectListItemToAnalytics('prod123', {
|
|
191
|
+
id: 'featured',
|
|
192
|
+
title: 'Featured Products'
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### pushViewProductDetailsToAnalytics(productId)
|
|
197
|
+
|
|
198
|
+
Track product detail page views.
|
|
199
|
+
|
|
200
|
+
**Example:**
|
|
201
|
+
```javascript
|
|
202
|
+
window.pushViewProductDetailsToAnalytics('prod123');
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### pushCheckOutBeginToAnalytics()
|
|
206
|
+
|
|
207
|
+
Track checkout initiation.
|
|
208
|
+
|
|
209
|
+
**Example:**
|
|
210
|
+
```javascript
|
|
211
|
+
window.pushCheckOutBeginToAnalytics();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### pushShippingInfoToAnalytics()
|
|
215
|
+
|
|
216
|
+
Track shipping method selection.
|
|
217
|
+
|
|
218
|
+
**Example:**
|
|
219
|
+
```javascript
|
|
220
|
+
window.pushShippingInfoToAnalytics();
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### pushPaymentInfoToAnalytics()
|
|
224
|
+
|
|
225
|
+
Track payment method selection.
|
|
226
|
+
|
|
227
|
+
**Example:**
|
|
228
|
+
```javascript
|
|
229
|
+
window.pushPaymentInfoToAnalytics();
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
#### pushPurchaseInfoToAnalytics()
|
|
233
|
+
|
|
234
|
+
Track successful purchase.
|
|
235
|
+
|
|
236
|
+
**Example:**
|
|
237
|
+
```javascript
|
|
238
|
+
window.pushPurchaseInfoToAnalytics();
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Integration Example
|
|
244
|
+
|
|
245
|
+
Here's a typical pattern for integrating both scripts:
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<!-- Include both scripts -->
|
|
249
|
+
<script src="https://cdn.example.com/storefront-actions/latest/storefront-actions.js" defer></script>
|
|
250
|
+
<script src="https://cdn.example.com/analytics/latest/analytics.js" defer></script>
|
|
251
|
+
|
|
252
|
+
<!-- Add to cart button -->
|
|
253
|
+
<button onclick="handleAddToCart()">Add to Cart</button>
|
|
254
|
+
|
|
255
|
+
<script>
|
|
256
|
+
async function handleAddToCart() {
|
|
257
|
+
try {
|
|
258
|
+
// Call storefront action
|
|
259
|
+
const result = await addToCart(variantId, orgId, 'cart-items', 1, productId);
|
|
260
|
+
|
|
261
|
+
// Update UI with response
|
|
262
|
+
document.getElementById('cart-section').innerHTML = result.sections.cartItems;
|
|
263
|
+
|
|
264
|
+
// Analytics is automatically tracked if productId provided
|
|
265
|
+
// But can also explicitly call:
|
|
266
|
+
window.pushAddToCartEventToAnalytics(variantId, 1, productId);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.error('Failed to add to cart:', error);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
</script>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Benefits
|
|
277
|
+
|
|
278
|
+
- **No Boilerplate**: Use pre-built functions instead of writing API calls
|
|
279
|
+
- **Built-in Analytics**: Actions automatically integrate with Zoho Analytics
|
|
280
|
+
- **Section Rendering**: Get live-updated section HTML from server
|
|
281
|
+
- **Error Handling**: Consistent error responses across all functions
|
|
282
|
+
- **Marketing Integration**: Track conversions for email, SMS, and ads
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Notes
|
|
287
|
+
|
|
288
|
+
- Scripts are automatically versioned by Zoho Commerce
|
|
289
|
+
- Always use `await` for async functions
|
|
290
|
+
- Include both scripts for full functionality
|
|
291
|
+
- Check browser console for errors during development
|
|
292
|
+
- Scripts are available on Zoho Commerce CDN
|
|
293
|
+
|
|
294
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Internationalization"
|
|
3
|
+
weight: 9
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# i18n
|
|
7
|
+
|
|
8
|
+
Zoho Commerce themes support multiple languages through translation files stored in the `i18n/` folder.
|
|
9
|
+
|
|
10
|
+
## Translation Files
|
|
11
|
+
|
|
12
|
+
The `i18n/` folder contains translation files. Two files are required in every theme; additional language files are added when targeting multiple languages:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
i18n/
|
|
16
|
+
├── en.json # English (default fallback)
|
|
17
|
+
├── en.schema.json # Schema label translations for the theme editor UI
|
|
18
|
+
├── ar.json # Arabic
|
|
19
|
+
├── de.json # German
|
|
20
|
+
├── es.json # Spanish
|
|
21
|
+
├── fr.json # French
|
|
22
|
+
├── id.json # Indonesian
|
|
23
|
+
├── ja.json # Japanese
|
|
24
|
+
├── ko.json # Korean
|
|
25
|
+
├── pt.json # Portuguese
|
|
26
|
+
├── th.json # Thai
|
|
27
|
+
├── vi.json # Vietnamese
|
|
28
|
+
├── zh.json # Chinese (Simplified)
|
|
29
|
+
└── zh_tw.json # Chinese (Traditional)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### File Format
|
|
33
|
+
|
|
34
|
+
`en.json` uses nested keys grouped by component:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"common": {
|
|
39
|
+
"home": "Home",
|
|
40
|
+
"loader": "Loading"
|
|
41
|
+
},
|
|
42
|
+
"header": {
|
|
43
|
+
"sign_in": "Sign In",
|
|
44
|
+
"sign_up": "Sign Up",
|
|
45
|
+
"sign_out": "Sign Out",
|
|
46
|
+
"my_profile": "My Profile",
|
|
47
|
+
"my_orders": "My Orders",
|
|
48
|
+
"my_wishlist": "My Wishlist"
|
|
49
|
+
},
|
|
50
|
+
"product_details": {
|
|
51
|
+
"sold_out": "Sold Out",
|
|
52
|
+
"on_sale": "On sale"
|
|
53
|
+
},
|
|
54
|
+
"pagination": {
|
|
55
|
+
"previous_btn": "<",
|
|
56
|
+
"next_btn": ">",
|
|
57
|
+
"per_page": "per page"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Using Translations
|
|
65
|
+
|
|
66
|
+
Use the `t` (translate) filter in templates:
|
|
67
|
+
|
|
68
|
+
```liquid
|
|
69
|
+
<!-- Simple key -->
|
|
70
|
+
<button>{{ "header.sign_in" | t }}</button>
|
|
71
|
+
```
|
|
72
|
+
**Output:** `Sign In`
|
|
73
|
+
|
|
74
|
+
```liquid
|
|
75
|
+
<!-- Nested keys use dot notation -->
|
|
76
|
+
<span>{{ "header.my_orders" | t }}</span>
|
|
77
|
+
<p>{{ "product_details.sold_out" | t }}</p>
|
|
78
|
+
```
|
|
79
|
+
**Output:** `My Orders` / `Sold Out`
|
|
80
|
+
|
|
81
|
+
### Output
|
|
82
|
+
|
|
83
|
+
The `t` filter looks up the key in the current locale's JSON file and returns the translated string. If the key is missing in the current locale, it falls back to `en.json`. If the key is missing there too, it returns the key itself as a fallback.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Schema Label Translations
|
|
88
|
+
|
|
89
|
+
Section schema labels can reference translation keys using the `t:` prefix:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"type": "text",
|
|
94
|
+
"id": "heading",
|
|
95
|
+
"label": "t:sections.hero.settings.heading.label",
|
|
96
|
+
"default": "Welcome"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This makes the theme editor UI appear in the merchant's language.
|
|
101
|
+
|
|
102
|
+
Schema translations are stored in `i18n/en.schema.json`:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"sections": {
|
|
107
|
+
"hero": {
|
|
108
|
+
"name": "Hero Banner",
|
|
109
|
+
"settings": {
|
|
110
|
+
"heading": {
|
|
111
|
+
"label": "Heading Text"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Adding a New Language
|
|
122
|
+
|
|
123
|
+
1. Create a new JSON file in `i18n/` using a locale code (e.g., `fr.json` for French)
|
|
124
|
+
2. Copy the structure from `en.json`
|
|
125
|
+
3. Translate all values
|
|
126
|
+
4. Configure the language in the Zoho Commerce admin
|
|
127
|
+
|
|
128
|
+
Example `i18n/fr.json`:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"header": {
|
|
133
|
+
"sign_in": "Se connecter",
|
|
134
|
+
"sign_up": "S'inscrire",
|
|
135
|
+
"sign_out": "Se déconnecter",
|
|
136
|
+
"my_profile": "Mon profil",
|
|
137
|
+
"my_orders": "Mes commandes"
|
|
138
|
+
},
|
|
139
|
+
"product_details": {
|
|
140
|
+
"sold_out": "Épuisé",
|
|
141
|
+
"on_sale": "En solde"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Best Practices
|
|
149
|
+
|
|
150
|
+
- **Use `en.json` as the source of truth** — all other languages should translate from it
|
|
151
|
+
- **Use descriptive, nested keys** — `product_details.sold_out` not `btn1`
|
|
152
|
+
- **Never hardcode user-facing text** — always use the `t` filter
|
|
153
|
+
- **Group keys by component** — `header.*`, `footer.*`, `product_details.*`
|
|
154
|
+
- **Keep translations consistent** — use the same terminology throughout
|
|
155
|
+
- **Test all languages** — verify translations render correctly in RTL languages like Arabic
|
package/ts-dist/mocks/init-theme/.claude/skills/theme-from-figma/zcommerce-docs/introduction.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Overview"
|
|
3
|
+
weight: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Overview
|
|
7
|
+
|
|
8
|
+
Welcome to the Zoho Commerce Liquid theme development documentation. This guide covers everything you need to build, customize, and deploy themes.
|
|
9
|
+
|
|
10
|
+
## What This Covers
|
|
11
|
+
|
|
12
|
+
- **Theme Structure** — Required folders, files, and naming conventions
|
|
13
|
+
- **Liquid Templating** — Variables, filters, tags, and control flow
|
|
14
|
+
- **Sections & Blocks** — Admin-customizable components with schema
|
|
15
|
+
- **Zoho Extensions** — Platform-specific filters, objects, and scripts
|
|
16
|
+
- **Best Practices** — Performance, security, and accessibility patterns
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<details open>
|
|
21
|
+
<summary><strong>What is Liquid?</strong></summary>
|
|
22
|
+
|
|
23
|
+
Liquid is an open-source templating language designed for safe, customer-facing template rendering. It separates presentation from logic, making themes secure and maintainable.
|
|
24
|
+
|
|
25
|
+
### Core Concepts
|
|
26
|
+
|
|
27
|
+
**Variables** — Display dynamic data:
|
|
28
|
+
```liquid
|
|
29
|
+
{{ product.title }}
|
|
30
|
+
{{ store.name }}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Filters** — Transform output:
|
|
34
|
+
```liquid
|
|
35
|
+
{{ product.title | upcase }}
|
|
36
|
+
{{ product.price | divided_by: 100 }}
|
|
37
|
+
{{ "hero.jpg" | asset_url }}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Tags** — Control logic and flow:
|
|
41
|
+
```liquid
|
|
42
|
+
{% if product.available %}
|
|
43
|
+
<button>{{ "product.add_to_cart" | t }}</button>
|
|
44
|
+
{% endif %}
|
|
45
|
+
|
|
46
|
+
{% for item in collection.products %}
|
|
47
|
+
{{ item.title }}
|
|
48
|
+
{% endfor %}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Comments** — Notes without output:
|
|
52
|
+
```liquid
|
|
53
|
+
{% comment %} This won't render {% endcomment %}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Why Liquid?
|
|
57
|
+
|
|
58
|
+
| Aspect | Liquid | Traditional Code |
|
|
59
|
+
|--------|--------|-----------------|
|
|
60
|
+
| Security | Safe by design — no arbitrary code execution | Requires careful sanitization |
|
|
61
|
+
| Learning curve | Gentle — HTML + simple tags | Steeper |
|
|
62
|
+
| Use case | Templates only | General-purpose |
|
|
63
|
+
| Performance | Optimized for rendering | More overhead |
|
|
64
|
+
|
|
65
|
+
### Zoho Commerce Extensions
|
|
66
|
+
|
|
67
|
+
Beyond standard Liquid, Zoho Commerce adds:
|
|
68
|
+
|
|
69
|
+
- `asset_url` — Versioned asset URLs with cache busting
|
|
70
|
+
- `image_url` — Dynamic image URLs with optional dimension parameters
|
|
71
|
+
- `color_component` — Extract RGB/HSL values from colors
|
|
72
|
+
- `t` — Multi-language translation from i18n files
|
|
73
|
+
- Global objects for store, product, collection, and customer data
|
|
74
|
+
- Schema system for admin-customizable settings
|
|
75
|
+
|
|
76
|
+
**Reference:** [Liquid official documentation](https://shopify.github.io/liquid/)
|
|
77
|
+
|
|
78
|
+
</details>
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Quick Start
|
|
83
|
+
|
|
84
|
+
1. Read [Theme Structure](/theme-structure/) to understand the required folder layout
|
|
85
|
+
2. Follow [Setup Guide](/setup-guide/) to configure your development environment
|
|
86
|
+
3. Build sections using [Sections](/sections/) and [Schema Types](/reference/schema-types/)
|
|
87
|
+
4. Use [Filters](/reference/filters/) and [Tags](/reference/tags/) for template logic
|
|
88
|
+
5. Review [Best Practices](/best-practices/) before publishing
|
|
89
|
+
|
|
90
|
+
**For experienced developers:** Start from [Filters](/reference/filters/) and work through the reference pages — [Tags](/reference/tags/), [Schema Types](/reference/schema-types/), and [Global Objects](/reference/global-objects/) — as each may contain Zoho-specific additions.
|
|
91
|
+
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Layouts"
|
|
3
|
+
weight: 4
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Layouts
|
|
7
|
+
|
|
8
|
+
Layouts are the outermost HTML wrapper for every page. They define the document structure, inject site-wide scripts/styles, and render page content.
|
|
9
|
+
|
|
10
|
+
## Required Files
|
|
11
|
+
|
|
12
|
+
| File | Purpose |
|
|
13
|
+
|------|---------|
|
|
14
|
+
| `theme.liquid` | Default layout for all store pages |
|
|
15
|
+
| `accounts.liquid` | Layout for authentication and account pages (sign-in, sign-up, profile, orders, addresses) |
|
|
16
|
+
| `sitemap.liquid` | XML sitemap for search engine crawlers |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## theme.liquid
|
|
21
|
+
|
|
22
|
+
The main layout wrapping every page:
|
|
23
|
+
|
|
24
|
+
```liquid
|
|
25
|
+
<!DOCTYPE html>
|
|
26
|
+
<html lang="en">
|
|
27
|
+
<head>
|
|
28
|
+
<meta charset="UTF-8">
|
|
29
|
+
<title>{{ page_title }}</title>
|
|
30
|
+
{{ content_for_header }}
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
{% sections 'header-group' %}
|
|
34
|
+
|
|
35
|
+
<main>
|
|
36
|
+
{{ content_for_layout }}
|
|
37
|
+
</main>
|
|
38
|
+
|
|
39
|
+
{% sections 'footer-group' %}
|
|
40
|
+
{{ content_for_footer }}
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Layout Variables
|
|
46
|
+
|
|
47
|
+
| Variable | Placement | Description |
|
|
48
|
+
|----------|-----------|-------------|
|
|
49
|
+
| `content_for_header` | Inside `<head>` | Server-injected platform scripts, meta tags, stylesheets, and analytics from Zoho Commerce admin |
|
|
50
|
+
| `content_for_layout` | Inside `<body>` | Renders the page-specific content (sections, blocks) |
|
|
51
|
+
| `content_for_footer` | Before `</body>` | Injects scripts that must load after DOM |
|
|
52
|
+
|
|
53
|
+
> **Note:** The `{{ content_for_header }}` variable outputs code that the server builds from Zoho Commerce admin settings. Along with meta tags and other head assets, **analytics scripts are included here when configured**—you do not need to add or integrate analytics explicitly in the theme; including this variable in `<head>` is enough.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Section Groups
|
|
58
|
+
|
|
59
|
+
`{% sections 'header-group' %}` and `{% sections 'footer-group' %}` are **Zoho Commerce-specific tags** — they are not part of standard Liquid. They render a named section group, which is defined by a `.json` file in the `sections/` folder.
|
|
60
|
+
|
|
61
|
+
### What is a Section Group?
|
|
62
|
+
|
|
63
|
+
A section group is a JSON file that defines a fixed set of sections rendered together as a unit (like the header or footer). Unlike page JSON files where admins can freely add/remove sections, section groups have a fixed structure configured by the theme.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
sections/
|
|
67
|
+
├── header-group.json # defines the header group
|
|
68
|
+
├── footer-group.json # defines the footer group
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Group JSON Structure
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"name": "Header",
|
|
76
|
+
"type": "header",
|
|
77
|
+
"sections": {
|
|
78
|
+
"header": {
|
|
79
|
+
"type": "header",
|
|
80
|
+
"settings": {
|
|
81
|
+
"menu_type": { "display_name": "Drill Down", "value": "1" }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"order": ["header"]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
| Property | Description |
|
|
90
|
+
|----------|-------------|
|
|
91
|
+
| `name` | Display name for the group |
|
|
92
|
+
| `type` | Group type identifier (`"header"` or `"footer"`) |
|
|
93
|
+
| `sections` | Map of section instances keyed by ID |
|
|
94
|
+
| `order` | Array of section IDs in render order |
|
|
95
|
+
|
|
96
|
+
Each entry in `sections` is a section instance with `type` (matching a `.liquid` file in `sections/`) and `settings`. The `order` array controls which sections render and in what order.
|
|
97
|
+
|
|
98
|
+
### Usage in theme.liquid
|
|
99
|
+
|
|
100
|
+
```liquid
|
|
101
|
+
{% sections 'header-group' %} {%- comment -%} Zoho Commerce-specific tag {%- endcomment -%}
|
|
102
|
+
|
|
103
|
+
<main>
|
|
104
|
+
{{ content_for_layout }}
|
|
105
|
+
</main>
|
|
106
|
+
|
|
107
|
+
{% sections 'footer-group' %}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## accounts.liquid
|
|
113
|
+
|
|
114
|
+
Used for both authentication pages (sign-in, sign-up, forgot password) and all account pages (profile, orders, addresses). Selected by adding `"layout": "accounts"` in a page JSON file — see [Pages](/pages/) for details.
|
|
115
|
+
|
|
116
|
+
This layout does not use `{% sections 'header-group' %}` or `{% sections 'footer-group' %}`. Instead it renders the `accounts-header` snippet directly, which handles the before/after-signin header states for account pages. It also loads the Zoho accounts portal scripts required for authentication to function.
|
|
117
|
+
|
|
118
|
+
```liquid
|
|
119
|
+
<!DOCTYPE html>
|
|
120
|
+
<html lang="en-us">
|
|
121
|
+
<head>
|
|
122
|
+
<meta charset="utf-8">
|
|
123
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
124
|
+
<link rel="shortcut icon" href="{{ store.favicon.url }}">
|
|
125
|
+
<link rel="stylesheet" href="{{ "style.css" | asset_url }}">
|
|
126
|
+
<link rel="stylesheet" href="{{ "signin.css" | asset_url }}">
|
|
127
|
+
<link rel="stylesheet" href="{{ "theme-settings.css" | asset_url }}">
|
|
128
|
+
<script src="{{ "portal-signup.js" | asset_url }}" defer></script>
|
|
129
|
+
<script src="{{ routes.signup_url }}" defer></script>
|
|
130
|
+
<title>
|
|
131
|
+
{{ page_title }}
|
|
132
|
+
{% unless page_title contains store.name %}
|
|
133
|
+
– {{ store.name }}
|
|
134
|
+
{% endunless %}
|
|
135
|
+
</title>
|
|
136
|
+
</head>
|
|
137
|
+
<body>
|
|
138
|
+
{% render "accounts-header", store: store %}
|
|
139
|
+
{{ content_for_layout }}
|
|
140
|
+
{% render "theme-settings" %}
|
|
141
|
+
</body>
|
|
142
|
+
</html>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> The `accounts_signup_url` script is the Zoho accounts portal JS bundle. It is required for sign-in, sign-up, and password reset flows to work.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## sitemap.liquid
|
|
151
|
+
|
|
152
|
+
Renders the XML sitemap at `/sitemap.xml`. The sitemap content is generated by Zoho Commerce and injected via `content_for_layout`:
|
|
153
|
+
|
|
154
|
+
```liquid
|
|
155
|
+
{{ content_for_layout }}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Zoho Commerce automatically generates and serves the sitemap XML — the layout just provides the wrapper for the platform to inject it.
|