Hikamarket orders not created correctly

  • Posts: 77
  • Thank you received: 4
4 years 8 months ago #308399

-- HikaShop version -- : 4.1.0
-- Joomla version -- : 3.9.8
-- PHP version -- : 7
-- Error-message(debug-mod must be tuned on) -- : No error, but custom order creation does not work anymore since upgrade to hikashop 4

Hello,
We use hikamarket and hikashop.
I updated to Version 4 from version 3.
I have customised code for shipping handling.
The shipping creates a new order for a specific vendor.
In hikashop 3 it worked well. In hikashop 4, the order is created, but the price is always 0.
Can you please advise ? Looks like something changed in Hikashop/Market Version 4.
Below the used code to create the order in hikashop/market.

Used code:

//Shipping modification
		if(empty($order->order_shipping_id) || $order->order_shipping_id == 5 )
			return; 
		elseif($order->order_shipping_id == 3 || $order->order_shipping_id == 6 || $order->order_shipping_id == 7 || $order->order_shipping_id == 8) 
			$vendor_id = 2 ;  
		elseif($order->order_shipping_id == 1 || $order->order_shipping_id == 4) 
			$vendor_id = 5 ;  
		else
			return;
		
		$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);
		//Shipping modification end

Last edit: 4 years 8 months ago by Jerome. Reason: [code] tag is nice

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 8 months ago #308411

Hello,

Please provide more details about the nature of the issue.
And please note that you can use debug function such as "print_r" or "hikashop_writeToLog" in order to see the content of variables and try to understand your problem.

Regarding the relation with HikaMarket, since you have the "internal_process" variable, HikaMarket should not do anything with the object.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 4
4 years 8 months ago #308417

Hello Jerome,
Thanks for the tips.
The problem is, the order is created in hikashop, but no entries in the hikamarket_order_transaction table. Only for the "real vendor" who is defined for this hikashop product a order_transaction is created.
I attached 2 screenshots. When the order is created, it creates the entriy in the hikashop_order table, but not in the hikamarket_transaction_table. The price is listed correctly for the subsales.
As soon as i set the order to confirmed, the prices of the manually created orders are set to 0 (screenshot 2).
How can i make sure, that the programatically created orders are considered as a "real" order and an entry is also done in the order_transaction table of hikamarket ?
Thank you

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 8 months ago #308493

Hello,

Sorry for the late answer.

Your problem is not related with the HikaShop 4 update ; but I do think that you also made a major update related HikaMarket.
Since HikaMarket 2.0, we introduced the "order transaction" system.
www.hikashop.com/support/documentation/1...arket-changelog.html

Refactoring of the order system to use order transaction and no more extra entries in the HikaShop order table


In the latest releases, we improved that transaction system and because you just create the subsale without any order transaction, you are missing some important data for the HikaMarket process.
HikaMarket need the order transaction to know what the vendor will earn. The "subsale" vendor total contain the full price and that value can change if you add or remove products, the order transaction allow to keep a record of these and know what the vendor earn (or pay) with an history.

Afterwards, if you really want to know what has been stored, you have to look into the database and not what the view is telling you (because without the order transaction, HikaMarket can't process any amount).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 4
4 years 8 months ago #308507

Hello Jerome,

Thanks for the clarification.

How can I programatically correctly save the order, so that hikamarket makes a correct vendor order including filling the order_transaction table.

For sure there is some sample code to create an order in hikamarket.
Can you provide any sample code, please. I could not find it in the hikamarket developer documentation.

Some background information why this is needed.
1. We have products, where more than 1 vendor get some fee. Since only one vendor can be configured in hikasmarket, we need to create additional orders.
2. We also have to credit the shipping fees to different vendors, based on the choosen hikashop shipping method (country related).

Thank you so much.
Regards
Rene

Last edit: 4 years 8 months ago by tgdkere2.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 8 months ago #308531

Hello,

I would need to investigate more and see if some function in the HikaMarket order class should be "open" or not.
For the moment, I would rather recommend you to look at the "Create Order Transaction" function in the HikaShop order class.
The idea is not complicated and you would already have all necessary elements (variables) ; it is just that we store the history of the vendor price (and the state if the vendor has been paid) into the order_transaction table instead of the hikashop order table.
Thanks to that, we create less "holes" in the order IDs and we can have more specific data for HikaMarket processing.
But the main data are the parent order id (the "sale" order_id), the vendor id and its vendor price.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 4
4 years 8 months ago #308559

Hello Jerome,
Thnks, but i don't find any "Create Order Transaction" function in the HikaShop order class.
I even don't find any word "transaction" in the HikaShop order class.
Do you mean hikamarket order class ?
Also there I dont find this function, only CreateTransaction.
Would be nice if the CreateTransaction function would be public in HikaMarket.

However, I dont understand that:
When I save an order in Hikashop with $order_id = $shopOrderClass->save($o); it creates the subsales but not the transactions. Even all the vendor info is there. Are the subsales not needed at all anymore with the latest hikamarket version ?

Regards
Rene

Last edit: 4 years 8 months ago by tgdkere2.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 8 months ago #308586

Hello,

Yes, the exact function name is

private function createTransaction(&$order, $vendor_id, $price = null)
And as I wrote previously, the function is not meant to be public since it's a very advanced function which require very specific parameters ; so you can duplicate a part of the function code but I don't think moving it to public would be good.
As you are not using the API to create the subsale, you should not use an API to create the transaction.

As I explained, the subsale is still a requirement for HikaMarket but storing the vendor price history into the orders are not.
Before HikaMarket 2, you had "subsale" but also "vendorrefund" ; if the vendor was paid for an order and the order was modified, new entries in the order table was created... Which is not the case anymore.

I understand that you want to have a system to assign multiple vendors to products ; I do think it would be better to think about a trigger/API to allow a plugin to do so instead of using partial functions.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 77
  • Thank you received: 4
4 years 8 months ago #308611

Could you or some proposed developer do this ?
If yes, what would be the approximate costs ?

What we would need is:
Credit additional vendors for specific products
Credit the shipping costs to a specific vendor

No GUI needed to make the configs for this. It could be in a simple config file like:
product_id: xyz ; vendor_id: abc ; fee_percentage: 5%
and for the shipping
shipping_id: xyz ; vendor_id: abc

Regards
Rene

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 8 months ago #308631

Hello,

We do not provide any kind of quote or similar in our forum.

If you want to ask for a HikaMarket feature request, please make that suggestion so it will be useful for the entire community.
We cannot accept a feature request which is too specific for one single usage ; our components are made to be flexible and we want to keep that philosophy in mind.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum