| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Customize invoice based on product purchased | ||||
|
|
Thread Tools | Search this Thread |
#11
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Quote:
Hmm, I think I follow. Ne is for negative, so you are basically saying not to include that, but what does the ne '' do? If negative nothing? Thanks!
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
#12
|
|||||||||
|
|||||||||
Re: Customize invoice based on product purchased
ne is for "not equals" (!=). I am saying if this not equals nothing, display it, else display that. There are a thousand ways to word these things, you can test for positive or negative and go from there. Finding the best way, now that is an art.
__________________
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. |
|||||||||
|
#13
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Hmm, not equals makes more sense.
This thread threw me off. http://forum.x-cart.com/showthread.php?t=60942 The guy asked about negative and you responded ne. Thanks again for all of the help. I think I understand this now (or at least 1000x more than I did before).
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
#14
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Sorry Mike, one more question for you about the variables.
Does everything have to be defined? I used {$order|@print_r} to print the variables and I see nothing related to count. I guess what I am asking is can I count the number of each SKU and use that number in a basic math problem? Here is an example of the logic that I am thinking: HTML Code:
(Just incase I randomly became a genius at this in 4 posts, I checked to see if my attempt at pseudo code worked. Its safe to say it didn't for those of you that may try it in the future. )
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
#15
|
|||||||||
|
|||||||||
Re: Customize invoice based on product purchased
To get the total number of rows in the products array, try {$products|@count}
To know what the current index of the array is use {$smarty.foreach.myproducts.index} -to use .index or .iteration you need to name your foreach loop. Example: Quote:
Are you perhaps trying to determine how many of a certain product they bought? Then you would use {$product.amount}
__________________
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. |
|||||||||
#16
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Quote:
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:
I tested the code with an order that had 1 prodid=6 and the only output was Code:
-------------------------------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:
Thanks!
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
#17
|
|||||||||
|
|||||||||
Re: Customize invoice based on product purchased
James I can't test the code right now. I am not at my normal IP address. I can tell you what looks suspicious to me:
{assign var=orderedy value={$product.amount}} --There is no need for those internal brackets. Since you are already inside the brackets with your assign, you don't use them again when accessing variables. Try fixing that and let me know.
__________________
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. |
|||||||||
|
#18
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Mike,
Thanks! That definitely helped as it is now displaying a number at least! On an invoice that has 5 of product#7 and 1 of product#6, the output is 18. (which is the output of the 1 product#6.) It seems the issue is the or statement. It is not combining the count of each of the products in the or, but rather 1 of them. It seems that I should switch which side of the equation the or is on. This is my attempt, which only outputs "text" for an order with 5 product#7 and 1 product#6. HTML Code:
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
#19
|
|||||||||
|
|||||||||
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:
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. |
|||||||||
|
#20
|
|||||||
|
|||||||
Re: Customize invoice based on product purchased
Quote:
Brilliant! I was hoping it would just assume non intergers as 0, for purposes of math equations, but that obviously wasn't the case. Everything is working now. Thanks again. Quote:
THESE DAMN Z's!! I also noticed that it was outputting an unexpected number. Upon closer inspection: Quote:
should have been: Quote:
Hopefully that helps someone that comes along later. P.S. for anyone that needs it, I added format="%.2f" to my code in order to display 2 decimal places (like you would need in the case of currency). Code:
__________________
Best Wishes, James 4.5.2 Gold (work in progress) |
|||||||
|
|
|||
X-Cart forums © 2001-2020
|