Skip to content

Commit e396063

Browse files
authored
feat: use store-info resource (#72)
1 parent af3d4ef commit e396063

File tree

13 files changed

+59
-33
lines changed

13 files changed

+59
-33
lines changed

theme/components/sections/store/item-list.html.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
{% endif %}
108108
{% set filtersDialogProps = {
109109
id: filterDropdownId ~ '__dialog',
110-
fulfillment_support: square.store.fulfillment_support,
110+
fulfillment_support: store_info.fulfillment_support,
111111
current_value: request.query|default({}),
112112
global_options,
113113
category,
@@ -168,7 +168,7 @@
168168
{{ include('partials/components/store/filters/buttons/categories', { id: filterDropdownId ~ '__categories', currentValue: (request.query.category_ids|split(','))|default({}), category }) }}
169169
</span>
170170
{% endif %}
171-
{{ include('partials/components/store/filters/buttons/advanced', { id: filterDropdownId ~ '__advanced', chooseLocationTemplateId, currentValue: request.query|default({}), filtersDialogProps, globalOptions: global_options }) }}
171+
{{ include('partials/components/store/filters/buttons/advanced', { id: filterDropdownId ~ '__advanced', storeInfo: store_info, chooseLocationTemplateId, currentValue: request.query|default({}), filtersDialogProps, globalOptions: global_options }) }}
172172
</div>
173173
{{ include('partials/components/store/filters/buttons/sort', { id: filterDropdownId ~ '__sort', sortOptions: sort_options, currentValue: currentSortValue }) }}
174174
</div>
@@ -216,6 +216,9 @@
216216
"sort_options": {
217217
"type": "array"
218218
},
219+
"store_info": {
220+
"type": "store-info"
221+
},
219222
"global_options": {
220223
"type": "array",
221224
"optional": true

theme/components/sections/store/item/main.html.twig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
{% if product.subscriptions|length %}
158158
<fieldset>
159159
<legend class="visually-hidden">{{ 'partials.components.store.item.subscriptions.label'|localize }}</legend>
160-
{{ include('partials/form/subscriptions', { subscriptions: product.subscriptions }) }}
160+
{{ include('partials/form/subscriptions', { subscriptions: product.subscriptions, storeInfo: store_info }) }}
161161
</fieldset>
162162
{% endif %}
163163

@@ -169,9 +169,9 @@
169169
x-data="productFormButtons(Boolean({{ isManualFulfillment }}))"
170170
class="item-page__add-to-buttons"
171171
>
172-
{% set isNotAcceptingOrders = square.store.accepting_orders == false %}
172+
{% set isNotAcceptingOrders = store_info.accepting_orders == false %}
173173
{% set shouldShowAddToCartButton = true %}
174-
{% set shouldShowBuyNowButton = square.store.show_pdp_buy_now_button %}
174+
{% set shouldShowBuyNowButton = store_info.show_pdp_buy_now_button %}
175175
{% set buyNowButtonText = 'shared.buttons.buy_now'|localize %}
176176

177177
{% if productTypes[product.square_online_type] %}
@@ -250,7 +250,7 @@
250250
{% endif %}
251251

252252
{# Shipping and return policies #}
253-
{{ include('partials/components/store/item/policies') }}
253+
{{ include('partials/components/store/item/policies', { storeInfo: store_info }) }}
254254
</div>
255255
</div>
256256
</div>
@@ -271,6 +271,9 @@ function setInitialProductStore() {
271271
},
272272
"locations": {
273273
"type": "location-list"
274+
},
275+
"store_info": {
276+
"type": "store-info"
274277
}
275278
}
276279
{% endschema %}

theme/layouts/theme.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{% endblock %}
4848
</head>
4949

50-
{% set defaultFulfillment = (square.store.default_item_fulfillment|split(',')[0])|default('SHIPMENT') %}
50+
{% set defaultFulfillment = (store_info.default_item_fulfillment|split(',')[0])|default('SHIPMENT') %}
5151

5252
{% if config.theme.shouldUseSiteStyles %}
5353
{% set themeContainerWidth = max(square.site.styles.spacing.site_width, 1200) %}
@@ -65,8 +65,8 @@
6565
>
6666
<script id="global-data" type="application/json">
6767
{{ {
68-
locale: square.store.locale,
69-
currency: square.store.currency,
68+
locale: store_info.locale,
69+
currency: store_info.currency,
7070
defaultFulfillment,
7171
}|json_encode }}
7272
</script>

theme/partials/components/mini-cart.html.twig

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444
{% for modifier in modifiersWithPrice %}
4545
{% set itemBasePrice = itemBasePrice + modifier.base_price_money.amount %}
4646
{% endfor %}
47-
{% set itemBasePriceFormatted = (itemBasePrice)|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) %}
47+
{% set itemBasePriceFormatted = (itemBasePrice)|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) %}
4848
{% endif %}
4949

5050
{# Regular and sale price #}
5151
{% set isOnSale = itemBasePrice != item.gross_price_money.amount %}
5252
{% if isOnSale %}
53-
{{ include('partials/ui/price', { price: {
53+
{{ include('partials/ui/price', { price: {
5454
regular_high: {
5555
amount: itemBasePrice,
56-
currency: cart.order.total_money.currency|default(square.store.currency),
57-
formatted: itemBasePrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) })
58-
},
56+
currency: cart.order.total_money.currency|default(store_info.currency),
57+
formatted: itemBasePrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) })
58+
},
5959
regular_low: {
6060
amount: item.gross_price_money.amount,
61-
currency: cart.order.total_money.currency|default(square.store.currency),
62-
formatted: item.gross_price_money.amount|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) })
61+
currency: cart.order.total_money.currency|default(store_info.currency),
62+
formatted: item.gross_price_money.amount|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) })
6363
},
6464
}, size: 'tiny' }) }}
6565
{% endif %}
@@ -105,13 +105,13 @@
105105
{{ include('partials/ui/price', { price: {
106106
regular_high: {
107107
amount: itemFinalPrice,
108-
currency: cart.order.total_money.currency|default(square.store.currency),
109-
formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) })
108+
currency: cart.order.total_money.currency|default(store_info.currency),
109+
formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) })
110110
},
111111
regular_low: {
112112
amount: itemFinalPrice,
113-
currency: cart.order.total_money.currency|default(square.store.currency),
114-
formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) })
113+
currency: cart.order.total_money.currency|default(store_info.currency),
114+
formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) })
115115
},
116116
}, size: 'small' }) }}
117117
</div>
@@ -169,7 +169,7 @@
169169
{% for discount in cart.order.discounts %}
170170
{% set subtotal = subtotal - discount.applied_money.amount %}
171171
{% endfor %}
172-
{% set formattedSubtotal = (subtotal)|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) %}
172+
{% set formattedSubtotal = (subtotal)|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) %}
173173
{% endif %}
174174

