Developer forum

Forum » Swift » When does the Unit selector show

When does the Unit selector show

Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hello,

I'm trying to understand when a unit selector will be shown in Swift_ProductAddToCart

  • I have a product, with a base unit (each) and a additional unit (box) of 10 bas units
  • For each of these units I have setup there to be a stock level > 0
  • in Swift_ProductAddToCart "Show unit selector" is checked

Couple of questions:

  • How do I get the UnitOptions for the product to be > 0? I can see that @product.UnitOptions.Count is 0, so with this line the selector will not show: if (unitsSelector && product.UnitOptions.Count > 0) {
  • What dis this variable do (bit confused because it seems to hav options "disabled" and "hide" : string whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide");

It reads a bit like units are only available if there are no variants, but that would seem strange to me.

Thanks!

Justin


Replies

 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply

Hi Justin

I may be able to answer some of your questions.

  • For the unit options to appear in the frontend, you need to configure a product with units correctly: https://doc.dynamicweb.com/documentation-9/ecommerce/product-catalog/product-units
  • If you have a Swift demo with products, you can take a look at product number 2134002640
  • And yes, the unit selector should also be enabled on the Swift_ProductAddToCart 
  • The variable "WhenVariantsExist" simply tells what should happen to the add to cart button, if the product has variants, and you need to make a variant selection before you can add to cart

Maybe this forum thread may be a help to you: https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/variants-and-units

 

Best regards
Karsten Thuen

 
Davy Capiau
Reply

Hi Karsten,

Is my understanding correct that the combination of Variant and Units is currently not supported in Swift? 

This is a core feature for our customer. We thought that it was included in Swift.

 Can you help us on how to make it happen.

 

 

You must be logged in to post in the forum