Class Name

/atg/commerce/catalog/UnitOfMeasureDroplet.java

Component

/atg/commerce/catalog/UnitOfMeasure

This droplet provides fractional breakdown for specific Units of Measure (UOM) It can be used to determine if a product of SKU accepts fractional quantities. It can indicate whether the product of SKU can be sold in fractional quantities, and if it can, the configuration can provide a list of beans with values and labels for a UOM, or an increment value.

Input Parameters

unit

9/21/15 – Changed unit_of_measure to unitOfMeasure
Required. This parameter identifies the value corresponding to the unitOfMeasure property value of a product of SKU.

item
A commerce item. Indicates that the selection applies only to a specific commerce item.

product
The product whose price you are interested in, identified by a product repository item or as a product ID string.

sku
The SKU whose price we are interested in, identified by a SKU repository item, or as a SKU ID string.

language
The language of the locale used.

country
The country of the locale used.

Output Parameters

fractional
Indicates if fractional quantities are allowed.

type
This parameter indicates the type of fractional breakdown, either options or increment.

options
An ordered list of the UnitOfMeasure beans, that contains the measurements and associated labels.

increments
A decimal value that represents the quantity increments that the unit can be sold in.

errorMessage
An error message that is displayed.

output
Output is displayed with the displayElement parameter is set.

unitResource
This open parameter can render a String resource for the unit, for example, lbs or ltrs.

error
 
This parameter is rendered when an error occurs.

Examples

The following example shows the UnitOfMeasureDroplet being called with an input parameter of product ID. It renders the fractional output parameter, identifying if the product is flagged as allowing fractional quantities. It also renders the type output parameter indicating if the unit of measure is an increment or option type. Because the product uses the increment type, it renders the increment output parameter, which is a double value of what increments quantities should be supplied in:

<dsp:importbean bean="/atg/commerce/catalog/UnitOfMeasureDroplet"/>
  <dsp:droplet name="UnitOfMeasureDroplet">
    <dsp:param name="product"  param="product.repositoryId"/>
    <dsp:oparam name="output">
      <dsp:valueof param="fractional"/>
      <dsp:valueof param="type"/>
      <dsp:valueof param="increment"/>
    </dsp:oparam>
  </dsp:droplet>

The following example shows how the droplet can be used to render different logic for products that do or do not allow fractional quantities, as it can be used to decide which field to render for a form handler:

<dsp:importbean bean="/atg/dynamo/droplet/Switch"/>
<dsp:importbean bean="/atg/commerce/catalog/UnitOfMeasureDroplet"/>
<dsp:droplet name="UnitOfMeasureDroplet">
  <dsp:param name="product" param="product.repositoryId"/>
  <dsp:oparam name="output">
  <dsp:droplet name="Switch">
     <dsp:param name="value" param="fractional"/>
    <dsp:oparam name="false">
       non-fractional logic
     </dsp:oparam>
     <dsp:oparam name="true">
      fractional logic
    </dsp:oparam>
  </dsp:droplet>
  </dsp:oparam>
</dsp:droplet>

Converting Localized Number Values

When working with the UnitOfMeasureDroplet, the AddItemToCartServlet is expecting a double type input for quantityWithFraction, so all values coming into the servlet need to be converted before submitting them to the servlet.

The NumberTagConverter class performs conversion to and from number objects and can be used to convert localized values, such as 0,25 to 0.25 before passing it to the AddItemToCartServlet. The NumberTagConverter accepts the input string and Locale of the user, and converts the string to the appropriate number format.

For detailed information on the NumberTagConverter, refer to the ATG Platform API Reference.


Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices