Product structure for Ecommerce functionality

I am planning to create an ecommerce functionality in WeWeb with

  • products
  • variants of products
  • cart

I don’t have many products, but the variants make it a little tricky for me.
For the cart, I found this awesome explanation by @dorilama.

My question is about how to manage products and variants best.
Let’s say I sell T-Shirts with a product structure like this:

  • Shirt A with Size S, M, L and colors Green and Blue
  • However, color blue is only available in sizes S and M, but not L.

In my thoughts, I see the requirement to work on a variant level when it comes to cart functionality.
Each variant has

  • a variant ID
  • Size
  • Color
  • Quantity
  • Reference to main product (e.g. Shirt A)

Each combination of options is a separate variant ID, which can make the product list quite long.

In WeWeb, I only want to display the Shirt-level (Shirt A, Shirt B, Shirt C, etc.) in a grid or list, with an option to select and switch between variants (via Dropdown button).

Here is where I’m stuck right now, and I see two options:

  1. I create a collection with all variants from one product table. But how do I filter this list in WeWeb, so that the grid only shows the shirt level (Shirt A, B, C, etc), and not all variants?
  2. I create 2 tables (in Xano), one with products (shirts A, B , C) and another one with variants (with colors, sizes, quantities). This way, I could easily display the product level in WeWeb. But how do I “combine” the product with the dropdown options (variants)?

This is how I would like to display a product

  • with the Title and description
  • with selectable variants

But in a datagrid:

Grateful for any help on this :pray:

What you probably might want to do is the opposite, instead of fetching all of the variants of the shirts, you might wanna fetch the shirts with a nested array of all the variants that shirt has. So it would be something like this:

[
  {
    "id": 1,
    "name" : "Fancy shirt A",
    "variants" : [
        { "id": 1, 
           // Color, Quantity etc. here
        },
        { "id": 2, 
           // ...
        }
      ]
    }
]

By doing it this way, you’ll also be able to simply input the variants[] (array) into the select dropdowns that you have in your Figma Design.

For the design (if the variants will be common for each item, or at least shared between multiple items) you might want to go with a design like this (I think Shopify has it like this - as far as I know from client projects).

In case of having variants dictated for each product, without them being shared betwen each other, you can do it like this.

1 Like

Good idea. I did that and it works well. Thanks :pray:

I was able could bind the items to the product grid flexbox and display the name of the variant 0 in the selector, and the variants (that are not 0) in the dropdown list of the product. So far so good.

Now, I’m stuck with another step.
Since the “add to cart” action (grab variant and post it into a “cart database”) needs to know which variant is currently selected, I would need some extra variable per product in WeWeb.

Question:
Is there any way I can create a variable (e.g. active_variant) as a nested element in the product array, so it repeats for each product?

If this is not possible, I would have to create as many global variables as there are products, where each variable holds the selected variant for one specific product. This variable object would update once a new variant is selected from the dropdown list. Since I only have 10 product, this would still be an option. But I’m not sure if this is the smartest way.

I think this should be doable in more than one ways. You could:

  1. make a global variable, which could hold the whole state of your “front-end” cart before you send it to Xano and get it checked.

  2. you could add it to the item as you mentioned, but this might require some little tinkering.

I usually go over these kind of things on 1:1 meetings with no-coders / founders like you. Maybe that is something you might be interested in. I see a lot of people benefiting from the more face ti face personalized approach.

Awesome, thanks. I’ll get back to you with a call booking when needed.

1 Like

I’ll be looking forward to e-meet you! And of course, talk around here :slight_smile: