In Dynamicweb, you can create product units – like kilo, pair, and box – and let customers choose between ordering e.g. a pack, a box and a pallet of pencils. On each product you can then define precisely what is in a box for that product. Then, when the customer adds a box of pencils to cart and buys it, the correct number of pencils will be subtracted from the stock level of the product.
To create a product unit:
- Go to Settings > Ecommerce > Product Catalog > Product units
- Click New product unit in the toolbar
- Provide a name for the product unit
You can only create new product units when the default ecommerce language is selected in the toolbar. It can then be localized to other ecommerce languages by changing the language context and saving the product unit with a localized name. If you do not localize a product unit, no label will be rendered in frontend for that product unit in that language context. Read more about ecommerce languages here.
You can only create new product units when your default language is selected in the toolbar.
Once a product unit has been created, you can create language-specific version of it by changing the language and saving the product unit in the new language.
If you don’t, no unit category label will be rendered in the frontend for that language. Read more about languages in Dynamicweb.
Adding units to a product
The product units you create here are not automatically available in frontend for all products – which is good, because not all products are sold in a box, you know – but must be explicitly added to each product manually or as a part of an integration. There are two reasons for this:
- Not all products are sold in all units – a box of beer is called a crate and you don’t buy a six pack of socks
- The contents of a box can vary wildly from product to product – a box of socks doesn’t contain the same number of items as a box of pencils
To add units to a product:
- Go to PIM or Ecommerce and open a product
- Click the Units button in the toolbar
- Create a base unit – this could be piece, box or bottle, depends on the product
- Create additional units and define how many of the base unit each product unit corresponds to
Once you’ve specified which units are available for a products you can add unit stock via the stock matrix – which will make them available in your templates
Pricing product units
Product units are priced using the price matrix – which works in the same manner as the stock matrix, in that you create an entry for each combination of product unit, currency, variant, etc.
Adding units to cart
To add a specific unit to cart use a cart command with the UnitId parameter – here’s an example using the add-command from a ProductViewModel template.