News:

Support the VirtueMart project and become a member

Main Menu

Getting order details

Started by mrRiddle, August 05, 2020, 00:42:29 AM

Previous topic - Next topic

mrRiddle

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?

pinochico

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 :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

mrRiddle

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 :)