Home
Wiki
Home
Wiki
  1. 3. Reusables
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 6. FAQ
    • 1. Structure
      • _Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • _Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • Offer
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Quote
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • _Overview
      • Addresses
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • BillingRetail
      • BlogPostingStructuredData
      • BrandListStructuredData
      • CollectionStructuredData
      • Company
      • General
      • Login
      • LoginModal
      • MonthlyTransactions
      • Offers
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductGridItemClassic
      • ProductListItem
      • ProductModal
      • ProductStructuredData
      • ProfileInfo
      • PromptModal
      • Quotes
      • Register
      • Services
      • Shipping
      • ShoppingLists
      • ShoppingListsButton
      • ShoppingListsNavbar
      • StoresStructuredData
      • Toast
      • Transactions
      • Users
      • VariantContent
      • VariantContentClassic
      • WishlistButton
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • _Overview
        • theme.js
      • Css - Scss
        • _Overview
        • ThemeClasses
    • 5. SDK
      • _Overview
      • LiquidGlobals
      • ServicesSDK
  1. 3. Reusables

VariantContentClassic

Purpose#

VariantContentClassic is the Classic-theme counterpart of VariantContent: the variant-selection reusable used in product quick-add/product-modal experiences.
It mirrors VariantContent's behavior (dimension selectors, selected-variant resolution, add-to-cart readiness) with Classic-specific markup, a modal image swiper, and cart-quantity syncing for items already in the cart.

Where it's rendered#

Rendered from the same kind of contexts as VariantContent (e.g. cart/quick-add modal), using the Classic theme variant:
{% render 'Reusables\VariantContentClassic\Default', quickAddModal: true %}

Inputs (Liquid render parameters)#

Same contract as VariantContent:
quickAddModal (boolean, optional)
When true, shows the "Available variants" title and a product image block at the top.
Main data input (not a render parameter):
$store.productModal.product

Template behavior (Liquid + Alpine)#

Follows the same product header, MPN/SKU, and dimensions UI behavior as VariantContent (see that page for the full model shape and dimension-resolution rules).
Differences from VariantContent:
Renders a modal-scoped image swiper (initModalImageSwiper) that reacts to the selected variant's linked media (slideToVariantImage).
Syncs quantity with any matching item already in the cart (cartItem, isInCart, handleCartIncrease/handleCartDecrease/handleCartQuantityInput).
Re-initializes local selection state when the modal's product changes (reInitWithProduct), same intent as VariantContent's watcher but implemented as an explicit method.
Alpine wiring:
x-data="variantcontentclassicreusabledefault.initComponent($store.productModal.product, '{{ Reusables.VariantContentClassic.Translations.AddToCartErrorMessage }}', '{{ Reusables.VariantContentClassic.Translations.UpdateProductQuantityErrorMessage }}')"

Data contract (JS runtime)#

Model shape (storefront example)#

Same product shape as VariantContent — see that page's Model shape sample for the sanitized JSON (productVariants[], dimension1/dimension2, pricing fields).

JavaScript#

Global object#

Global object: variantcontentclassicreusabledefault

initSwiper(refs)#

Initializes a dimension-picker Swiper (color swatches / size buttons), same as VariantContent.

initModalImageSwiper(refs)#

Initializes the modal's product-image Swiper. Enables loop/touch navigation only when more than one slide is present.

initComponent(product, addToCartErrorMessage, updateProductQuantityErrorMessage)#

Factory returning Alpine state and handlers for variant selection, quantity, cart syncing, and the modal image swiper.

init#

Alpine lifecycle method. Sets up initial dimension selection state, registers listeners, and initializes the modal image swiper.

selectedVariant#

Getter that returns the currently selected variant (or null when selection is incomplete).

updateSelectedVariant#

Recomputes selectedVariant from the current dimension selections and updates dependent UI/pricing state.

allDimensionsSelected#

Getter returning whether all required dimension selections are complete.

