Hi
I am trying to create a view (using panels) that allows you to add to cart directly from the view. In my template I have:
<?php foreach ($columns as $column_number => $item): ?>
<td class="<?php print 'col-'. ($column_number + 1); ?>">
<?php print $item; ?>
<?php
$my_asin = "B001IHH3I6";
$form = drupal_get_form('amazon_store_addcart_form',$my_asin);
print_r($form);
?>
</td>
<?php endforeach; ?>
This works fine but I cannot figure out what goes into $my_asin to represent the asin of the current item. Sorry if this is a dumb question but I'm new to php and ths module
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | add_to_cart_content_type.txt | 2.33 KB | rfay |
| #7 | add_to_cart_view.txt | 9.05 KB | rfay |
| #7 | views_add_to_cart-1.0.tar_.gz | 2.68 KB | rfay |
| #4 | cck.txt | 2.16 KB | seangee |
| #4 | view.txt | 6.53 KB | seangee |
Comments
Comment #1
rfayIt doesn't look like you're using a view (as in the views module), which would probably be a good thing to do.
If you create a view using the techniques in the docs (http://drupal.org/node/524296) you can then embed that in your panel.
I'm not sure about the add-to-cart part (embedding a complete form).
The ASIN is nicely available if you set up using a view at the link I provided.
-Randy
Comment #2
seangee commentedThanks for the response - I did use that link as a tutorial. In fact the view is an import of the sample in that link. The code I displayed was from views-view-grid.tpl.php. The fact that I am using panels is probably a red herring.
The view is simply a listing of the products and I would like users to add an item to their basket without having to go into the detail first. The code works perfectly as is except that it is always the same ASIN that is added. So all I am looking for I think is how to I reference it. All the info I need is in $item but how do I get it out - e.g $item['asin'] - although that doesn't work :-)
Comment #3
rfayWhy don't you export your view and attach it to this issue. The conversation might be useful to others.
If you're using a CCK type, make sure to export that and attach it as well.
Comment #4
seangee commentedHere are the exports. My original assumption was wrong - $item is the rendered output
Comment #5
seangee commentedIts bed time in the Uk but to get an idea of what I am trying to achieve the view is available at www.themobileflorist.com/anniversary
One of the nodes in the view is http://www.themobileflorist.com/content/rose-golden-wedding-anniversary-...
Comment #6
rfayComment #7
rfayI was able to do this using views_customfield.
You *must* have the ASIN available. Use a relationship to the Amazon Item, and add ASIN as a field *before* customfield.
My view and CCK type are attached as text, and just for grins I exported them as a feature - you might try it out. The feature requires Views Bulk Operations and of course the Features module.
Comment #8
seangee commentedThank you, that's a lot more elegant than my solution :-)