175175
{% embed 'partials/ui/button' with {
@@ -204,6 +204,9 @@
204204
{
205205
"cart": {
206206
"type": "cart"
207+
},
208+
"store_info": {
209+
"type": "store-info"
207210
}
208211
}
209-
{% endschema %}
212+
{% endschema %}

theme/partials/components/store/filters/buttons/advanced.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if 'PICKUP' in square.store.fulfillment_support %}
1+
{% if 'PICKUP' in storeInfo.fulfillment_support %}
22
{{ register_asset('css/components/store/item/locations-dialog.css') }}
33
{{ register_asset('js/components/store/item/locations-dialog.js', { defer: false }) }}
44
{% endif %}
@@ -40,7 +40,7 @@
4040

4141
<div class="filters__advanced-options-row">
4242
{# Fulfillments and item status #}
43-
{{ include('partials/components/store/filters/options/fulfillments-and-status', { chooseLocationTemplateId, fulfillmentSupport: square.store.fulfillment_support }) }}
43+
{{ include('partials/components/store/filters/options/fulfillments-and-status', { chooseLocationTemplateId, fulfillmentSupport: storeInfo.fulfillment_support }) }}
4444
</div>
4545

4646
{% if globalOptions|length %}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{% set accordions = [] %}
22
{% set accordionAllowedTags = '<p><strong><em><ul><li><ol><a>' %}
3-
{% if square.store.shipping_policy is not empty %}
3+
{% if storeInfo.shipping_policy is not empty %}
44
{% set accordions = accordions|merge([{
55
icon: 'receipt_long',
66
label: 'partials.components.store.item.policies.shipping.label'|localize,
7-
content: square.store.shipping_policy,
7+
content: storeInfo.shipping_policy,
88
}]) %}
99
{% endif %}
10-
{% if square.store.return_policy is not empty %}
10+
{% if storeInfo.return_policy is not empty %}
1111
{% set accordions = accordions|merge([{
1212
icon: 'policy',
1313
label: 'partials.components.store.item.policies.return.label'|localize,
14-
content: square.store.return_policy,
14+
content: storeInfo.return_policy,
1515
}]) %}
1616
{% endif %}
1717
{% if accordions|length > 0 %}
@@ -20,4 +20,4 @@
2020
{{ include('partials/ui/accordion', { accordionItems: [item], allowedTags: accordionAllowedTags, richTextFormatting: true }) }}
2121
{% endfor %}
2222
</div>
23-
{% endif %}
23+
{% endif %}

theme/partials/form/subscriptions.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
{{ {
135135
cadences: SUBSCRIPTION_CADENCES,
136136
subscriptionCards,
137-
currency: square.store.currency,
137+
currency: storeInfo.currency,
138138
translations: {
139139
billingCycleOneDay: 'partials.form.subscriptions.billing_cycle.one_day'|localize,
140140
billingCycleDays: 'partials.form.subscriptions.billing_cycle.days'|localize,
@@ -179,7 +179,7 @@
179179
{% set discount = defaultPhase.pricing.discounts[0] %}
180180
{% set subscriptionPrice = null %}
181181
{% if defaultPhase.pricing.regular %}
182-
{% set subscriptionPrice = { regular_high: defaultPhase.pricing.regular, regular_low: defaultPhase.pricing.subscription, currency: square.store.currency } %}
182+
{% set subscriptionPrice = { regular_high: defaultPhase.pricing.regular, regular_low: defaultPhase.pricing.subscription, currency: storeInfo.currency } %}
183183
{% endif %}
184184

185185
{% if discount.discount_type == 'FIXED_PERCENTAGE' %}
@@ -231,4 +231,4 @@
231231
{% endfor %}
232232
{% endblock %}
233233
{% endembed %}
234-
</div>
234+
</div>

theme/templates/pages/home.html.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
{{ section_container(main, 'Main sections') }}
1414
</div>
1515

16-
1716
{% endblock %}
1817

1918
{% schema %}
@@ -23,6 +22,9 @@
2322
},
2423
"main": {
2524
"type": "section-list"
25+
},
26+
"store_info": {
27+
"type": "store-info"
2628
}
2729
}
2830
{% endschema %}

theme/templates/store/category.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
},
6666
"categories": {
6767
"type": "category-list"
68+
},
69+
"store_info": {
70+
"type": "store-info"
6871
}
6972
}
7073
{% endschema %}

theme/templates/store/item.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
{
5454
"item": {
5555
"type": "item"
56+
},
57+
"store_info": {
58+
"type": "store-info"
5659
}
5760
}
5861
{% endschema %}

theme/templates/store/locations.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
{
9090
"locations": {
9191
"type": "location-list"
92+
},
93+
"store_info": {
94+
"type": "store-info"
9295
}
9396
}
9497
{% endschema %}

theme/templates/store/search.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
{
5151
"search_term": {
5252
"type": "string"
53+
},
54+
"store_info": {
55+
"type": "store-info"
5356
}
5457
}
5558
{% endschema %}

theme/templates/store/shop.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
},
5555
"category_hierarchy": {
5656
"type": "category-hierarchy"
57+
},
58+
"store_info": {
59+
"type": "store-info"
5760
}
5861
}
5962
{% endschema %}

0 commit comments

Comments
 (0)