Announcement

Collapse
No announcement yet.

Subtraction

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

    Subtraction

    I am not sure why but I am not getting the result that I thought I would so I am hoping that someone can help me out. I have tried this two different ways and gotten the same wrong result. I should be getting a result of 5.50 but I am getting -5.00.

    Code:
    <mvt:item name="ry_toolbelt" param="assign|l.all_settings:product:calc_shipping |Json_Parse_Call(g.shipping_url,g.verbose)" />
    <mvt:assign name="l.settings:shipping_reduction" value="5" />
    <mvt:assign name="l.settings:calc_shipping" value="l.settings:product:calc_shipping" /> (I don't even think this is need, just did it for testing to see if it change the result)
    <mvt:assign name="l.settings:new_shipping" value="l.settings:calc_shipping - l.settings:shipping_reduction" />
    
    <mvt:item name="ry_toolbelt" param="assign|l.all_settings:product:calc_shipping |Json_Parse_Call(g.shipping_url,g.verbose)" />
    <mvt:assign name="l.settings:shipping_reduction" value="5" />
    <mvt:item name="toolkit" param="math_subtract|new_shipping|l.all_settings:product:calc_shipping|l.all_settings:shipping_reduction" />
    Chris Dye
    http://www.kseriesparts.com

    #2
    Any time you compute (x - 5) and get -5 as the result, it's a good bet that "x" contains something that is equal to zero. In Miva Script, that could be anything that's not a valid numeric value. I would take a closer look at the results of the JSON parse. .Probably there's some white space or other non-numeric characters in there.

    HTH --
    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


      #3
      Thanks Kent, I added a trim around the json result and now it is working correctly
      Chris Dye
      http://www.kseriesparts.com

      Comment

      Working...
      X