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).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    tjholowaychuk’s picture

    Assigned: Unassigned » tjholowaychuk

    Thank you, I like the suggestion I will certainly add this to the todo list :)

    jhebel’s picture

    That's great! Thank you.

    tjholowaychuk’s picture

    Status: Active » Postponed
    ablewave’s picture

    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.

    tjholowaychuk’s picture

    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.

    scottrigby’s picture

    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?

    Poieo’s picture

    Great module...add one more to the request above. Any insight on how to accomplish this through a theme override would be great.

    mattcoady’s picture

    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?

    pillarsdotnet’s picture

    Version: 5.x-1.0-beta2 » 6.x-1.x-dev
    Assigned: tjholowaychuk » pillarsdotnet
    Status: Postponed » Active

    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.

    tjmoyer’s picture

    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!

    pillarsdotnet’s picture

    It should be possible for uc_option_image to do the swap via javascript without hacking the cart module.

    acdtrp’s picture

    It would be great if the modules does that by itself but for now the tjmoyer's hack works for me.

    zapscribbles’s picture

    +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

    Militopedia’s picture

    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

    Militopedia’s picture

    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

    marcoBauli’s picture

    Priority: Normal » Critical

    +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.

    verta’s picture

    subscribing

    guypaddock’s picture

    I would also like to see this feature...

    guypaddock’s picture

    Status: Active » Needs review

    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.

    Bryan T’s picture

    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.

    summit’s picture

    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

    summit’s picture

    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

    pillarsdotnet’s picture

    Assigned: pillarsdotnet » Unassigned
    Status: Needs review » Active

    There's no patch here to review.

    yannickoo’s picture

    No activity here? This is bad.

    Going to checkout the uc_cart_foo...

    yannickoo’s picture

    YEAH! Finally it works <3

    I just removed all other attributes except my option images attribute and damdamdamdam all is working fine.

    cybis’s picture

    Status: Active » Closed (fixed)

    This is working fine with the latest dev.

    khakistocracy’s picture

    Version: 6.x-1.x-dev » 7.x-1.0-beta2
    Status: Closed (fixed) » Active

    Hope nobody minds me re-opening this, but I am having a problem getting my option images to appear in the cart view for D7.. Images appear nicely in the product view, although I have no idea how to translate the patches and fixes for D6 above to help me in D7.

    If anybody has got option images to appear in the cart view in D7 please give me a clue! Thank you.

    fineartist99’s picture

    Any options out there for Ubercart and Drupal 7???