Thickbox + Add to Cart

Posts: 20
Joined: 08/07/2007
Uber Donor

I want to display the "Add to cart" form within thickbox product previews. I'm trying to make the View I've set up at http://woo.circatree.com/flooring/carpet look (and of course function) like the attached comp, which includes the product attributes Size and Style.)

Should I use the hook_add_to_cart somewhere? ( http://www.ubercart.org/docs/api/hook_add_to_cart ) I posted this topic on the old site and remember somebody's response mentioning the hook_form_alter but I don't remember how or where I was to use that function.

Thanks, dUdes,

-Steve

AttachmentSize
Brennan & Woo Sample Request - Thickbox + Add to Cart (.jpg)371.62 KB
Posts: 2244
Joined: 08/07/2007
AdministratoreLiTe!

I think you want to use theme_uc_product_add_to_cart().

Stick this snippet in the Thickbox content:

<?php
  theme
('uc_product_add_to_cart', $node);
?>

This is the way the node view displays the form, allowing the attribute module to hook in. You might want to write a new function to emulate it if it doesn't look quite like you want.

Posts: 20
Joined: 08/07/2007
Uber Donor

Thank you Lyle for your response. That snippet seems like just what I'm after. But I'm not clear where my "Thickbox content" is. Can you please clarify what you mean and where I should look?

Thanks again,

-Steve

Posts: 2244
Joined: 08/07/2007
AdministratoreLiTe!

Well, in your view, you will have to write a link that has the class "thickbox". This link will point to some content somewhere that will contain that snippet. Since you want it to look a specific way, this would require you make some custom functions to output exactly what you want, and not any extra Drupal markup.

Posts: 20
Joined: 08/07/2007
Uber Donor

I'm considering I could do this a few different ways. I think I'll need or like to use this feature on another site, and others may also want to take advantage of it.

So, it doesn't seem like a theme function is the best idea; A View might make sense (to which I .thickbox a link to in my view, like you recommended); but a Module seems like it might be the best idea.

Similar to uc_views, I could create my functionality in a uc_thickbox_views module.

What do you think?

Posts: 20
Joined: 08/07/2007
Uber Donor

Lyle- Can I pay you to do this for me?

-Steve

Posts: 2244
Joined: 08/07/2007
AdministratoreLiTe!

Yes, you can. I think I can help you out.

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

So my code to do this looks like this:

<?php
  $myProdNid
= 1;
 
$product_node = node_load($myProdNid);
 
$product_output = theme('uc_product_add_to_cart', $product_node);
 
print_r($product_output);
?>

and it definately creates a form like the one on the product node page..

but when I click the add_to_cart button, it appears to just reload the page that the code is on and the cart remains empty. Is there some AJAX involved that I am missing, Maybe?