Announcement

Collapse
No announcement yet.

Adding two product prices

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

    Adding two product prices

    Looking for a little help with the script below.

    Just trying to add two products prices together to display on a page ultimately saving me countless hours of changes whenever the post office does their price increases every 6 months.

    The two product codes are below. TIA!

    HTML Code:
    <MvASSIGN NAME="l.product_code1" VALUE="'MMERGEMAGNET'">
    <MvASSIGN NAME="l.product_code2" VALUE="'ENV_9_FOM'">
    
    <MvtDO NAME="l.return" FILE="g.Module_Library_DB" VALUE="Product_Load_Code(l.product_code1, l.settings:product)">
    <MvASSIGN NAME="l.product1_price" VALUE="l.return:price">
    
    <MvtDO NAME="l.return" FILE="g.Module_Library_DB" VALUE="Product_Load_Code(l.product_code2, l.settings:product)">
    <MvASSIGN NAME="l.product2_price" VALUE="l.return:price">
    
    <MvASSIGN NAME="l.total_price" VALUE="l.product1_price + l.product2_price">
    
    Total Price: $<MvEVAL EXPR="l.total_price">

    #2
    Assumed this is MivaScript and not template code, you need to change MvtDo to MvDo. There appears to be other syntax errors too.

    If you're in template code, look up the MVT: for example:
    Code:
    <mvt:assign name...
    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    Comment


      #3
      LOL! Serves me right trying to take a shortcut with AI. I'll start over and see how far I get. Sometimes tasks like this that I thought would take no time consume me :)

      Comment


        #4
        I was messing with this again and getting a 0 for the total. I did confirm the item code and they both have a price.

        Am I loading these incorrectly?

        HTML Code:
        <mvt:do name="l.product_mmergemagnet" file="g.Module_Library_DB" value="Product_Load_Code('MMERGEMAGNET', l.settings:product)" />
        <mvt:do name="l.product_env_9_fom" file="g.Module_Library_DB" value="Product_Load_Code('ENV_9_FOM', l.settings:product)" />
        
        <mvt:assign name="l.price_mmergemagnet" value="l.product_mmergemagnet:price" />
        <mvt:assign name="l.price_env_9_fom" value="l.product_env_9_fom:price" />
        <mvt:assign name="l.price_total" value="l.price_mmergemagnet + l.price_env_9_fom" />
        
        <p>Total Price: <mvt:eval expr="l.price_total" /></p>

        Comment


          #5
          mstella1 try this:

          Code:
          <mvt:do name="l.product_mmergemagnet" file="g.Module_Library_DB" value="Product_Load_Code('MMERGEMAGNET', l.settings:mmergemagnet)" />
          <mvt:do name="l.product_env_9_fom" file="g.Module_Library_DB" value="Product_Load_Code('ENV_9_FOM', l.settings:env_9_fom)" />
          <mvt:assign name="l.price_total" value="l.settings:mmergemagnet:price + l.settings:env_9_fom:price" />
          <p>Total Price: <mvt:eval expr="l.price_total" /></p>
          Nicholas Adkins
          Technical Training Specialist / Miva, Inc.
          [email protected]
          https://www.miva.com/mivalearn

          Comment


            #6
            That worked! Thank you.

            Is there a way to display the formatted price so the 0 doesn't drop off of the end? This one comes out to $1.10 but displays as 1.1

            Comment


              #7
              mstella1 you can do something like this:

              https://docs.miva.com/developer/addi...rrency-format/

              Let me know if you have trouble getting it implemented.
              Nicholas Adkins
              Technical Training Specialist / Miva, Inc.
              [email protected]
              https://www.miva.com/mivalearn

              Comment


                #8
                Perfect!

                HTML Code:
                <mvt:do name="l.formatted_total_price" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.price_total )" />
                <p>Total Price: <mvt:eval expr="l.formatted_total_price" /></p>

                Comment

                Working...
                X