Project D

Ubercart - uc_upsell div Modification

by admin on Jun.18, 2009, under Linux Blerg

I need to theme the uc_upsell module to suit my need…….

Well If we use ubercart, we absolutely need to use uc_upsell! but the default uc_upsell is a little bit hard to theme, why? because the default uc_upsell although it uses div but the div itself is packed with all the feature such as price / image that we wish to separate in different div class for easy theming.

Thus, I modified the function that outputted the div and separate all the different element into different div.

function theme_pane_upsell($products, $msg = 'Related Products') {
  global $conf;
  if (empty($products)) return '';

 drupal_add_css(drupal_get_path('module', 'uc_upsell') .'/uc_upsell.css');
  $output = '<div id="cart-related-products"><p>'. t($msg) .'</p>';
foreach ($products as $related) {
	$output .= '<div id="category-grid-products-wrapper">';
	$output .= '<div class="category-grid-products-content">';

	$output .= '<div class="catalog-grid-title">';
	$output .= l($related->title, drupal_get_path_alias("node/". $related->nid), array('attributes' => array('class' => 'buy-related-item'), 'html' => TRUE));
	$output .= '</div>';
	$output .= '<div class="catalog-grid-image">';
    if ($related->field_image_cache && file_exists($related->image['filepath'] . $related->field_image_cache[0]['filepath'])) {

	  $output .= l(theme('imagecache', uc_upsell_get_imagecache_preset(), $related->image['filepath'] . $related->field_image_cache[0]['filepath'], $related->title, $related->title, array('class' => 'buy-related-item')), drupal_get_path_alias("node/". $related->nid), array('attributes' => array('class' => 'buy-related-item'), 'html' => TRUE));
    } else {
      //use the default image
      $output .= l(theme('imagecache', uc_upsell_get_imagecache_preset(), 'files/default_product.jpg', $related->title, $related->title, array('class' => 'buy-related-item')), drupal_get_path_alias("node/". $related->nid), array('attributes' => array('class' => 'buy-related-item'), 'html' => TRUE));
    }
	$output .= '</div>';

	$output .= '<div class="catalog-grid-sell-price">';
	$output .= l(uc_currency_format($related->sell_price));
	$output .= '</div>';

	$output .= '<div class="catalog-addtocart-button">';
	      $output .= l(t('Buy now ') , "cart/add/p{$related->nid}_q1-i{$related->nid}Checkout", array('attributes' => array('class' => 'buy-related-item-buynow'), 'query' => 'destination=cart'));
    $output .= '</div>';

	$output .= '</div>';
}
  $output .= '</div>';
  $output .= '</div>';
  $output .= '';
  $output .= '';
  $output .= '';
  return $output;
}

Although its not pretty but, Its usefull.

Enjoy!

-= end transmission =-

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • blinkbits
  • eKudos
  • Live
  • Share/Save/Bookmark

1 Comment for this entry

Leave a Reply

You must be logged in to post a comment.

RSS Fresh Ebuild