Inserting an order through a plugin

  • Posts: 49
  • Thank you received: 4
6 years 10 months ago #285047

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.3
-- PHP version -- : 7.0.26
-- Browser(s) name and version -- : any
-- Error-message(debug-mod must be tuned on) -- : no error

Hello,

I try to create a new order through a plugin, but it is not displayed in the the orders page. I tried using two different methods:

First using the order API:

		$order = new stdClass();
		$order->order_billing_address_id = 3;
		$order->order_shipping_address_id = 3;
		$order->order_user_id = 1;
		$order->order_status = 'refunded';
		$order->order_type = 'retour';
		$order->order_number = 'RET'.substr($curr_time, -4);
		$order->order_created = $curr_time;
		$order->order_modified = $curr_time;
		$order->order_currency_id = '151';
		$order->order_full_price = (($result[0]->price_value) * ($prod_tax + 1));
		$order->order_tax_info = $prod_tax_info;
		$order->order_payment_id = '11';
		$order->order_payment_method = 'check';
		$order->order_shipping_id = '6';
		$order->order_shipping_method = 'manual';
		$order->order_shipping_params = 'O:8:\"stdClass\":1:{s:6:\"prices\";a:1:{s:3:\"6@0\";O:8:\"stdClass\":2:{s:14:\"price_with_tax\";s:7:\"0.00000\";s:3:\"tax\";d:0;}}}';
		$order->order_ip = '188.155.141.69';
		$order->order_currency_info = 'O:8:\"stdClass\":4:{s:13:\"currency_code\";s:3:\"CHF\";s:13:\"currency_rate\";s:7:\"1.00000\";s:20:\"currency_percent_fee\";s:4:\"0.00\";s:17:\"currency_modified\";s:10:\"1447973156\";}';
		$order->order_token = 'xxxx';

		$product = new stdClass();
		$product->order_product_quantity = 1;
		$product->order_product_price = $result[0]->price_value;
		$product->order_product_tax = ($result[0]->price_value) * $prod_tax;
		$product->product_id = $retour_prod_id;
		$product->order_id = $retour_order_id;
		$product->order_product_name = $result[0]->product_name;
		$product->order_product_code = $result[0]->product_code;
		$product->order_product_price = $result[0]->price_value;
		$product->order_product_tax = ($result[0]->price_value) * $prod_tax;
		$product->order_product_tax_info = $prod_tax_info;
		$product->order_product_shipping_id = '6@0';
		$product->order_product_shipping_method = 'manual';
		
		$order->products = array($product);
		$orderClass = hikashop_get('class.order');
		$orderClass->save($order);
In this case it is creating the element in the "xx_hikashop_order" database table, but not in the "xx_hikashop_order_product" one. What is missing so that the order appears in the order admin list?


The other method I created is by inserting directly the elements in the tables "xx_hikashop_order", "xx_hikashop_history" & "xx_hikashop_order_product" and updating the product quantity in the table "xx_hikashop_product".
Although everything seems to be fine, the new orders do not appear in the hikashop back-end.

Last edit: 6 years 10 months ago by Jerome. Reason: [code] tag is REALLY marvelous for posting code

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 10 months ago #285049

Hi,

Only orders of the type "sale" will be displayed in the orders listing of the backend of HikaShop.
Orders of the type "subsale" (for HikaMarket vendor sub-sales) or "partner" (for commission payments to partners of the affiliate system) are not displayed there either.
If you want your order to appear on the orders listing you need to change its type to "sale".

Regarding the products, you need to have them in $order->cart->products and not $order->products

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

  • Posts: 49
  • Thank you received: 4
6 years 10 months ago #285096

Great, thanks

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

Time to create page: 0.059 seconds
Powered by Kunena Forum