View Single Post
  #16  
Old 09-27-2012, 08:02 AM
 
Pyro Pyro is offline
 

X-Adept
  
Join Date: Nov 2009
Posts: 506
 

Default Re: Customize invoice based on product purchased

Quote:
Originally Posted by totaltec
Are you perhaps trying to determine how many of a certain product they bought? Then you would use {$product.amount}




Mike,


That is exactly what I am trying to do. I have 2 products that I am interested in counting on the invoice, multiplying each by a set number, and then adding the mathematical products together, so that my end result is one number.

I think you may even tear up on this one, but I managed to come up with what I think is the correct smarty math function (or at least it is pretty close). {math equation="(( y * 9 ) + ( z * 18 ))" y=$county z=$countz}




As such, I have edited my code to be this:


HTML Code:
{foreach from=$products item=product} {if $product.productid eq 1} {assign var=orderedy value={$product.amount}} {/if} {if $product.productid eq 7 or $product.productid eq 5 or $product.productid eq 6} {assign var=orderedz value={$product.amount}} {/if} {/foreach} {if $orderedy ne '' and $orderedz ne ''} text{math equation="(( y * 9 ) + ( z * 18 ))" y=$county z=$countz} {elseif $orderedy ne ''} text{math equation="( y * 9 )" y=$county} {elseif $orderedz ne ''} text{math equation="( z * 18 )" z=$countz} {else} Go get a boat, and some $*%# life jackets, loser! {/if}



I tested the code with an order that had 1 prodid=6 and the only output was
Code:
}
. Any idea where I went wrong? I think the issue is with how I am using $product.amount.







-------------------------------Edit-----------------------

I noticed that I was not defining the countz and county variables anywhere, so I revised my code to this, but I still get the same output.

Code:
{foreach from=$products item=product} {if $product.productid eq 1} {assign var=orderedy value={$product.amount}} {/if} {if $product.productid eq 7 or $product.productid eq 5 or $product.productid eq 6} {assign var=orderedz value={$product.amount}} {/if} {/foreach} {if $orderedy ne '' and $orderedz ne ''} text{math equation="(( y * 9 ) + ( z * 18 ))" y=$orderedy z=$orderedz} {elseif $orderedy ne ''} text{math equation="( y * 9 )" y=$orderedy} {elseif $orderedz ne ''} text{math equation="( z * 18 )" z=$orderedz} {else} Go get a boat, and some $*%# life jackets, loser! {/if}

Thanks!
__________________
Best Wishes,
James

4.5.2 Gold (work in progress)
Reply With Quote