UGC Techdocs
  • Introduction
  • Guides
    • Analytics
      • Tracking UGC on Adobe Analytics
      • Tracking Widget interactions with Google Analytics
    • Direct Uploader
      • How to add Custom Data to Direct Uploader
      • How to capture Custom Data on Direct Uploader
      • How to automatically tag data on Direct Uploader
      • How to Customize error messages on Direct Uploader
      • How to Track Direct Uploader form submissions with Google Analytics (Universal & GA 4)
    • Data Templates
      • Creating a Data Template
    • Rights via Registration
      • Capture Custom Data on Rights by Registration Form
      • Styling Rights via Registration Form
    • REST API
      • Caching REST API results for optimization
      • Posting content into Nosto via Tile API
      • Posting images into Nosto via Tile API
    • Onsite Widgets (2.0)
      • Blank Canvas
        • How to Use the Blank Canvas to Create a Twitter Count Widget
        • Creating an Auto-Scrolling Carousel using Blank Canvas
        • Creating Gallery Widget by Using the Blank Canvas Widget
        • Creating a simple Hover effect using Blank Canvas
        • Creating a Word Cloud using Blank Canvas
        • Creating Your Widget by Using the Blank Canvas
      • Bind your own Events
      • Creating a Grid Widget from Waterfall
      • Create a Q&A Widget using Data Templates
      • Displaying a Widget in a Mobile App
      • Dynamically Specify Products to Display in Widget
      • Dynamically specify what Tile to display in a Widget
      • How to add a title / subtitle to a widget
      • How to localize the load more button on widgets
      • How to overlay existing Google Map with the UGC Map Widget
      • Styling cross-sellers on Grid and Carousel Widgets
      • How to Load External JS and CSS into Widgets
      • Profiling Widget Performance
      • Re-targeting with Widgets and Facebook Pixel
      • Render Widget filters dynamically
      • Styling Carousel Widget
      • Styling Grid Widget
      • Styling Masonry Widget
      • Styling Waterfall Widget
      • Styling Widget Expanded Tile
      • Styling Widget Shopspots
      • Using Web Fonts in Widgets
    • Digital Screens
      • Customizing Carousel Event Screen
      • Customizing Mosaic Event Screen
      • Customizing Scrollwall Event Screen
      • Customizing the Mosaic Event Screen to Have 9 Even Tiles
    • Email
      • Adding Location to an Email Tile
      • Styling the Email Widget
    • Integrations
      • DoubleClick
        • UGC Ads with Nosto and Google DoubleClick
      • Zapier
        • Consuming UGC Webhooks via Zapier
      • Mailchimp
        • Bring Social Content into a Mailchimp Campaign
    • Webhooks
      • Trigger notifications when content is in the moderation queue
  • Widgets
  • API Docs
    • JavaScript API
      • Widgets
        • Introduction
        • API Reference for Content Widgets
        • API Reference for Blank Canvas
        • API Reference for Map Widget
      • Digital Screens
        • Introduction
        • API Reference
    • Content API
      • Reference
    • REST API
      • Reference
        • Filters API
        • Moderation Views API
        • Tags API
        • Terms API
        • Tiles API
        • Users API
        • Widgets API
        • Automation Rules API
        • REST API Reference Widgets style and config
      • Best Practices
    • Webhooks
  • Enterprise Tools
    • Automation Rules
      • Triggers
      • Actions
      • Samples
    • Data Templates
    • User Access Control (UAC)
    • Single Sign On (SSO)
    • Enterprise Admin User Interface (EAUI)
    • Zapier
  • Commerce Tools
    • Product Feeds
    • Widget Implementation
    • Reporting
    • Integrations
      • Google Tag Manager
      • Magento
      • SalesForce Commerce Cloud
      • Shopify
      • Shopify Add To Cart
        • Global Variant Mapping for Add to Cart
        • Customise Add to Cart Widget Experience
  • Analytics
    • Google Analytics 4
      • Getting Started
      • Widgets Events
      • E-commerce Events
      • Email Events
  • Terms of Use
Powered by GitBook
On this page
  • Overview
  • Developer Guide
  • Before you get started...
  • Default Add to Cart Widget Experience
  • Note
  • Enable Add to Cart Feature
  • Customising CSS Properties of the Add To Cart Functionality
  • Example customization
  • Changing the structure of the variant selectors
  • Customising The Add To Cart Error / Success Messages
  • Customising The Add To Cart Button Text
  • Using partial color matches
  • Customising Color Variant Selection for individual Widgets
  • Adding Shopify Add To Cart To Blank Canvas Widgets

Was this helpful?

  1. Commerce Tools
  2. Integrations
  3. Shopify Add To Cart

Customise Add to Cart Widget Experience

PreviousGlobal Variant Mapping for Add to CartNextAnalytics

Was this helpful?

Overview

Shopify Add To Cart is a feature that allows you to create a seamless shopping experience for your customers by allowing them to add products to their cart directly from your UGC Widgets.

Developer Guide

This guide should assist you with basic customization of the Shopify Add To Cart functionality. We will continue to update this guide with more customization options as they become available.

Before you get started...

Default Add to Cart Widget Experience

Our Widget templates come with a default Shopify Add to Cart experience, which can be used as-is. See the below example of the default experience for each widget template:

Slider Widget

Quadrant Widget

Nightfall Widget

Story Widget

Waterfall, Direct Uploader, Grid, Masonry and Carousel Widgets

Note

When customizing UGC widgets, Javascript & CSS codes are modified within the custom code editor of the widget. The section should be 'Expanded Tile'.

Enable Add to Cart Feature

