Posted by jhebel on May 9, 2008 at 12:44pm
| Project: | Ubercart Option Images |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi, great module... very much appreciated!
A great feature would be if the users' chosen Attribute Option Image showed in the cart as well -- so if say if the default prod pic was a yellow shirt but I chose a blue shirt (attribute option), the blue shirt would show in the cart instead of the default prod image (yellow shirt in this case).
Comments
#1
Thank you, I like the suggestion I will certainly add this to the todo list :)
#2
That's great! Thank you.
#3
#4
Any progress on this feature? I am having other problems with this module as well, but if this isn't active I won't use it anyway. Having the wrong color item shown in the cart creates a major uncertainty in the buyer's mind and can prevent checkouts.
#5
Unfortunately I have had no time to work on this one as I have been working on a bunch of other projects. For a quick-fix you may want to simply override the theme in order to make the picture switch appropriately.
#6
Hi tjholowaychuk, I just found this module - thank you!
+1 for this feature :)
In the meantime, can you give any tips about how to override the theme function?
#7
Great module...add one more to the request above. Any insight on how to accomplish this through a theme override would be great.
#8
Also looking for a fix as well. If it helps, in "uc_cart.module" on line 1271, you'll find the line:
$data['image'][] = array('data' => drupal_render($form['items'][$i]['image']), 'class' => 'image');
Which appears to be the code to present the image in the cart. Anyone know what to do with this?
#9
Will be adding a "default image" feature in version 6. The support code is already there; just need to add the UI. Once it's working, I'd appreciate any assistance in backporting to 5.x as I no longer have access to a 5.x server.
#10
For what it's worth, I just hacked the UC Cart module to show the option image. I'm using UC Cart 6.x-2.0-beta5 and options images 6.x-1.4. Here's my code (may be a bit simple, but it works).
I haven't fully tested this, but seems to work so far.
Added the following function, which mimics the output of uc_product_get_picture() in UC Product module, at the end of the file:
function uc_cart_get_option_picture($path, $node_id, $format = 'thumbnail') {
$output = '';
$product = node_load($node_id);
if (!module_exists('imagecache') || !($field = variable_get('uc_image_'. $product->type, ''))) {
return '';
}
// Get the current product image widget.
$image_widget = uc_product_get_image_widget();
$image_widget_func = $image_widget['callback'];
if (isset($product->$field)) {
$image = array();
$image['alt'] = $product->title;
$image['title'] = $product->title;
if (file_exists($path)) {
$img = theme('imagecache', $format, $path, $image['alt'], $image['title']);
if ($format == 'thumbnail') {
if ($image_widget) {
$output .= '<a title="'. $image['title'] .'" href="'. imagecache_create_url('product_full', $path) .'" '. $image_widget_func(NULL) .'>';
}
$output .= $img;
if ($image_widget) {
$output .= '</a>';
}
}
else {
$output = l($img, 'node/'. $product->nid, array('html' => TRUE));
}
}
}
return $output;
}
Then I replaced this line:
$form['items'][$i]['image']['#value'] = uc_product_get_picture($display_item['nid']['#value'], 'cart');with this:
if (module_exists('uc_option_image')) {$attribs = $item->data['attributes'];
foreach ($attribs as $key => $value) {
$aid = $key;
$oid = $value;
}
$option_img = uc_option_image_load($display_item['nid']['#value'], $aid, $oid);
$img_path = $option_img->filepath;
$form['items'][$i]['image']['#value'] = uc_cart_get_option_picture($img_path, $item->nid);
}
if (empty($form['items'][$i]['image']['#value'])) {
$form['items'][$i]['image']['#value'] = uc_product_get_picture($display_item['nid']['#value'], 'cart');
}
Now my cart pulls in the selected option image rather than the default product image. I'll attach my hacked copy of uc_cart.module, as well. Hope this helps!
#11
It should be possible for uc_option_image to do the swap via javascript without hacking the cart module.
#12
It would be great if the modules does that by itself but for now the tjmoyer's hack works for me.
#13
+1 for this feature, would be very very handy as customers would probably get confused otherwise
Will use tjmoyers hack until this feature is implemented. Love ya work
#14
Hello,
Has there been any update on this feature request?
I don't like to hack the cart module, but if the option image module has not yet been updated, that appears to be the only option (for me without in depth programming knowledge).
Thanks.
Roger
#15
Hello again,
Just some helpful comments for the hack in #10:
- I had to replace "Thumbnail" in the first code line of the first code block in #10 with my actual imagecache preset. In my case it was "Cart". Otherwise the file is not found.
- The second code block replacement has to be done in uc_cart.module whereas the first one is done in uc_product.module.
Great code, it worked perfectly for me. Thank you very much tjmoyer!
Cheers,
Roger
#16
+1 for this feature request and for quick fix at #10, thanks!
i agree is pretty indispensable to prevent confusion in customers. Any committent would expect this feature, critical IMO.
#17
subscribing
#18
I would also like to see this feature...
#19
See comment #50 in #550344: Option Images Bug Fixes and Enhancements for a patch that adds this functionality without hacking UC. It will require the version of the module from comment #49 in the same post.
#20
Thank you GuyPaddock! The patches work perfectly and no issues as of yet. Hopefully it will get added to the module's next release.
For those unsure about using patch files, below is a zip of the module already patched.
#21
Hi, I use the .zip in this latest post #20; I use Acquia_prosper. And still using this advanced version of the module (the #20), I still see my product image, and underneath the selection, the option_image image? Do I need to change node-product.tpl.php still? Is this related to http://drupal.org/node/803712?
greetings,
Martijn
#22
Hi,
Wouldn't it be great to have not only the cart main picture be changed using option image. But to be able to change all product pictures by the option pictures? See request: http://drupal.org/node/1022638.
Greetings, Martijn
#23
There's no patch here to review.
#24
No activity here? This is bad.
Going to checkout the uc_cart_foo...
#25
YEAH! Finally it works <3
I just removed all other attributes except my option images attribute and damdamdamdam all is working fine.
#26
This is working fine with the latest dev.