Announcement

Collapse
No announcement yet.

How to use math calculation with Attributes

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

    How to use math calculation with Attributes

    Hello, I am not a developer so any help would be very much appreciated.
    Thank you in advance, Iris

    I am on a Miva 5.5 PR 8 store which I will be upgrading to PR9 soon.
    Right now I have the price for items with attributes set as 0.00 and then each attribute has the actual price for that attribute.
    It is confusing for customers to see the product price as 0.00.
    Below is what I tried that shows 2 lines in the Basket for each attribute to get to the total price.

    Example below of what I tried to implement for attributes for an item.
    Product page showing 20.00 for product
    Attributes:
    10" item (this shows up as 20.00 in the basket because it is taken from the product page)
    15" item 30.00 - add 10.00


    Doing this shows up in the Basket as 2 lines for each attribute after the first one
    for example, the 15" item shows up in the basket as
    15" Item 20.00
    15" Item 10.00

    I am hoping that it can be coded so the two lines are added together and there is one line showing
    15" Item 30.00

    I have toolkit and found the math calculation below but do not know how to implement it,.

    Use the math_add to calculate the sum of two variables to a new number. For example,
    <mvt:item name="toolkit" param="math_add|sum|l.all_settings:product:price|l .all_settings:product:cost" />
    sum the price plus the cost to get a variable called sum.

    Below is the Attribute Template Code
    <table>
    <mvt:foreach iterator="attribute" array="attributes">
    <tr>
    <td class="prompt">
    <input type="hidden" name="Product_Attributes[ &mvt:attribute:index; ]:code" value="&mvte:attribute:code;" />
    <mvt:if expr="l.settings:attribute:template_code NE 0">
    <input type="hidden" name="Product_Attributes[ &mvt:attribute:index; ]:template_code" value="&mvte:attribute:template_code;" />
    </mvt:if>
    <mvt:if expr="l.settings:attribute:type NE 'checkbox'">
    <mvt:if expr="l.settings:attribute:image">
    <img src="&mvte:attribute:image;" alt="&mvte:attribute:raw_prompt;" />
    <mvt:else>
    <mvt:if expr="l.settings:attribute:required">
    <span class="required">
    <mvt:else>
    <span>
    </mvt:if>
    &mvt:attribute:prompt;
    </span>
    </mvt:if>
    <mvt:else>
    &nbsp;
    </mvt:if>
    </td>
    <td class="field">
    <mvt:if expr="l.settings:attribute:type EQ 'text'">
    <input type="text" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:attribute:value;" class="textfield" />
    <mvt:elseif expr="l.settings:attribute:type EQ 'memo'">
    <textarea name="Product_Attributes[&mvt:attribute:index;]:value">&mvte:attribute:value;</textarea>
    <mvt:elseif expr="l.settings:attribute:type EQ 'radio'">
    <mvt:foreach iterator="option" array="attribute:options">
    <div>
    <mvt:if expr="( ( g.Product_Attributes[l.settings:attribute:index]:value EQ 0 ) AND
    ( l.settings:option:id EQ l.settings:attribute:default_id ) ) OR
    ( g.Product_Attributes[l.settings:attribute:index]:value EQ l.settings:option:code )">
    <input type="radio" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:option:code;" checked />
    <mvt:else>
    <input type="radio" name="Product_Attributes[&mvt:attribute:index;]:value" value="&mvte:option:code;" />
    </mvt:if>
    <mvt:if expr="l.settings:option:image">
    <img src="&mvte:option:image;" alt="&mvte:option:prompt;" />
    <mvt:else>
    &mvte:option:prompt;
    </mvt:if>
    </div>
    </mvt:foreach>
    <mvt:elseif expr="( l.settings:attribute:type EQ 'select' ) OR ( l.settings:attribute:type EQ 'swatch-select' )">
    <select name="Product_Attributes[&mvt:attribute:index;]:value">
    <mvt:foreach iterator="option" array="attribute:options">
    <mvt:if expr="( ( g.Product_Attributes[l.settings:attribute:index]:value EQ 0 ) AND ( l.settings:option:id EQ l.settings:attribute:default_id ) ) OR
    ( g.Product_Attributes[l.settings:attribute:index]:value EQ l.settings:option:code )">
    <option value="&mvte:option:code;" selected>&mvte:option:prompt;</option>
    <mvt:else>
    <option value="&mvte:option:code;">&mvte:option:prompt;</option>
    </mvt:if>
    </mvt:foreach>
    </select>
    <mvt:elseif expr="l.settings:attribute:type EQ 'checkbox'">
    <mvt:if expr="g.Product_Attributes[l.settings:attribute:index]:value">
    <input type="checkbox" name="Product_Attributes[&mvt:attribute:index;]:value" value="Yes" checked />
    <mvt:else>
    <input type="checkbox" name="Product_Attributes[&mvt:attribute:index;]:value" />
    </mvt:if>
    <mvt:if expr="l.settings:attribute:image">
    <img src="&mvte:attribute:image;" alt="&mvte:attribute:raw_prompt;" />
    <mvt:else>
    <mvt:if expr="l.settings:attribute:required">
    <span class="required">
    <mvt:else>
    <span>
    </mvt:if>
    &mvt:attribute:prompt;
    </span>
    </mvt:if>
    </mvt:if>
    </td>
    </tr>
    </mvt:foreach>
    </table>
    <div class="clear"></div>

    #2
    Re: How to use math calculation with Attributes

    Have you thought of starting out with a base product price of $20.00 then using radio buttons, do:

    10" item (+0.00) - make this the default choice
    15" item (+10.00)

    Then, the customer sees the base price (which you define what they are getting in the first attribute option) and then can easily see the progression in price as they choose the larger size(s).

    The basket show the base product price and then the effect of choosing the larger size by adding the price difference. If they don't choose a larger size, the base size (10") shows as the chosen attribute option with a no added cost.

    I hope this is close . . . .

    Comment


      #3
      Re: How to use math calculation with Attributes

      Thank you for your suggestion. I am already doing this...the problem is it shows up in the basket as 20.00 and another line with 10.00. I have seen other people's websites where no matter what option you choose, it adds the base price to the additional cost behind the scenes and it shows up in the basket as just one price. I would think it would be a math calculation that would show up on the front end as just one price for each option.
      Again, Thank you, Iris

      Comment


        #4
        Re: How to use math calculation with Attributes

        Toolkit has a function for Combined price

        139. Use bask_getsum to create a price sum variable in the basket. It sums the base price + the attribute prices to create a formatted_price_sum.

        http://apps.miva.com/product/WCW-TOOLKIT5.html

        Comment


          #5
          Re: How to use math calculation with Attributes

          What version are you on?

          I could get bask_getsum to work in 5.5 but not Miva 9.
          http://www.alphabetsigns.com/

          Comment


            #6
            Re: How to use math calculation with Attributes

            I'm using 5.5

            Haven't read that any of the TK functions wouldn't be supported in v.9.

            Comment


              #7
              Re: How to use math calculation with Attributes

              All of the TK functions should work fine in 9.
              Thanks,

              Rick Wilson
              CEO
              Miva, Inc.
              [email protected]
              https://www.miva.com

              Comment


                #8
                Re: How to use math calculation with Attributes

                Confirming that I can now get Toolkit ver 5.2760 function bask_getsome to work in Miva 9.
                http://www.alphabetsigns.com/

                Comment

                Working...
                X