Announcement

Collapse
No announcement yet.

Fun with math

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

  • Fun with math

    I need to do a math function with two fields that will display numbers

    The first field is a custom field


    Code:
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code,'MSRP',g.MSRP)" />
                                    <s id="price-value-additional">$&mvte:global:MSRP;</s>
    the second field is the

    Code:
    &mvt:product:price;
    to create a custom "Savings" result.

    Yes, I know that this can be done using the Marketing Specific Sale Price but the store is using an external connection that populates the first two fields.
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

  • Maybe I'm not understanding... but will something simple like this work?
    Code:
    <mvt:assign name="g.savings" value="( (l.settings:product:customfield_values:customfields:MSRP - l.settings:product:price) ROUND 2)" />
    You save &mvt:global:savings;!

    Comment


    • Originally posted by RTHOMASDESIGN View Post
      Maybe I'm not understanding... but will something simple like this work?
      Code:
      <mvt:assign name="g.savings" value="( (l.settings:product:customfield_values:customfields:MSRP - l.settings:product:price) ROUND 2)" />
      You save &mvt:global:savings;!
      It looks like it was what I was after, it really did. The end result though was a negative value of the product price.
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


      • Reverse the variables? Sorry, I assumed your MSRP was "Manufacturer Suggested Retail Price", which is usually higher than the price a retailer is actually selling the product at. So the higher price, minus the price your client is selling the product for should results in savings.

        Comment


        • Originally posted by RTHOMASDESIGN View Post
          Reverse the variables? Sorry, I assumed your MSRP was "Manufacturer Suggested Retail Price", which is usually higher than the price a retailer is actually selling the product at. So the higher price, minus the price your client is selling the product for should results in savings.
          I don't think that will help. The MSRP is $2205.05. The selling price (product price) is $999.00. So the savings should have been $1206.05

          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


          • Originally posted by lesliekirk View Post

            It looks like it was what I was after, it really did. The end result though was a negative value of the product price.
            Then the other variable, from the custom field, must be zero. Probably the code that reads that value isn't correct; or else the product you're testing with doesn't have a value in that field.
            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


            • Originally posted by Kent Multer View Post

              Then the other variable, from the custom field, must be zero. Probably the code that reads that value isn't correct; or else the product you're testing with doesn't have a value in that field.
              The value is "supposed" to be 2205.05 - it displays on the page as that. Let me go back in and check a couple of things.
              Leslie Kirk
              Miva Certified Developer
              Miva Merchant Specialist since 1997
              Previously of Webs Your Way
              (aka Leslie Nord leslienord)

              Email me: [email protected]
              www.lesliekirk.com

              Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

              Comment


              • I'd check the token list. Also, make sure the values for your custom field are not proceded by a dollar sign, you want "2205.05", not "$2205.05". I used the exact code above on a dev store and it's working for me.

                Comment


                • I figured it out - I needed to use g.MSRP because I had previously done this:

                  Code:
                  <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code,'MSRP',g.MSRP)" />
                  Thanks ya'll!

                  Leslie Kirk
                  Miva Certified Developer
                  Miva Merchant Specialist since 1997
                  Previously of Webs Your Way
                  (aka Leslie Nord leslienord)

                  Email me: [email protected]
                  www.lesliekirk.com

                  Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                  Comment


                  • yeah, gave up using miva's generated custom field values and alway just create my own cause iz lazy and typing
                    g.pm:customfield is a LOT easier than l.settings:product:customfield_values:customfields :customField
                    Bruce Golub
                    Phosphor Media - "Your Success is our Business"

                    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                    phosphormedia.com

                    Comment


                    • Originally posted by Bruce - PhosphorMedia View Post
                      yeah, gave up using miva's generated custom field values and alway just create my own cause iz lazy and typing
                      g.pm:customfield is a LOT easier than l.settings:product:customfield_values:customfields :customField
                      Yeah, I "try" to stick with what Miva has provided as it's more universal and makes it a tad bit easier for the next person to clean up my mess.
                      Leslie Kirk
                      Miva Certified Developer
                      Miva Merchant Specialist since 1997
                      Previously of Webs Your Way
                      (aka Leslie Nord leslienord)

                      Email me: [email protected]
                      www.lesliekirk.com

                      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                      Comment


                      • That's why I have a keyboard shortcuts in my editor that does this:

                        Code:
                        <mvt:comment> ### insert -bwg ###</mvt:comment>
                        and

                        Code:
                        <mvt:comment>
                        #
                        # insert -bwg
                        #
                        </mvt:comment>
                        remember, its better to be clever and lazy programmer than just a clever programmer :)
                        Bruce Golub
                        Phosphor Media - "Your Success is our Business"

                        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                        phosphormedia.com

                        Comment


                        • Originally posted by Bruce - PhosphorMedia View Post
                          That's why I have a keyboard shortcuts in my editor that does this:

                          Code:
                          <mvt:comment> ### insert -bwg ###</mvt:comment>
                          and

                          Code:
                          <mvt:comment>
                          #
                          # insert -bwg
                          #
                          </mvt:comment>
                          remember, its better to be clever and lazy programmer than just a clever programmer :)

                          I seem to recall a conversation about a move to require all code be standardized. Maybe someone will come up with how they want us to do it so it doesn't drive my OCD crazy.
                          Leslie Kirk
                          Miva Certified Developer
                          Miva Merchant Specialist since 1997
                          Previously of Webs Your Way
                          (aka Leslie Nord leslienord)

                          Email me: [email protected]
                          www.lesliekirk.com

                          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                          Comment

                          • Working...
                            X

                            This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

                            This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

                            Accept