Motorprise uses price lists to maintain the prices of different products and SKUs. Price lists allow you to target a specific set of prices to a specific group of customers. We used two types of pricing in Motorprise: list and volume. A list price is the full, undiscounted price of a product. Volume pricing determines the price based on the number of items ordered. We used two types of complex volume pricing in Motorprise:

We used two page fragments to display prices on the product template pages in Motorprise: MotorpriseJSP/j2ee-apps/Motorprise/web-app/en/catalog/DisplayPrice.jsp and MotorpriseJSP/j2ee-apps/Motorprise/web-app/en/common/DisplayComplexPrice.jsp. DisplayPrice.jsp formats and displays list prices. DisplayComplexPrice.jsp displays the detailed information of complex prices such as the number of price levels and the minimum and maximum prices at each level.

DisplayPrice.jsp is invoked to display the price of the product. We used the PriceDroplet to determine the pricing scheme used for a given product and SKU. It takes SKU and product repository items as input and gives as an output the price repository items. The price parameter contains all pricing attributes such as pricing scheme used, list price, and complex price. We used the following JSP fragment to display the price of the product:

<dsp:droplet name="PriceDroplet">
  <dsp:param name="product" param="Product"/>
  <dsp:param name="sku" param="Sku"/>
  <dsp:oparam name="output">
    <dsp:droplet name="Switch">
      <dsp:param name="value" param="price.pricingScheme"/>
      <dsp:oparam name="listPrice">
        <tr>
          <td>&nbsp;</td>
          <td><span class=smallb>Price:</span></td>
          <td>&nbsp; </td>
          <td>

We used the CurrencyConversionFormatter droplet to format the list price correctly for its locale. Notice that locale (the locale that price.listPrice is defined in) and targetLocale (the locale that we will be displaying the price for) are the same. This means that no currency conversion actually takes place, only formatting. The result is formatted correctly for Profile.pricelist.locale. If the default currency is the euro, then we use the correct currency symbol by setting the euroSymbol property.

            <%/*Display price for locale of user: */%>
            <dsp:droplet name="CurrencyConversionFormatter">
                 <dsp:param name="currency" param="price.listPrice"/>
                 <dsp:param bean="Profile.priceList.locale" name="locale"/>
                 <dsp:param bean="Profile.priceList.locale" name="targetLocale"/>
                 <dsp:param name="euroSymbol" value="&euro;"/>
                 <dsp:oparam name="output">
                   <span class=small><dsp:valueof valueishtml="<%=true%>"
                      param="formattedCurrency">no price</dsp:valueof></span>
                 </dsp:oparam>
               </dsp:droplet>

            <%/*Switch to see whether user is of German locale */%>
            <dsp:droplet name="Switch">
                     <dsp:param bean="Profile.priceList.locale" name="value"/>
                     <dsp:oparam name="de_DE_EURO">

                     <%/*Display price in DM for German users: */%>

At this point, we display the same price as before, we need to display it correctly for the German user. In this case locale and targetLocale are not the same. This means that before the result is formatted for the target locale, the currency (price.listPrice) must be converted from the default currency of de_DE_EURO to the default currency of de_DE. We mathematically calculate the value based on the exchange rates stored in /atg/droplet/ExchangeRates.properties. The result is then formatted for the de_DE locale. (In this way, the price, which is stored in euros, is displayed in Deutsch Marks.)

                     <dsp:droplet name="CurrencyConversionFormatter">
                       <dsp:param name="currency" param="price.listPrice"/>
                       <dsp:param bean="Profile.priceList.locale" name="locale"/>
                       <dsp:param name="targetLocale" value="de_DE"/>
                       <dsp:oparam name="output">
                         <span class=small>(<dsp:valueof
                            param="formattedCurrency">no price
                            </dsp:valueof>)</span>
                       </dsp:oparam>
                     </dsp:droplet>
                     </dsp:oparam>
            </dsp:droplet>
          </td>
          <td>&nbsp;</td>
        </tr>
      </dsp:oparam>

      <dsp:oparam name="bulkPrice">
        <dsp:getvalueof id="pval0" param="price.complexPrice"><dsp:getvalueof
          id="pval1" param="price.pricingScheme"><dsp:include page=
          "DisplayComplexPrice.jsp" flush="true"><dsp:param name="complexPrice"
          value="<%=pval0%>"/><dsp:param name="pricingScheme"
          value="<%=pval1%>"/></dsp:include></dsp:getvalueof></dsp:getvalueof>
      </dsp:oparam>

      <dsp:oparam name="tieredPrice">
        <dsp:getvalueof id="pval0" param="price.complexPrice"><dsp:getvalueof
           id="pval1" param="price.pricingScheme"><dsp:include
           page="DisplayComplexPrice.jsp" flush="true"><dsp:param name=
           "complexPrice" value="<%=pval0%>"/><dsp:param name="pricingScheme"
           value="<%=pval1%>"/></dsp:include></dsp:getvalueof></dsp:getvalueof>
      </dsp:oparam>
    </dsp:droplet>

  </dsp:oparam>
  <dsp:oparam name="error">
    There was a pricing error.
  </dsp:oparam>

