From 89cf20cc33990f28c20336a5e842a40285605e91 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 31 Oct 2024 16:01:46 -0700 Subject: [PATCH] feat: use store-info resource --- .../sections/store/item-list.html.twig | 7 +++-- .../sections/store/item/main.html.twig | 11 ++++--- theme/layouts/theme.html.twig | 6 ++-- theme/partials/components/mini-cart.html.twig | 29 ++++++++++--------- .../store/filters/buttons/advanced.html.twig | 4 +-- .../components/store/item/policies.html.twig | 10 +++---- theme/partials/form/subscriptions.html.twig | 6 ++-- theme/templates/pages/home.html.twig | 4 ++- 8 files changed, 44 insertions(+), 33 deletions(-) diff --git a/theme/components/sections/store/item-list.html.twig b/theme/components/sections/store/item-list.html.twig index 88d15a3..8d69e28 100644 --- a/theme/components/sections/store/item-list.html.twig +++ b/theme/components/sections/store/item-list.html.twig @@ -107,7 +107,7 @@ {% endif %} {% set filtersDialogProps = { id: filterDropdownId ~ '__dialog', - fulfillment_support: square.store.fulfillment_support, + fulfillment_support: store_info.fulfillment_support, current_value: request.query|default({}), global_options, category, @@ -168,7 +168,7 @@ {{ include('partials/components/store/filters/buttons/categories', { id: filterDropdownId ~ '__categories', currentValue: (request.query.category_ids|split(','))|default({}), category }) }} {% endif %} - {{ include('partials/components/store/filters/buttons/advanced', { id: filterDropdownId ~ '__advanced', chooseLocationTemplateId, currentValue: request.query|default({}), filtersDialogProps, globalOptions: global_options }) }} + {{ include('partials/components/store/filters/buttons/advanced', { id: filterDropdownId ~ '__advanced', storeInfo: store_info, chooseLocationTemplateId, currentValue: request.query|default({}), filtersDialogProps, globalOptions: global_options }) }} {{ include('partials/components/store/filters/buttons/sort', { id: filterDropdownId ~ '__sort', sortOptions: sort_options, currentValue: currentSortValue }) }} @@ -216,6 +216,9 @@ "sort_options": { "type": "array" }, + "store_info": { + "type": "store-info" + }, "global_options": { "type": "array", "optional": true diff --git a/theme/components/sections/store/item/main.html.twig b/theme/components/sections/store/item/main.html.twig index 2529b99..56f749b 100644 --- a/theme/components/sections/store/item/main.html.twig +++ b/theme/components/sections/store/item/main.html.twig @@ -157,7 +157,7 @@ {% if product.subscriptions|length %}
{{ 'partials.components.store.item.subscriptions.label'|localize }} - {{ include('partials/form/subscriptions', { subscriptions: product.subscriptions }) }} + {{ include('partials/form/subscriptions', { subscriptions: product.subscriptions, storeInfo: store_info }) }}
{% endif %} @@ -169,9 +169,9 @@ x-data="productFormButtons(Boolean({{ isManualFulfillment }}))" class="item-page__add-to-buttons" > - {% set isNotAcceptingOrders = square.store.accepting_orders == false %} + {% set isNotAcceptingOrders = store_info.accepting_orders == false %} {% set shouldShowAddToCartButton = true %} - {% set shouldShowBuyNowButton = square.store.show_pdp_buy_now_button %} + {% set shouldShowBuyNowButton = store_info.show_pdp_buy_now_button %} {% set buyNowButtonText = 'shared.buttons.buy_now'|localize %} {% if productTypes[product.square_online_type] %} @@ -250,7 +250,7 @@ {% endif %} {# Shipping and return policies #} - {{ include('partials/components/store/item/policies') }} + {{ include('partials/components/store/item/policies', { storeInfo: store_info }) }} @@ -271,6 +271,9 @@ function setInitialProductStore() { }, "locations": { "type": "location-list" + }, + "store_info": { + "type": "store-info" } } {% endschema %} diff --git a/theme/layouts/theme.html.twig b/theme/layouts/theme.html.twig index fa3f050..2307ba3 100644 --- a/theme/layouts/theme.html.twig +++ b/theme/layouts/theme.html.twig @@ -47,7 +47,7 @@ {% endblock %} - {% set defaultFulfillment = (square.store.default_item_fulfillment|split(',')[0])|default('SHIPMENT') %} + {% set defaultFulfillment = (store_info.default_item_fulfillment|split(',')[0])|default('SHIPMENT') %} {% if config.theme.shouldUseSiteStyles %} {% set themeContainerWidth = max(square.site.styles.spacing.site_width, 1200) %} @@ -65,8 +65,8 @@ > diff --git a/theme/partials/components/mini-cart.html.twig b/theme/partials/components/mini-cart.html.twig index 93be42f..68a63f6 100644 --- a/theme/partials/components/mini-cart.html.twig +++ b/theme/partials/components/mini-cart.html.twig @@ -44,22 +44,22 @@ {% for modifier in modifiersWithPrice %} {% set itemBasePrice = itemBasePrice + modifier.base_price_money.amount %} {% endfor %} - {% set itemBasePriceFormatted = (itemBasePrice)|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) %} + {% set itemBasePriceFormatted = (itemBasePrice)|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) %} {% endif %} {# Regular and sale price #} {% set isOnSale = itemBasePrice != item.gross_price_money.amount %} {% if isOnSale %} - {{ include('partials/ui/price', { price: { + {{ include('partials/ui/price', { price: { regular_high: { amount: itemBasePrice, - currency: cart.order.total_money.currency|default(square.store.currency), - formatted: itemBasePrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) - }, + currency: cart.order.total_money.currency|default(store_info.currency), + formatted: itemBasePrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) + }, regular_low: { amount: item.gross_price_money.amount, - currency: cart.order.total_money.currency|default(square.store.currency), - formatted: item.gross_price_money.amount|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) + currency: cart.order.total_money.currency|default(store_info.currency), + formatted: item.gross_price_money.amount|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) }, }, size: 'tiny' }) }} {% endif %} @@ -105,13 +105,13 @@ {{ include('partials/ui/price', { price: { regular_high: { amount: itemFinalPrice, - currency: cart.order.total_money.currency|default(square.store.currency), - formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) + currency: cart.order.total_money.currency|default(store_info.currency), + formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) }, regular_low: { amount: itemFinalPrice, - currency: cart.order.total_money.currency|default(square.store.currency), - formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) + currency: cart.order.total_money.currency|default(store_info.currency), + formatted: itemFinalPrice|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) }, }, size: 'small' }) }} @@ -169,7 +169,7 @@ {% for discount in cart.order.discounts %} {% set subtotal = subtotal - discount.applied_money.amount %} {% endfor %} - {% set formattedSubtotal = (subtotal)|format_price({ currency: cart.order.total_money.currency|default(square.store.currency) }) %} + {% set formattedSubtotal = (subtotal)|format_price({ currency: cart.order.total_money.currency|default(store_info.currency) }) %} {% endif %} {% embed 'partials/ui/button' with { @@ -204,6 +204,9 @@ { "cart": { "type": "cart" + }, + "store_info": { + "type": "store-info" } } -{% endschema %} \ No newline at end of file +{% endschema %} diff --git a/theme/partials/components/store/filters/buttons/advanced.html.twig b/theme/partials/components/store/filters/buttons/advanced.html.twig index ffa1296..fe685c0 100644 --- a/theme/partials/components/store/filters/buttons/advanced.html.twig +++ b/theme/partials/components/store/filters/buttons/advanced.html.twig @@ -1,4 +1,4 @@ -{% if 'PICKUP' in square.store.fulfillment_support %} +{% if 'PICKUP' in storeInfo.fulfillment_support %} {{ register_asset('css/components/store/item/locations-dialog.css') }} {{ register_asset('js/components/store/item/locations-dialog.js', { defer: false }) }} {% endif %} @@ -40,7 +40,7 @@
{# Fulfillments and item status #} - {{ include('partials/components/store/filters/options/fulfillments-and-status', { chooseLocationTemplateId, fulfillmentSupport: square.store.fulfillment_support }) }} + {{ include('partials/components/store/filters/options/fulfillments-and-status', { chooseLocationTemplateId, fulfillmentSupport: storeInfo.fulfillment_support }) }}
{% if globalOptions|length %} diff --git a/theme/partials/components/store/item/policies.html.twig b/theme/partials/components/store/item/policies.html.twig index 2ab9fdb..f17149a 100644 --- a/theme/partials/components/store/item/policies.html.twig +++ b/theme/partials/components/store/item/policies.html.twig @@ -1,17 +1,17 @@ {% set accordions = [] %} {% set accordionAllowedTags = '