hasMultipleVariants#

Getter returning whether the product has more than one variant.

setSelectedColor#

Sets the selected color dimension item and recomputes the selected variant.

setSelectedOther#

Sets the selected non-color dimension item and recomputes the selected variant.

setDimension#

Generic dimension setter used by both color and non-color selection flows.

isOtherOptionOrderable#

Returns whether a candidate non-color option is orderable under the current selection.

isSingleOptionOrderable#

Returns whether a single-dimension option is orderable for single-dimension products.

reInitWithProduct#

Re-initializes local selection and swiper state when $store.productModal.product changes (e.g. the modal is reopened for a different product).

slideToVariantImage#

Slides the modal image swiper to the media item linked to the currently selected variant.

displayStartPrice / displayFinalPrice / displayOriginalPrice#

Getters controlling which price block (range/start, final, original/discounted) is shown for the current selection.

variantOrDefault(path, displayNullLine)#

Reads a value from the selected variant first, falling back to the product; returns - when displayNullLine is true and the value is missing. Also toggles customColorActive for stockAvailability.label === 'Custom'.

canAddToCart#

Returns whether the current selection is orderable and the add-to-cart action should be enabled.

handleAddToCart(closeModal)#

Clears toasts, checks canAddToCart(), then calls servicesreusabledefault.addToCart(...). On success, optionally closes the modal, updates quantity constraints from the response, and calls updateQuantity(...).

debounceUpdateProduct#

Debounces product-variant dependent quantity updates to avoid excessive recomputation on rapid clicks.

updateQuantity(newQuantity, product, productVariantId, checkQuantity, useDebounce)#

Validates/normalizes quantity server-side via servicesreusabledefault.updateProductQuantity when checkQuantity is true; otherwise updates the local quantity directly.

cartItem#

Getter that finds the matching item already present in $store.cart for the selected variant.

isInCart#

Getter that returns whether the currently selected variant is already present in the cart.

applyCartItemQuantity#

Syncs the local quantity field from the matching cart item.

handleCartIncrease / handleCartDecrease / handleCartQuantityInput#

Update the quantity of an item already in the cart (increment, decrement, or direct input) and persist the change via servicesreusabledefault.updateProductCart(...).

debouncedUpdateCartItemQuantity#

Debounces cart-quantity updates from the increase/decrease/input handlers before calling the cart update service.

removeCartItem#

Removes the matching item from the cart via servicesreusabledefault.removeFromCart(...) when quantity is reduced to zero.

Global Alpine stores#

$store.productModal (product)
$store.cart (reading/updating the item already in the cart)
$store.toast (removeAll(), add(...))

Services / API calls#

Uses servicesreusabledefault for add-to-cart and quantity-validation operations, same as VariantContent, plus cart-quantity syncing calls used only in the Classic variant:
servicesreusabledefault.addToCart(...)
servicesreusabledefault.updateProductQuantity(data, cancelToken)
servicesreusabledefault.updateProductCart(...) — used by handleCartIncrease/handleCartDecrease/handleCartQuantityInput to persist quantity changes for an item already in the cart.
servicesreusabledefault.removeFromCart(...) — used by removeCartItem to remove the item when quantity reaches zero.

Dependencies#

Liquid: Reusables/VariantContentClassic/Default.liquid
JS: Reusables/VariantContentClassic/Default.js
Translations: Reusables/VariantContentClassic/Default.json (consumed as Reusables.VariantContentClassic.Translations.*)
Vendor: Swiper (dimension carousels + modal image swiper)

Notes#

Functionally equivalent to VariantContent; consult that page for the full dimension/variant selection model shape.
Modal image swiper (initModalImageSwiper, slideToVariantImage) and cart-quantity syncing (cartItem, isInCart, cart increase/decrease/input handlers, removeCartItem) are Classic-specific and not present in VariantContent.
Modified at 2026-07-24 07:19:10
Previous
VariantContent
Next
WishlistButton
Built with