1

Im working on building a product comparison to add into a Cartthrob Ecommerce site. I would like to be able to extract item option information from an existing cart entry to transfer to a page in order to compare against other products. Does anyone know if this is possible and how I would do it?

Any advise would be appreciated

2
  • Are you wanting to use EE tags or PHP? Probably should specify to get a better answer. May 3, 2013 at 16:52
  • I know if I can get the data back from the cart and assign the info to some $strings, I can do it all in PHP, however if its possible with EE tags, that would be better for learning the ins and outs of EE May 4, 2013 at 11:14

1 Answer 1

1

You should be able to get any info from items in the cart using the following CartThrob template tags.

cart_items_info Outputs information about items in the cart, including item subtotals and prices with tax

item_options Outputs selectable and selected options for items in the cart, or stored items

cart_entry_ids lists entry ids of items in the cart separated by a pipe | character

customer_info Outputs customer information. Generally you can use cart items info instead, as long as there is at least one item in the cart

If you find that you cannot get particular custom field data from your products then you can use the CT tags to get the entry_id of the product and pass this to an embed or snippet which can be a normal exp:channel:entries tag pair.

So yes. What you describe should certainly be possible.

2
  • Thanks for the reply, would it be straight forward to assign $strings to the quantities that are retrieved from the cart? ie item one - quantity 4 to $item_one = 4? May 4, 2013 at 11:26
  • I'm not sure. You may be able to drop the EE tags into your PHP (if it's in the template) - depends on parse order I guess. But... do you need to use PHP for this? I have a hunch it's doable within EE's native templating system. If it's not then perhaps a pure PHP solution as an EE add-on would be better.
    – foamcow
    May 4, 2013 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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