1
Answers
Vote up!
0
Vote down!

How to access add to cart form in a view's template.php theme

I've set up a custom view for a very complex product listing. I've custom themed my view's row output by creating a custom template file in my subtheme's template folder. I then turned this into a function in the subtheme's template.php file so that I could add some php logic to the output.

I've been able to access all the view's fields, EXCEPT for the add to cart form, which shows up in my view's fields within the Drupal view UI, but doesn't seem to show up in my devel's variables list (which is what I'm using to navigate my complex product listing).

How can I access and include the add to cart form?

Please see the following screengrab for clarification:

https://www.dropbox.com/s/oafei0wkun5iw65/view-theme-add-to-cart.jpg

Asked by: Reuben Lara
on February 24, 2014

1 Answer

Vote up!
0
Vote down!

Finally found the form buried deep within the variable:

$myVariable = ($variables['view']->query->pager->display->handler->handlers['field']['add_to_cart_form']->original_value);

Answer by: Reuben Lara
Posted: Feb 24, 2014