Jump to content

Show Voucher SQL Statement


Recommended Posts

Hello :)

 

Im trying to figure out HOW to show the USED voucher on the Orders tab in BO.

 

I have found the place to edit in the AdminOrderController.php i just need to GET the used voucher based on order.

 

Can someone point me in the right direction with the SQL Statement?

 

Starting on Line 31 - 68 i have this:

 

public function __construct()
{
 $this->table = 'order';
 $this->className = 'Order';
 $this->lang = false;
 $this->addRowAction('view');
 $this->explicitSelect = true;
 $this->deleted = false;
 $this->context = Context::getContext();
 $this->_select = '
 a.id_currency,
 a.id_order AS id_pdf,
 CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
 osl.`name` AS `osname`,
 os.`color`,
 IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new';
 $this->_join = '
 LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
 LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
 LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
 $this->_orderBy = 'id_order';
 $this->_orderWay = 'DESC';
 $statuses_array = array();
 $statuses = OrderState::getOrderStates((int)$this->context->language->id);
 foreach ($statuses as $status)
  $statuses_array[$status['id_order_state']] = $status['name'];
 $this->fields_list = array(
 'id_order' => array(
  'title' => $this->l('ID'),
  'align' => 'center',
  'width' => 25
 ),

 

And in the buttom instead of:

 

$this->fields_list = array(

'id_order' => array(

'title' => $this->l('ID'),

'align' => 'center',

'width' => 25

 

I need:

 

$this->fields_list = array(

'id_order' => array(

'title' => $this->l('Voucher'),

'align' => 'center',

'width' => 25

 

 

Hope someone can help me out :huh:

Link to comment
Share on other sites

I have this, i just dunno how to put it in the array, so i can show the name of the voucher.

 

I have this working code:

 

SELECT ps_orders.*, ps_order_cart_rule.* FROM ps_orders, ps_order_cart_rule WHERE ps_orders.id_order = ps_order_cart_rule.id_order;

Link to comment
Share on other sites

×
×
  • Create New...