dividing variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • habreu
    replied
    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:
    [SIZE=18px]$21 [/SIZE]
      $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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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. :)

    Leave a comment:


  • habreu
    replied
    Thanks Bruce, I sorted it out. :)

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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.

    Leave a comment:


  • habreu
    replied
    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.

    Leave a comment:


  • Brennan
    replied
    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.

    Leave a comment:


  • habreu
    started a topic dividing variables

    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?
Working...
X