uc_wishlist Ubercart v1.x hacks / fixes

c0psrul3's picture
Offline
Joined: 10/07/2007
Juice: 95
uc_wishlist Ubercart v1.x hacks / fixes

I did this in about 15 minutes so suggestions are greatly appreciated if not encouraged.

I am using these hacks for demonstration that nothing is extremely wrong here.

<?php
/**
* Display a page allowing the customer to view his/her wish list.
*/
function uc_wishlist_view_form($items, $wid, $own) {
/***  TODO: FIX: $items was not being passed so we load them just like before in uc_wishlist_view()  */
if (!$items) {
 
$items = uc_wishlist_get_contents($wid);
}
 
$form['items'] = array('#tree' => TRUE);

 

$i = 0;
  foreach(
$items as $item) {
   
$item->module = 'uc_product';   /**** TODO: WORKAROUND: my objects were not showing $item->module so i injected it here */
   
$display_item = module_invoke($item->module, 'wishlist_display', $item, $own);
    if (!empty(
$display_item)) {
     
$form['items'][$i] = $display_item;
     
$i++;
    }
  }

  if ((

$page = variable_get('uc_continue_shopping_url', '')) != '<none>' &&
     
variable_get('uc_continue_shopping_type', 'link') == 'button') {
   
$form['continue_shopping'] = array(
     
'#type' => 'submit',
     
'#value' => variable_get('uc_continue_shopping_text', t('Continue shopping')),
    );
  }

 

$form['wid'] = array(
   
'#type' => 'hidden',
   
'#value' => $wid,
  );
  if (
$own) {
   
$form['own'] = array(
     
'#type' => 'hidden',
     
'#value' => true,
    );
   
$form['update'] = array(
     
'#type' => 'submit',
     
'#value' => t('Save wish list'),
    );
  }
  return
$form;
}
?>
Wish list/gift registry module By: detour (42 replies) Thu, 10/18/2007 - 02:30