LogoLogo
Siteglide.comAdminRoadmap
  • πŸ‘‹Welcome
  • Get Started
    • πŸš€Quickstart Guides
    • ❔Support & FAQs
      • ℹ️Siteglide Support Policy
      • ℹ️Siteglide Technology Stack
      • ℹ️External Resources
      • ℹ️Front-end Browser Support
  • Portal
    • Account
    • Sites
      • πŸš€Quickstart: Create a Site
      • ℹ️Site Details
      • ℹ️Site Users
      • πŸ“‹Install & Manage Modules
      • πŸ’³Go Live
      • πŸ’³Subscription
      • 🌍Domains
        • πŸ“‹Add a Fully Delegated Domain
        • πŸ“‹Add an External Domain
        • πŸ’»Subdomain on a separate instance
        • πŸ“‹How to setup a multi domain start page
      • ☁️Site Backups and Disaster Recovery
    • Users
      • πŸ“‹User Roles
      • πŸ“‹Invite & Manage Users
    • Billing
      • πŸ’³Billing Setup
      • πŸ’³Subscriptions and Changes
      • πŸ’³Automatic Site Upgrades
      • πŸ’³Invoices
    • Tickets
    • Marketplace
    • Agencies
      • πŸ‘©β€πŸ’»Agency Account
      • πŸ‘©β€πŸ’»Clients
      • πŸ‘©β€πŸ’»Site Copies
      • πŸ‘©β€πŸ’»Agency Whitelabelling
  • Developer Tools
    • CLI
      • πŸš€Quickstart: CLI
      • ℹ️About
      • πŸ“‹Site Setup
      • ❔Troubleshooting
      • πŸ’»Reference
      • πŸ›³οΈCLI Changelog
      • πŸ§™β€β™‚οΈGo Further: CLI
        • Creating WebApps via CLI
    • Liquid
      • ℹ️About
      • πŸ’»Reference
      • Accessing Data in Liquid Variables - Tutorial 1 - Using Dot Notation
      • Accessing Data in Liquid Variables - Tutorial 2 - Iterating over Arrays and Objects
      • Using Collections with WebApps and Modules
      • Accessing Data from the Global Context Variable
      • Truthiness - Using Liquid to determine if a field is empty or blank
      • πŸ“‹Alternatives to Storing and Executing Liquid from Database Items
    • GraphQL
      • ℹ️About GraphQL
      • πŸ“‹Tutorials
        • Tutorial 1 - Your First Query
        • Tutorial 2 - Pagination
        • Tutorial 3 - Filtering the Results
        • Tutorial 3 - (Answers)
        • Tutorial 4 - Advanced Filtering
        • Tutorial 4 - (Answers)
        • Tutorial 5 - Using Liquid to run GraphQL queries on your Site
        • Tutorial 6 - Variables
        • Tutorial 6 - (Answers)
        • Tutorial 7 - Sorting
        • Tutorial 8 - Building a Liquid API GET Endpoint Page powered by GraphQL queries
        • Tutorial 9 - Using Mutations to Create New Records
        • Tutorial 10 - Using Mutations to Edit a Record
        • Tutorial 11 - Using Mutations to Delete an Item
        • Tutorial 12 - Related Records and Datasources
    • Configuration
      • ℹ️Field Types
      • ℹ️Custom Field IDs
    • Zapier Integration
      • ℹ️Formatting arrays correctly
    • Developer Marketplace
      • ℹ️About Building Modules
      • ℹ️Module Setup
      • ℹ️Site Template Modules - and How to Make Your Own
      • ℹ️Create Folder Structure
      • ℹ️Updating Modules
      • ℹ️Submit Module for Approval
      • ℹ️Adding Payment to a Module
      • ℹ️Theme Module Example
      • ℹ️Data & UI Module Example
      • πŸ’»Reference
      • 🌳File Structure
    • Release Notes
      • πŸ›³οΈSiteglide Admin/API - Changelog
      • πŸ›³οΈModule - System Files - Changelog
      • πŸ›³οΈModule - eCommerce - Changelog
      • πŸ›³οΈModule - Menu - Changelog
      • πŸ›³οΈModule - Slider - Changelog
      • πŸ›³οΈModule - Secure Zones - Changelog
      • πŸ›³οΈModule - FAQ - Changelog
      • πŸ›³οΈModule - Events - Changelog
      • πŸ›³οΈModule - Blog - Changelog
  • SiteBuilder
    • Build Sites Faster
      • πŸš€Quickstart: SiteBuilder
      • About
      • Site Setup
        • πŸ—οΈMarketplace Themes & Templates
        • πŸ—οΈCreate Site From Template
        • πŸ—οΈInstall SiteBuilder Module
        • πŸ—οΈCreate a Page Template
        • πŸ—οΈSet Up Tailwind CSS with the recommended CLI method
      • Styling
        • πŸ—οΈEditing Tailwind CSS using the recommended CLI method
        • πŸ—οΈTailwind CSS Themes - Choosing a Build Method
        • πŸ—οΈTailwind CSS - Preview Mode
        • πŸ—οΈTailwind's JIT Compiler Via CDN (deprecated)
        • πŸ—οΈTheme Presets
        • πŸ—οΈExample Tailwind Project Setup
      • Layouts
        • πŸ—οΈInsert Static Layouts
        • πŸ—οΈInstalling Dynamic Layouts
        • πŸ—οΈEditing Dynamic Layouts
        • About Layouts
          • πŸ—οΈDynamic Layouts
          • πŸ—οΈStatic and Dynamic Form Layouts
          • πŸ—οΈSliders
      • πŸ’»Reference
    • Advanced Features
      • 🧞SiteBuilder Live Updates API
        • πŸ‘€Live Updates Reference
        • πŸ”ΉLive Updates Markup Example
        • πŸ“‹Steps to Setting Up Live Updates API in a Module/WebApp Layout
        • πŸ”ΉLive Updates Example - Enforcing Filters
        • πŸ“‹Steps to Use Live Updates Methods
        • πŸ“‹Steps to Initialise Live Updates with JS
        • πŸ—“οΈLive Updates Changelog
      • ℹ️SiteBuilder JavaScript
        • ℹ️Forms JS
        • ℹ️Social Sharing JS
        • ℹ️Sliders JS
        • ℹ️Dark Mode JS
        • ℹ️Cookie Settings JS
      • ℹ️SiteBuilder Liquid Includes
        • ℹ️Pagination
      • ℹ️SiteBuilder Liquid Functions
        • ℹ️Detail Page Valid
        • ℹ️Field Mapping
        • ℹ️Get Table Config
        • ℹ️Case From Order ID
      • πŸ—“οΈSiteBuilder Changelog
    • Extend SiteBuilder
      • ℹ️Create SiteBuilder Themes
      • ℹ️Create Marketplace Modules
      • ℹ️Adding Dynamic Layouts to Themes & Modules
      • ℹ️Adding Static Layouts to your Theme
      • πŸ’»Reference
  • CMS
    • Dashboard
    • Pages
      • πŸš€Quickstart: Pages
      • ℹ️Studio
      • ℹ️Code View & Toolbox
      • ℹ️About Pages
        • ℹ️Page Settings
        • ℹ️Custom Fields in Pages
        • ℹ️Pages with Siteglide CLI
      • ℹ️About Page Templates
        • ℹ️Page Templates with Siteglide CLI
        • Preventing Duplicate Content
      • ℹ️System Pages
      • πŸ’»Reference
      • 🌳File Structure
    • Content Sections
    • File Manager
      • πŸ”ΉAbout Assets
      • πŸ”ΉLinking to Assets Explained
      • πŸ”§Assets Troubleshooting
      • πŸ”ΉSiteglide Scripts Explained
      • πŸ’»Assets with CLI
      • πŸ”ΌMigrating Assets
      • πŸ“‹Steps to Optimise Images on the Fly with Cloudinary
      • πŸ”Ήsiteglide_head_scripts and siteglide_footer_scripts Explained
      • 🌳Assets File Structure
      • πŸ‘€Tags for Assets
    • Forms
      • Quickstart: Forms
      • ℹ️About Forms
      • πŸ“‹Guides: Forms
        • πŸ“‹Steps to Using Separate Fields for First Name and Surname in a Form
        • πŸ“‹Steps to Programmatically Redirecting after a Form Submission
        • πŸ“‹Steps to Adding Form Confirmation Pages
        • πŸ“‹Steps to Adding a Progress Bar
        • πŸ“‹Steps to Changing Form Styling on Submission Using CSS
        • πŸ“‹Steps to Using Custom Field Set fields in a Form's Custom Layout
      • πŸ§™β€β™‚οΈGo Further: Forms
        • ℹ️Migrating Forms
        • ℹ️Explained - Preventing Spam Form Submissions and Captchas
        • ℹ️Explained - Show Clearly When a User is Already Logged in When Submitting a Form
        • ℹ️Forms Error Callback and Validation
        • ℹ️Forms Success Callback
        • ℹ️File Upload Previews
      • 🌳Forms File Structure
      • πŸ’»Reference
      • ❔Troubleshooting
    • Automations
      • πŸš€Quickstart: Automations
      • ℹ️About
        • ℹ️Email Templates
        • ℹ️Email Automations and Email Templates with Siteglide CLI
      • πŸ“‹Guides
        • ℹ️Integration Automations
        • ℹ️A Transactional Email Example
        • ℹ️An API Call Action Example
        • ℹ️A Custom Liquid Action Example
        • πŸ“‹Steps to Testing Emails on a Staging Site
        • πŸ“‹Steps to Authenticating Sendgrid Emails on Live Sites
      • πŸ§™β€β™‚οΈGo Further
      • πŸ’»Reference
      • 🌳File Structure
    • Categories
      • πŸš€Quickstart: Categories
      • ℹ️About
        • ℹ️Outputting Categories on WebApp / Module / eCommerce Layouts
        • ℹ️Filtering WebApps and Modules by Categories Using Liquid Parameters
      • 🌳File Structure
      • πŸ’»Reference
    • Company Information
      • ℹ️About
      • πŸ’»Reference
      • ❔Troubleshooting
    • URL Redirects
  • Modules
    • Core Modules
      • MenuBuilder
        • πŸš€Quickstart: Menu Builder
        • ℹ️About
      • Secure Zones
        • πŸš€Quickstart: Secure Zones
        • ℹ️About
          • πŸ“‹Dynamically Assign a Secure Zone during Form Submission
        • πŸ§™β€β™‚οΈGo Further
          • ℹ️Secure Zones with Siteglide CLI
          • ℹ️Using the context.current_user object
      • Media Downloads
        • πŸš€Quickstart: Media Downloads
        • ℹ️Layouts
        • πŸ’»Reference
      • Blog & Authors
        • πŸš€Quickstart: Blog & Authors
        • πŸ”ΉBlog Archive & Date Filtering
        • πŸ”ΉBlog Search
        • πŸ”ΉBlog Filter by Category
        • πŸ”ΉBlog Filter by Author
        • 🌳File Structure
        • πŸ’»Reference
      • Events
        • πŸš€Quickstart: Events
        • ℹ️Standard List View
        • ℹ️Getting Started with Event Filtering & Searching
        • ℹ️Filter by Category
        • ℹ️Filter By Host (Author)
        • ℹ️Filter by Event Dates
        • ℹ️Datasourcing the Event Host
        • ℹ️Search
        • ℹ️Map List View
        • ℹ️Calendar List View
      • FAQ
        • πŸš€Quickstart: FAQ
        • πŸ’»Reference
      • Testimonials
        • πŸš€Quickstart: Testimonials
        • πŸ’»Reference
      • Slider
        • πŸš€Quickstart: Slider
        • πŸ’»Reference: Slider
    • Community Modules
      • πŸ—οΈSiteBuilder
      • πŸš€CRM Sync
        • ℹ️About CRM Sync Module
        • πŸ“‹Steps to Set Up CRM Sync on an Automation
        • πŸ—“οΈCRM Sync Changelog
    • Go Further: Modules
      • ℹ️Front-end Submit Modules
  • WebApps
    • πŸš€Quickstart: WebApps
    • WebApp Items
      • πŸ“‹Create WebApp Items
      • πŸ“‹Importing and Exporting
    • Layouts
      • ℹ️WebApp List Layout
      • ℹ️WebApp Detail Layouts
    • Go Further: WebApps
      • πŸ“‹Searching by Location
      • πŸ“‹Searching - Advanced Filtering
      • πŸ“‹Searching - By Keyword
      • πŸ“‹Front End Create Forms
      • πŸ“‹Front End Update Forms
      • πŸ“‹Front End Delete
  • WebApp Troubleshooting
  • eCommerce
    • πŸš€Quickstart: eCommerce
    • Get Started
      • πŸ’‘About the eCommerce Module
      • Settings
      • πŸ“‚Cart, Checkout and Quotes
        • πŸ’‘About Cart, Checkout and Quotes
        • πŸ“‹Steps to Implement a Guest Checkout Flow
        • πŸ“‚Product Views
          • πŸ”ΉProduct Layouts
          • πŸ”ΉProduct List Layout
          • πŸ”ΉProduct Detail Layout
          • πŸ”ΉAdd to Cart Button
          • πŸ“‹Steps to Datasource and Display Related Products
          • πŸ”ΉDynamic Product Layouts based on Categories
          • πŸ“‚Attribute Selection
            • πŸ”ΉAttribute Layout - Presenting the Choice to the Customer
            • πŸ”ΉAttributes - Changing Product Price after Change
          • πŸ“‚Discount Selection
            • Discount Codes Layout
            • Minimum Payments
          • πŸ“‚Shipping Selection
            • Shipping Options Layout
        • Managing Products
          • Creating and Editing
          • Securing Products
          • Location
          • Custom Fields
          • Edit Module Structure
          • Product Custom Field Sets
          • Inventory
          • Managing Attributes
          • Pricing
          • Product Categories
          • Open Graph Fields
          • SEO Fields
          • Standard Fields
          • Product Import and Export
          • Discounts
        • πŸ“‚Cart
          • πŸ”ΉCart Layouts
          • Checking Inventory in Cart
          • Updating Quantity in Cart
          • Updating Displayed Cart Quantity
        • πŸ“‹How to Set Up a Shopping Cart and Guest Checkout - Tutorial
        • πŸ“‚Checkout Forms
          • πŸ”ΉCheckout Form Layouts
          • πŸ”ΉCheckout Forms with PayPal
        • πŸ“‚Orders
          • Order Confirmation
          • Re-Ordering
          • πŸ”ΉOrders Layouts
        • πŸ“‹Steps to Add Secure Zones and User Orders View to your Checkout Flow
        • Quotes
        • Selling Digital Products
        • πŸ”ΉVolume Pricing
        • πŸ“‹Steps - Alternatives to Product Grouping
      • πŸ“‚Basic Payment Forms
        • πŸ’‘About Basic Payment Forms
        • πŸ“‹Steps to Set up a Basic Payment Form (with a Fixed Payment Amount)
        • πŸ“‹Authorize.net Basic Payment Forms
        • πŸ“‹PayPal Basic Payment Forms
        • πŸ“‹Steps to Allow User to Decide Amount they Will Pay
        • πŸ“‹Step-by-step Basic Payment Confirmations
        • πŸ‘€Basic Payment Forms Reference
        • ℹ️ecommerce/basic_payment
      • πŸ“‚Payment Gateways
        • πŸ’»Building a Custom Payment Gateway
          • πŸ“‹Steps to Support Basic Payment Forms with your Custom Payment Gateway
          • πŸ“‹Steps to Support Checkout with your Custom Payment Gateway
        • πŸ”ΉPaypal Custom Parameters
        • πŸ”ΉStyling Stripe Card Elements
        • πŸ’‘About Payment Gateways
        • πŸ“‹Steps to Switching Payment Gateway
        • πŸ”ΉTest Cards
      • πŸ“‚Currency and Tax
        • πŸ’‘About Tax Codes
        • Currency Changer
        • Tax Code Changer
        • Formatting Currency
      • πŸ“‚Subscriptions
        • πŸ’‘About Subscriptions
        • Managing Subscriptions
          • Creating Subscription Products
          • Changing Price and Billing Interval
          • Creating a Form for Signing Up and Changing Payment Details
          • Subscription Order Status Explained
          • Terms and Conditions (Good Practice)
        • πŸ“‹Subscriptions Payment Gateway Setup
        • Subscriptions List Layout
        • Subscriptions Detail Layout
        • User's Active Subscriptions
        • Subscription Action Required
        • Cancelling Subscriptions
      • 🌳Basic Payment Forms Folder Structure
      • 🌳Cart and Checkout Folder Structure
  • CRM
    • πŸš€Quickstart: CRM
    • Users
      • User Details
      • User Secure Zones
      • How Users Edit their Email and Password Front End
      • Custom Field Sets & CRM Custom Fields
      • Storing User's Favourite WebApp / Module Items
    • Companies
    • Cases
      • User's Form Submissions (Cases)
  • Site Manager
    • Code Editor
    • Templates (Pages & Email)
    • Headers & Footers
    • Code Snippets (Includes)
      • πŸ”§Includes Troubleshooting
      • πŸ‘€constants_json
      • πŸ‘€constants
      • 🌳Includes File Structure
      • πŸ’»Includes with Siteglide CLI
      • πŸ”§Tags for Includes
    • System Pages
      • Automatic Site Maps
    • System Emails
    • Data Management
    • Admin Menu Editor
    • Integrations
  • Reporting
    • πŸš€Quickstart: Reports
  • Miscellaneous
    • System Features
      • Pagination on Liquid Tags
      • Custom Pagination Layouts
      • Timezones in the Siteglide Admin and on the front-end of your Site
      • Module/WebApp Caching
      • Getting Started with Liquid Caching - to Reduce Server Response time and Improve Performance
      • Translating Dates
      • Site Search
      • About Site Search
      • AI Tools for the Rich Text Editor
      • Cookies on Siteglide Sites
    • Front-End Performance
      • Video Embeds
      • Forms Above the Fold
