VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: mrRiddle on August 05, 2020, 00:42:29 AM

Title: Getting order details
Post by: mrRiddle on August 05, 2020, 00:42:29 AM
Hi!
I'm writing shippment plugin. Maybe not actually writing, but editing default weight_countries for now  ;)

I'm using plgVmOnUpdateOrderPayment function.
How can I get full order details like product category, units in box etc?

I've tried:

$orderModel = VmModel::getModel();
$details = $orderModel->getOrder($order_id);


but it seems to conflict with my payment gatewey...
Is there any other way? Is it possible to get it directly from  plgVmOnUpdateOrderPayment function?
Title: Re: Getting order details
Post by: pinochico on August 05, 2020, 00:52:36 AM
I don't know, but shipment is shipment because is not payment, then I think trigger for payment is call in another time as trigger for shipment, then order info will be not correct....

better, say what do you want :)
Title: Re: Getting order details
Post by: mrRiddle on August 06, 2020, 01:15:39 AM
I have to do some changes in database after client buy some product.
I came up with idea to write shipment method. Here it is:


function plgVmOnUpdateOrderPayment($cart,$order) {

$zamowienie=(get_object_vars($order));

$status =   $zamowienie['order_status'];
$order_id = $zamowienie['virtuemart_order_id'];
$user_id =  $zamowienie['virtuemart_user_id'];


$orderModel = VmModel::getModel();
$sheep = $orderModel->getOrder($order_id); 
$myJSON=json_encode($order);

if($status == "C"){

$db = JFactory::getDBO ();

$orderModel = VmModel::getModel();
$sheep = $orderModel->getOrder($order_id);
$ship = get_object_vars($sheep["items"][0])    //don't ask about those names

$cat = $ship['category_name'];
$ile = $ship['product_box']

$sql  = "some sql query here";
$db->setQuery ($sql);
$result = $db->execute();
}

return TRUE;
}



I know it isn't beautiful. It's my first "plugin".
That works perfect when I change order status manually.
I have a problem with payment gateway implemetation. Order status doesn't change after payment. When I comment line with "$orderModel->getOrder($order_id)" gateway works fine, but script doesn't work correctly of course.

That's why I'm asking about another method to get order details. I hope then it will work :)