is it possible to add product images to product list?

Comments

redhatusr’s picture

starting at line 507 of dc_ajax_add_cart.module

$row[] = array(
  array('data' => '<img src="'.image_style_url('thumbnail', $product->field_image['und'][0]['filename']).'" />' , 'class' => array('image')),          
  array('data' => $quantity, 'class' => array('quantity')),
  array('data' => $product->title, 'class' => array('name')),
  array('data' => $product_prices[$product->product_id], 'class' => array('price')),
  array(
    'data' => l(variable_get(DC_AJAX_ADD_CART_REMOVE_CART, 'link') == 'link' ? t('Remove from cart') : $image_remove_cart,
    'remove-product/nojs/' . $line_item->line_item_id,
    array(
      'attributes' => array(
        'class' => array('use-ajax'),
      ), 'html' => TRUE)), 'class' => array('remove-from-cart')),
);

its seems to working

subhojit777’s picture

Status: Active » Closed (won't fix)

Re #1:
That is not the correct way to add image to the cart. The cart is rendered using dc-ajax-shopping-cart.tpl.php, you can alter the template file and add image to it.

doxigo’s picture

Can you tell us how actually it's being done? to add another custom field (Image in this case) to the template file?

subhojit777’s picture

@doxigo You have to override the preprocess of dc-ajax-shopping-cart.tpl.php, add your product images there, and then override the default dc-ajax-shopping-cart.tpl.php and render the images there.

mozh92’s picture

in file dc_ajax_add_cart.module
we find - function template_preprocess_dc_ajax_add_to_cart_message(&$variables)
and add

//dpm($variables);
  $variables['product_image'] = '';
  if(isset($variables['product']->field_card_image['und'][0]['uri'])) {
    $var = array(
      'style_name' => '216x131',
      'path' => $variables['product']->field_card_image['und'][0]['uri'],
      'alt' => $variables['product_name'],
    );
    $variables['product_image'] = theme_image_style($var);
  }

Use own field from Product field (field_card_image)

and after you can add $product_image in file dc-ajax-add-to-cart-message.tpl.php
for example

<p class="name">
   <?php print $product_image; ?>
   <br />
   <?php print $product_name; ?>
</p>