Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Creating addon - have list of orders in template Rate Topic   - - - - -

 
  • dansmithpm
  • Newbie
  • Members
  • Join Date: 08-Feb 12
  • 4 posts

Posted 16 December 2012 - 11:47 PM #1

In the middle of creating a new addon and in my update.tpl form I'm trying to have a select box with the recent order list in it, then once an item is selected, parse the value to specific fields.

The parsing bit can simply be done by javascript with the value field of the select having contatenated values from a table, though where do I have to put the code for the database lookup?

hope that makes sense

 
  • dansmithpm
  • Newbie
  • Members
  • Join Date: 08-Feb 12
  • 4 posts

Posted 19 December 2012 - 11:25 PM #2

figured this out.- adding here in case it can help someone else

1. in my addon's func.php added custom function


function fn_getorderlist() {
$data=db_get_array('select concat(order_id,"%",total,"%",shipping_cost,"%",firstname," ",lastname,"%",email) as odata, order_id from ?:orders order by order_id desc;');
return $data;

}


in the main controller added

$view->assign('order_data',fn_getorderlist());

then in the template used {foreach} loop to create the select box, using the order_data. had an onchange javascript event to take the value, split to individual elements and apply the values to the relevant fields on the template.