View Single Post
  #19  
Old 09-27-2012, 09:46 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Customize invoice based on product purchased

Aha! I think I see it.

Smarty cannot use non integer variables in a math equation. Since some of your variables are not assigned like w=$ordered1 then it returns null. "null" doesn't add up and breaks the math equation.

You can handle this several ways by assigning a value of 0 to ordered1 etc, or by using |default:0 which is my preference.

Consider this code:
PHP Code:
{if $ordered1 ne '' or $ordered5 ne '' or $ordered6 ne '' or $ordered7 ne ''}
  
You bought {$ordered1|default:0boats, {$ordered5|default:0life jackets, {$ordered6|default:0anchors, and {$ordered7|default:0paddles!
   
You get {math equation="(( w * 9 ) + ( z * 18 ) + ( y * 18 ) + ( z * 18 ))" w=$ordered1|default:0 x=$ordered5|default:0 y=$ordered6|default:0 z=$ordered7|default:0points!
{else}
  
Go get a boat, and some $*%# life jackets, loser!
{/if} 

BTW, you also have a small typo: x=$orderedz5
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote