Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Navigate to Advanced Content --> Custom Widgets.
  2. Click 'Add New Widget'.
  3. Give the widget a Name and Description (e.g. UOM Selector).
  4. Leave the Cache Mode set to 'None'. 
  5. Paste the code from the code block below into the 'Source Code' field. 
    Image Added 
  6. Click 'Save & Exit'. 
  7. Navigate to Content --> Standard Pages
  8. Select the Product Detail template. 
  9. In the zone MainRight, click Add Widget.
  10. Search 'CUS' to bring up the list of your custom widgets. 
  11. Select the one you just created and click Add Widget

    Code Block
    collapsetrue
    @if (((IDictionary<String, Object>)Model).ContainsKey("item")) {
        if (Model.item.Count > 0) {
    		if (Model.item["RandomWeight"].ToString() == "1") {
          		<span class="widget-productlist-unit">Approx. @Model.item["ConversionFactor"].ToString("N2") @Model.item.UnitDescription.ToString() per Unit</span><br \>       
    			<span class="widget-productlist-unit">UNITS per CTN: @Model.item["ItemsPerCtn"].ToString("N0") </span>       
          	} else {
          		<span class="widget-productlist-unit">@Model.item["ConversionFactor"].ToString("N2") @Model.item.UnitDescription per @Model.item.AltUnitDescription</span><br /><br />
          	}
        }
    }
    
    @if (((IDictionary<String, Object>)Model).ContainsKey("Product"))
    {
        if (Model.Product.Count > 0) {    
    		  if (Model.Product["RandomWeight"].ToString() == "1") {
              <span class="product-info">&nbsp;
                  <span><strong>Approx. @Model.Product["ConversionFactor"].ToString("N2") @Model.Product.UnitDescription per Unit</strong></span>
              </span>        
    		  } else {
              <span class="product-info">&nbsp;
                  <span>@Model.Product["ConversionFactor"].ToString("N2") @Model.Product.UnitDescription per @Model.Product.AltUnitDescription</span>
              </span>        
          }
        }
    }

...