For the widget to show the Add to Cart experience make sure you enable the setting by going to:

  • Expanded Tile Configuration

  • Select the Shopify Add to Cart option

  • Click Preview and Save

Customising CSS Properties of the Add To Cart Functionality

The following elements can be customized using our predefined selectors. This can be added to our UGC code editor.

.ugc-add-to-cart-button Utilised to customize the Add To Cart button

.ugc-add-to-cart-colorpicker-text Utilised to customize the text of the color picker

.ugc-add-to-cart-colorpicker-ring Utilised to customize the container for the ring of the color picker

.ugc-add-to-cart-colorpicker-ring-after: Utilized to customize the ring of the color picker

.ugc-add-to-cart-colorpicker Utilised to customize the container for the color picker

.ugc-add-to-cart-colorpicker-inner Utilised to customize the inner container for the color picker

.ugc-add-to-cart-other-variant-selector Utilised to customize the container for the other variant selector

.ugc-add-to-cart-size picker Utilised to customize the container for the size picker

.ugc-add-to-cart-sizepicker-btn Utilised to customize the button for the size picker

.ugc-add-to-cart-price Utilised to customize the price of the product

.ugc-add-to-cart-container Utilised to customize the container for the add-to-cart functionality

Example customization

If you wish to change the border of the variant selector to be a square instead of a circle, you can modify the existing border-radius.

For example:

```css
.ugc-add-to-cart-colorpicker-ring:after {
    border-radius: 0;
}

.ugc-add-to-cart-colorpicker-ring {
    border-radius: 0;
}

.ugc-add-to-cart-colorpicker-inner {
    border-radius: 0;
}
```

Changing the structure of the variant selectors

If you wish to move the parent divs around or add custom HTML between the components, you can utilize the following code in the UGC Widget Expanded Tile code editor and modify it as required.

    window.ugc.options.shopify = {
        rawTemplate: `
        <div data-component="color-variant-picker"></div>
        <div data-component="size-variant-picker"></div>
        <div data-component="other-variant-picker"></div>
        <div data-component="add-to-cart-button"></div>
        `
    }  

For example, I may wish to add a div around the color-variant-picker so I can decorate it a bit differently, I can do this by doing so.

    window.ugc.options.shopify = {
        rawTemplate: `
        <div id="my-variant-selector">
            <p>Test!</p>
            <div data-component="color-variant-picker">
            </div>
        </p>
        <div data-component="size-variant-picker"></div>
        <div data-component="other-variant-picker"></div>
        <div data-component="add-to-cart-button"></div>
        `
    }  

This will enable the addition of the 'Test!' text between variant selectors, and will also create the my-variant-selector div around the color-variant-picker.

Customising The Add To Cart Error / Success Messages

If you would like to modify the error / success messages that are displayed when adding a product to the cart, you can do so by adding the following code to the UGC Widget Expanded Tile code editor.

    window.ugc.options.shopify = {
        successTitle: ‘Great! ’,
        successMessage: ‘Item has been added to cart.’,
        errorTitle: ‘Uh oh!’,
        errorMessage: ‘Item has not been added to cart.’
    }

Customising The Add To Cart Button Text

If you would like to modify the text associated with the add to cart button, you can do so with the following:

    window.ugc.options.shopify = {
        addToCartButtonText: ‘Add To Cart’
    }

Using partial color matches

By default, our color variant picker has a strict matching algorithm. This means that if you have a color variant named 'Black' and a color variant named 'Black Navy', the color variant picker will not match the 'Black' variant. However, if you wish to use partial matching, you can do so by adding the following code to the UGC Widget Expanded Tile code editor.

    window.ugc.options.shopify = {
        usePartialColorMapping: true
    }

By default, we provide a list of 1000+ colors which we can default to, this can be helpful to match to those colors loosely.

Customising Color Variant Selection for individual Widgets

Adding custom color swatches to your variant selectors is a great way to make your UGC Widgets stand out and enhance the customer's experience.

By default, the widgets will use what's configured in the Global Mapping settings. However, within the Widgets' Custom Code Editor, you can add the following code to your Javascript section to add custom color swatches to your variant selector for a specific widget.

window.ugc.options.shopify = {
  mappings: {
    "colors": [
        {
            "name": "Celeste Olive Mix",
            "displayName": "Olive Mix",
            "value": "https://images.ctfassets.net/09hbx69ra4p2/7DQrNNXRhl02EDxhOmNtlW/830408f2ac9bfa5c44dbe63f07ab53ab/swatch_solids-ankle-8pk-fa23-celesteolivemix.png"
        },
        {
            "name": "Black navy mix",
            "displayName": "Black Navy Mix",
            "value": "#e6e6e6"
        }]
    }
};

Note the Celeste Olive Mix Color and how it utilizes an image as the value. This is how you can add custom image icons to your color swatches.

However, if you wish to map a color instead of utilizing a custom image, you can add the hexadecimal value of the color instead, as shown in the black navy mix.

If you wish to change the label of the mapping, you can utilize the "displayName" property. This is how it will be displayed, but will default to the name property value.

Adding Shopify Add To Cart To Blank Canvas Widgets

In-order to load add to cart on a blank canvas widget, you will need to load this JS file in your widget: https://stackla.com/media/js/dist/shopify-add-to-cart.bundle.js

Once this JS file is loaded, you will need to create an element to store their add-to-cart content: i.e.

Once that is complete, you will need to invoke the following method on your code, targeting your newly created element: window.ugc.renderShopifyToDOM(stacklapopup-add-to-cart-${product.id}, mapping);

The mapping variable is utilized in the same way the settings above are, you can use this to customize the add-to-cart functionality.