Powered by GitBook
On this page
  • Prerequisites
  • Introduction
  • Folder Structure
  • Creating a new set of Product Layouts
  • Including a Single Known Attribute on a Detail Page
  • Looping Over Multiple Attributes
  • Steps:
  • Full example:
  • Attribute Layout Development

Was this helpful?

Export as PDF
  1. eCommerce
  2. Get Started
  3. Cart, Checkout and Quotes
  4. Product Views
  5. Attribute Selection

Attribute Layout - Presenting the Choice to the Customer

PreviousAttribute SelectionNextAttributes - Changing Product Price after Change

Last updated 1 month ago

Was this helpful?

Product Attribute Layouts allow you to customise the way that you present users with a choice of which variation of a Product they want.

Product Attribute Layouts allow you to customise the way that you present users with a choice of which variation of a Product they want.

Prerequisites

  • You have in the Admin

  • You have

Introduction

This Tutorial will show you how to use Attributes to let Users pick Variants on the Product's automatically-generated Detail Page.

It will cover how to:

  • Find where Product layouts are stored on Code Editor

  • Develop a my_attribute_layout.liquid file

  • Allow the User to select Attribute Options before adding to Cart

Folder Structure

In SITE MANAGER/Code Editor, the folder structure for product attributes layouts is as below:

