Reputation: 680
I have a module that is responsible for handling special products in ubercart (product kits). The module is responsible for crafting a product kit on the fly based on choices a user has made. I've used the function below in my uc_bundle_manager.module file. I can't seem to figure out how to render the output in my theme (as a block). I'm not sure how to access or created the $vars variable so that it may be used in my template. Currently the function just returns the node idea of the correct product kit (this is working just fine in my debug output). Any help is greatly appreciated. thanks!
function clothing_filter_form_submit($form, &$form_state)
{
/*--Form Values--*/
$vals = array($form_state['values']['shirt'],$form_state['values']['hoodie'],$form_state['values']['hats']);
/*--DB isn't setup for this relationship. Maybe a better SQL query is better but TODO--*/
$sql = "SELECT nid, product_id FROM uc_product_kits";
$result = db_query($sql);
while($row = mysql_fetch_assoc($result))
{
$rid = $row['nid'];
$bundles[$rid][] = $row['product_id'];
}
foreach($bundles as $key => $bundle)
{
$count = 0;
foreach($vals as $val)
{
if(in_array($val,$bundle))
{
$count++;
}
}
//--If we match 3 items--//
if($count == 3)
{
$selected_bundle = $key;
}
}
return $selected_bundle;
}
Upvotes: 1
Views: 177
Reputation: 2587
You will need to use the hook_block_info() function to generate a block. I am assuming you are using d7.
Below is a sample code
/**
* Implements hook_block_info().
*/
function trails_block_info() {
$blocks['history'] = array(
'info' => t('History'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
Cheers, vishal
Upvotes: 1