0

I am looking for a way to output the total amount of products purchased, similiar to {exp:cartthrob:total_items_count} for the cart only that I want to pull it from the "orders" channel (to be used in the order confirmation email).

I have:

Articles ordered: {order_items:total_results}

Which outputs how many different articles were purchased but not the totals. Like if a customer bought:

2 x Product A

3 x Product B

the above tag would output "2". I am now looking for a way to also output "5".

I have tried all different kind of tag combinations and fiddled around with CT arithemtic also but can't get it straight. Maybe this is only possible with an sql query, but since I am not good with those I am first asking here.

Thanks and Cheers

0

We came across this issue before and used the query module like this to get the total item count.

{exp:query sql="SELECT SUM(quantity) AS total_items_count FROM exp_cartthrob_order_items WHERE order_id = {entry_id}"}
{total_items_count}
{/exp:query}

You'll probably need to use this outside of your order_items tag pair as it would be in a loop that might not get you the result you want.

Also, we never used this in the confirmation email, but in a My Account page on the site - but this is the query to get the information you want.

2
  • works perfectly, also in confirmation emails. Thanks!
    – Marc
    May 1 '14 at 21:40
  • Meanwhile I came across the {exp:cartthrob:total_items_count} tag in the CT documentation (cartthrob.com/docs/tags_detail/total_items_count/index.html). It's like searching for the right lego on one day but you just can't find it, then on another day you will find tons of them. :) I haven't tested this yet, since the answer I marked as correct is working great. I'll also let it be the correct answer, just figured to add my additional info for further reference.
    – Marc
    Jun 7 '14 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.