marketplace_builder
└───views
    └───partials
        └───layouts
            └───modules
                └───module_14
                    β”œβ”€β”€β”€product
                    β”‚   collection.liquid
                    β”‚   └───custom_product_layout
                    β”‚       β”œβ”€β”€β”€detail
                    β”‚       β”‚   item.liquid
                    β”‚       β”‚   wrapper.liquid
                    β”‚       └───list
                    β”‚           item.liquid
                    β”‚           wrapper.liquid
                    └───product_attributes
                        └───custom_attributes_layout.liquid

See a more complete Cart & Checkout Folder Structure here:

Creating a new set of Product Layouts

To create a new set of Product layouts- create your folder at the level of "name_of_my_layout". Inside that, the folders and files should be created as shown above.

Including a Single Known Attribute on a Detail Page

If you are making a layout where you know exactly which Attribute a Product has, you can include an Attribute layout to display an Attribute with a given name: detail/item.liquid (including a single Attribute)

{% include 'ecommerce/product_attributes'
   name: attribute
   layout: 'demo_site_attributes'
   attribute_name: "Size" 
-%}

Looping Over Multiple Attributes

If your Products have multiple Attributes, or you want to write code which can dynamically display any Attribute given to the Product, you can use liquid to loop over all Attributes. We've recently updated this example to be much simpler and easier to use.

