Developer forum

Forum » Ecommerce - Standard features » Configurable product with optional add-ons

Configurable product with optional add-ons

John Broers
Reply

I’m working on setting up a configurable product in Dynamicweb 9.

Example: a shirt where the customer can choose optional add-ons for an extra cost, such as a printed text or an extra badge. The user should be able to select none, one, or multiple options.

I tried setting this up with a PartsList, using products for these add-ons and setting the price of the main product to “Calculated Price.” However, this automatically adds all add-ons to the cart by default. I also tried setting it up with a PartsList Group, but if I add just the main product to the cart, it automatically adds the first option from the group as if one is always required.

What I’d like instead is for only the add-ons the customer actively selects to be added and if none are selected, then only the main product should go into the cart.

Has anyone dealt with this scenario before, and what’s the best practice in Dynamicweb for handling optional add-ons?

 

BR,

John Broers


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi John,

 

You can likely do this using the PartsList Group, but have to either:

  1. Update the templates to use the "None"/"Nothing selected" accordingly
    OR
  2. Create a dummy "None" product within each PartsList Group
    (so it's adding a product that costs 0)

 

Option 2 gets you there "easily", but Option 1 is cleaner in my opinion (no need for dummy products - but requires a bit more templating and testing)

 

BR,

Nuno Aguiar

 
John Broers
Reply

Hi Nuno,

Thank you for your reply and suggestions.

I agree option 1 sounds cleaner. Is there an example of how to implement the None/Nothing selected option into the template using the cartcmd add function? I set up some example code with a product that has two configuration groups. When I submit the form with both select groups empty (Value=""), a product for each group still gets added as a BOM orderline:

<form action="" method="post">
    <input type="hidden" name="productid" value='@GetValue("Ecom:Product.ID")' />
    <input type="hidden" name="cartcmd" value="add" />
    <input type="hidden" name="quantity" value="1" />

    @foreach (LoopItem bomGroup in GetLoop("BOMConfigurators"))
    { 
        <label>
            <h4>@bomGroup.GetValue("Ecom:Product.Configurator.Name")</h4>
            <select name='@bomGroup.GetValue("Ecom:Product.Configurator.ID")'>
                <option value="">@bomGroup.GetValue("Ecom:Product.Configurator.NoneSelected.Text")</option>
                @foreach (LoopItem bomProduct in bomGroup.GetLoop("ConfiguratorProducts"))
                {
                    <option value='@bomProduct.GetValue("Ecom:Product.ID")'>
                        @bomProduct.GetValue("Ecom:Product.Name")
                    </option>
                }
            </select>
        </label>
    }

    <button type="submit">Buy now</button>
</form>

Submitted form data: productid=PROD149&cartcmd=add&quantity=1&PRODITEM32=&PRODITEM33=

Even when I completely remove the PRODITEM32 and PRODITEM33 parameters, products still gets added as a BOM orderline. I attached a screenshot of my PartsList configuration.

BR,

John Broers

OptionalPartsList.png
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi John

When using items, you get all of them. When you use a group, you can only select one of them. So if the user should be able to only choose one add-on, use the group, if they need to be able to add more of them, use single items.

When you add a group to a bom product, the products in that group acts as the options. So you can add a 'product' called none with a 0 price. When you add the group you can also specify which of the products in that group should be default selected. Here you will choose the none product. But this will only work if the user can select only one add-on, and not all of them.

When adding a bundle to cart, Dynamicweb will always add one for each item - if you have not defined a default product for a BOM group, first or default will be added.

Instead you can try to override the quantity - and set that to 0:

PRODITEM32Quantity=0&PRODITEM33Quantity=0

So your template would be something like this:

<form action="" method="post">
    <input type="hidden" name="productid" value='@GetValue("Ecom:Product.ID")' />
    <input type="hidden" name="cartcmd" value="add" />
    <input type="hidden" name="quantity" value="1" />
    @foreach (LoopItem bomGroup in GetLoop("BOMConfigurators"))
    { 
        <label>
            <h4>@bomGroup.GetValue("Ecom:Product.Configurator.Name")</h4>
    <input type="hidden" name='@bomGroup.GetValue("Ecom:Product.Configurator.ID")Quantity' value="0">
            <select name='@bomGroup.GetValue("Ecom:Product.Configurator.ID")'>
                <option value="">@bomGroup.GetValue("Ecom:Product.Configurator.NoneSelected.Text")</option>
                @foreach (LoopItem bomProduct in bomGroup.GetLoop("ConfiguratorProducts"))
                {
                    <option value='@bomProduct.GetValue("Ecom:Product.ID")'>
                        @bomProduct.GetValue("Ecom:Product.Name")
                    </option>
                }
            </select>
        </label>
    }
    <button type="submit">Buy now</button>
</form>
 
Then you just have to make some logic to set quantity to 0 for none and 1 for all other items...
Votes for this answer: 1
 
John Broers
Reply

Hi Nicolai,

Thank you for your detailed explanation and the example template. I was able to get it working by adding the hidden quantity input and by adding some extra JavaScript to toggle the quantity to 0 or 1 based on the selection. Really appreciate your help!

BR,

John Broers

 

You must be logged in to post in the forum