Hi,
By creating a sub order, HikaMarket will include it in his processing.
A sub order is an HikaShop order with the order_type "subsale" and with the "order_parent_id" set with the "order_id" of his parent.
To use the API, you need to create a PHP empty object (stdClass) and fill it with the data you want to save in the database.
Then you can use the "save" function of the HikaShop order class to save and create the sub order.
The HikaMarket class order have some functions to create sub orders but they are "private", the parameters and the structure is mostly internal so I prefer to not make public functions for that. Even if you can call directly the function, you can see the code in order to help you.
The idea is to use the trigger "onAfterOrderCreate" that HikaShop is already using.
Here some sample code ; please understand that I wrote it like that and I didn't test it (so it could have some misspellings or mistakes)
public function onAfterOrderCreate(&$order, &$send_email) {
if(empty($order) || empty($order->order_type) || $order->order_type != 'sale')
return;
if(isset($order->hikamarket->do_not_process))
return;
/** TODO
* define $vendor_id
*/
$o = new stdClass();
$o->order_type = 'subsale';
$o->order_parent_id = $order->order_id;
$o->order_vendor_id = $vendor_id;
$o->order_partner_id = 0;
$o->order_partner_price = 0.0;
$o->order_payment_price = 0.0;
$o->order_shipping_price = 0.0;
$o->order_shipping_tax = 0.0;
$o->order_discount_price = 0.0;
$o->order_discount_tax = 0.0;
$o->order_discount_code = '';
// Create the order product
//
$p = new stdClass();
$p->product_id = 0;
$p->cart_product_id = 0;
$p->order_product_quantity = 1;
$p->order_product_name = JText::_('SHIPPING');
$p->order_product_code = 'shipping';
$p->order_product_price = $order->order_shipping_price;
$p->order_product_vendor_price = $order->order_shipping_price;
$p->no_update_qty = true;
// Create the order "cart" and put the product into
//
$o->cart = new stdClass();
$o->cart->products = array(
$p
);
// Reprocess full price
//
$shopOrderClass = hikashop_get('class.order');
$shopOrderClass->recalculateFullPrice($o, $o->cart->products);
$o->order_vendor_price = $o->order_full_price;
// Store internal data
//
$o->hikamarket = new stdClass();
$o->hikamarket->internal_process = true;
$o->hikamarket->send_email = true;
$o->hikamarket->parent = $order;
$order_id = $shopOrderClass->save($o);
}
It should be a good start to generate a sub sale with the price of the shipping.
Regards,