Steps:

  1. Loop over all Attribute Options

  2. Check if the Attribute is enabled

  3. If so, include the relevant Attribute layout, dynamically filling in the "name" parameter.

Full example:

detail/item.liquid -- (looping over all Attributes linked to this Product)

{% for attribute in this.product_attributes %}
  {% if attribute.properties.enabled == true %}
    {% include 'ecommerce/product_attributes'
       name: attribute.properties.name
       layout: 'demo_site_attributes' 
    -%} 
  {% endif %}
{% endfor %}




Attribute Layout Development

There is no need to create a wrapper file for Attributes, as they are already included inside an item.liquid file. Your Attribute layout can be given a name of your choice. Different Attributes for the same Product may use different Attribute layouts, e.g. "Colour" may include colour swatches.

You can output the name of the Attribute that the current Layout displays: {{this_attribute.properties.name}}

The following liquid outputs an array of the options that have been created for this Attribute: {{product_attribute_options}}

You can loop over this array with the following liquid code, (where the example has the variable "option", you could choose any variable name):

{% for option in product_attribute_options -%}
  {{option.name}} ({{this.price.currency_symbol}}{{option.price}})
{% endfor %}




To get the full benefits of Attribute functionality, including the user's choice of Attribute affecting what is added to the Cart, the data-attributes and function calls in the example should be included:

<select name="attr1" class="form-control" data-attribute-control="{{product_attribute_id}}" onchange="s_e_update_price()">
  
{% for option in product_attribute_options %}
    <option value="{{option.id}}" data-attribute-price-control="{{option.price_raw}}">
      {{option.name}} {{this.price.currency_symbol}}{{option.price}})
    </option>
  {% endfor %}
</select>

As you can see in the example, inside the loop it is possible to access the specific Attribute Option in this iteration via the "option" variable you created when setting up the loop, but you can also still access the "this" object specific to the Detail Layout that wraps around and includes the Attribute Layout. See the to see the fields available in the "this" object and those specific to Attributes and Attribute Options.

πŸ“‚
πŸ“‚
πŸ“‚
πŸ”Ή
created Products
created a Product Detail View
🌳Cart and Checkout Folder Structure
Product Layout Liquid Reference