I had an idea to solve that, but maybe I complicated it too much:
As configuration is set to use the same order_id for sale and subsale as well, I should just solve somehow to load order_id not from the #__hikashop_order table's order_id column, but from a column I added manually.
So I added a new column in phpMyAdmin: 'order_bif_az' with type: int(10)
I created a hikashop plugin, with this content (used history plugin for base):
<?php
class plgHikashopBifupdate extends JPlugin
{
function plgHikashopBifupdate(&$subject, $config){
parent::__construct($subject, $config);
if(!isset($this->params)){
$plugin = JPluginHelper::getPlugin('hikashop', 'bifupdate');
if(version_compare(JVERSION,'2.5','<')){
jimport('joomla.html.parameter');
$this->params = new JParameter($plugin->params);
} else {
$this->params = new JRegistry($plugin->params);
}
}
}
function onAfterOrderCreate(&$order,&$send_email){
$db = JFactory::getDBO();
$query = 'UPDATE '.hikashop_table('order').' SET '.hikashop_table('order').'.order_bif_az = (SELECT MAX(order_bif_az)+1) WHERE'.hikashop_table('order').'.order_id = '.$order->order_id.' AND '.hikashop_table('order').'.order_type = SALE;
$db->setQuery($query);
}
}
This should update the freshly created order's order_bif_az row with +1
As it not worked I also tried adding SQL update query to /admin/com_hikashop/helpers/helper.php to around line 256., in function hikashop_encode:
if(is_object($data)){
function hikashop_encode(&$data,$type='order', $format = '') {
$id = null;
if(is_object($data)){
if($type=='order')
$db = JFactory::getDBO();
$query = 'UPDATE '.hikashop_table('order').' SET '.hikashop_table('order').'.order_bif_az = (SELECT MAX(order_bif_az)+1) WHERE'.hikashop_table('order').'.order_id = '.$data->order_id.' AND '.hikashop_table('order').'.order_type = SALE';
$db->setQuery($query);
$id = $data->order_bif_az;
if($type=='invoice')
$id = $data->order_invoice_id;
}
I also changed line from:
to
$id = $data->order_bif_az;
nondepending from where the SQL syntax is given (plugin or helper.php).
But update sql is not running on, also $id = $data->order_bif_az is not OK.
Where am I wrong?