</dsp:droplet>

In the code sample above, if the pricing scheme is a list price, it is formatted and displayed; otherwise, DisplayComplexPrice.jsp is invoked to display the complex price.

We used ComplexPriceDroplet to display the detailed information of complex prices such as the number of price levels and the minimum and maximum prices at each level. The JSP code fragment below demonstrates how we iterate through each level of the complex price and display its pricing information:

     <tr>
       <td>&nbsp;</td>
       <td valign=top><span class=smallb>Bulk Price:</span></td>
       <td>&nbsp;</td>
       <td>
         <table border=0 cellspacing=0 cellpadding=0 width=100%>

     <dsp:droplet name="ComplexPriceDroplet">
       <dsp:param name="complexPrice" param="complexPrice"/>
       <dsp:oparam name="output">
         <dsp:droplet name="For">
           <dsp:param name="howMany" param="numLevels"/>
           <dsp:param name="indexName" value="index"/>
             <dsp:oparam name="output">
               <tr>
                 <td><span class=small>
                     <dsp:valueof param="levelMinimums[param:index]"/>
                 </span></td>
                 <td>
                     &nbsp;-&nbsp;
                 </td>
                 <td><span class=small>
                     <dsp:valueof param="levelMaximums[param:index]">or
                        over</dsp:valueof>
                 </span></td>
                 <td>

                   <%/*Display price for locale of user: */%>
                   <dsp:droplet name="CurrencyConversionFormatter">
                       <dsp:param name="currency" param="prices[param:index]"/>
                       <dsp:param bean="/atg/userprofiling/
                          Profile.priceList.locale" name="locale"/>
                       <dsp:param bean="/atg/userprofiling/
                          Profile.priceList.locale" name="targetLocale"/>
                       <dsp:param name="euroSymbol" value="&euro;"/>
                       <dsp:oparam name="output">
                         &nbsp;&nbsp;<span class=small><dsp:valueof
                            valueishtml="<%=true%>" param="formattedCurrency">no
                               price</dsp:valueof></span>
                       </dsp:oparam>
                     </dsp:droplet>
                     <dsp:droplet name="Switch">
                       <dsp:param bean="/atg/userprofiling/
                          Profile.priceList.locale" name="locale"/>
                       <dsp:oparam name="default">
                       </dsp:oparam>
                       <dsp:oparam name="de_DE">

                     <%/*Don't Display in en directory */%>
                     <%/*
                     <dsp:droplet name="CurrencyConversionFormatter">
                       <dsp:param name="currency" param="prices[param:index]"/>
                       <dsp:param bean="/atg/userprofiling/
                          Profile.priceList.locale" name="locale"/>
                       <dsp:param name="targetLocale" value="de_DE"/>
                       <dsp:oparam name="output">
                         <span class=small>(<dsp:valueof param=
                            "formattedCurrency">no price</dsp:valueof>)</span>
                       </dsp:oparam>
                     </dsp:droplet> */%>
                     </dsp:oparam>
                     </dsp:droplet>
                  </td>
               </tr>
             </dsp:oparam>
           </dsp:droplet>
         </dsp:oparam>
       </dsp:droplet>
     </table>
     </td>
   </tr>
 </dsp:oparam><!--  ************************************* End of Bulk Pricing -->

We used the same method to display tiered prices.