Announcement

Collapse
No announcement yet.

A replacement for Adjusted_Price?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    A replacement for Adjusted_Price?

    Hi folks,

    I'm familiar with the utility function Adjusted_Price, which takes a product price as input, and return a price that's been adjusted for any applicable price-group discounts. But I think this only works on the old "legacy" price groups, not for the newer ones that use discount modules. Is there a function that works like Adjusted_Price, but includes all the discounts?

    After hunting around in the LSK, I found some code in runtime.mv that involves a series of steps, starting with DiscountState_CreateFromBasket(), and ending with DiscountState_Predict_Product_Discounts(). Do I need to copy that, or is there an easier way?

    If it helps, I don't need to handle every possible type of discount, such as BOGO's that depend on what else is in the basket at the time. I just need to be able to find out the price for a single product, before it goes into the basket, using any price groups that apply to that particular product for the customer who's shopping. If the other types of discounts have to be included, that's OK too.

    Thanks --
    Last edited by Kent Multer; 05-24-16, 12:57 AM.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    The function you want is called CommonComponentFields_Initialize_Product_Discounts _Runtime. This takes in an array of products and will load any product specific price group discounts.

    Here is an example from how we do it for a single product on PROD:

    Code:
    <MvIF EXPR = "{ l.settings:predictdiscounts }">
            <MvREFERENCE NAME = "l.products" INDEX = 1 VARIABLE = "l.all_settings:product">
    
            <MvIF EXPR = "{ NOT [ g.Module_Feature_TUI_UT ].CommonComponentFields_Initialize_Product_Discounts_Runtime( l.products, 1 ) }">
                <MvFUNCTIONRETURN VALUE = 0>
            </MvIF>
        </MvIF>
    This function replaces the product:price variable with the sale price but also adds a discount array to the product structure.

    This is template code but the same data is available in your module:

    Code:
    <mvt:foreach iterator="product" array="products">
     
        Product Code: &mvt:product:code;<br>              
        Discount Count: &mvt:product:discount_count;<br>
        Formatted Price: &mvt:product:formatted_price;<br>
                  
     
        <mvt:foreach iterator="discount" array="product:discounts">
             Description:&mvt:discount:descrip;<br>
             Discount: &mvt:discount:discount;<br>
             Formatted Discount: &mvt:discount:formatted_discount;<br>
        </mvt:foreach>
     
    
    </mvt:foreach>
    Last edited by Brennan; 05-24-16, 02:13 PM.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Great; Thanks, Brennan!
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment

      Working...
      X