Announcement

Collapse
No announcement yet.

dividing variables

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

    dividing variables

    I hope someone will take pity on my remaining brain cells here. Since it seems Tool Kit which allowed me to tinker doesn't work with some of the changes in Miva I am trying to do something, which 'seems' like it should be baby stuff, but can't get past it.

    I've tried these more ways than I will admit to publicly

    Code:
    <mvt:assign name="l.settings:d_itemtotal" value="l.settings:group:formatted_subtotal_comprehensive" />
    <mvt:assign name="l.settings:d_quantity" value="l.settings:group:quantity" />
    <mvt:assign name="l.settings:d_unitresult" value="d_itemtotal / d_quantity" />
    &mvt:d_unitresult;
    if I output the value of l.settings:group:formatted_subtotal_comprehensive I get the correct value
    if I output the value of l.settings:group:quantity I get the right value

    however even though the documentation seems to indicate division is simple using '/' every attempt and combination I've tried moving dividing directly, passing into variables, using mvt:assign and so on ends up with '0'

    Can someone put me out of my misery?

    #2
    The variable l.settings:group:formatted_subtotal_comprehensive is the "formatted" version which is includes the $. That can't be divided as a number.


    Try using l.settings:group:subtotal_comprehensive and see if that works.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Argghhh! You are only as smart as what you don't know! I did a global search through all the templates looking at all the math code samples and still didn't see that. That did it. Thank you!
      Last edited by habreu; 01-05-17, 03:04 PM.

      Comment


        #4
        Also, I believe you want to change:

        value="d_itemtotal / d_quantity" /> to
        value="l.settings:d_itemtotal / l.settings:d_quantity" /> as expressions should use the full variable name.
        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


          #5
          Thanks Bruce, I sorted it out. :)

          Comment


            #6
            Great. Just didn't want anyone else seeing the initial code and thinking it was correct. Not calling out you cause you usually do post the 'final solution' but i see many folks here ask questions, get answers and then say "fixed it" without saying what actually fixed the problem. :)
            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


              #7
              Good point - thanks.

              This went in BASK/ Basket Contents (Level theme in case that's relevant) and was because the PRICE (EA) column in the basket was showing the combined price of the total quantity of an item, instead of the 'each' price (i.e. added 3 of a $10 item, PRICE (EA) showed as $30) so divided combined price by quantity.

              Previously the code also showed the base price and then the attributes separately -i.e. the $10 item was really $7 base price + 3 $1 options in smaller text below -so something like
              Code:
              $21 
                $3
                $3
                $3
              below for each attribute. Very confusing. I hid the attribute &mvt and using l.settings:group:subtotal_comprehensive gave me the total with attributes which I then divided by quantity.

              Code:
              <mvt:assign name="l.settings:d_unitresult" value="l.settings:group:subtotal_comprehensive/l.settings:group:quantity" />
              <mvt:do name="l.settings:group:combined_formatted_subtotal" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:d_unitresult )" />
              
              &mvt:group:combined_formatted_subtotal;
              Last edited by habreu; 01-06-17, 11:38 AM.

              Comment

              Working...
              X