VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: baroen on June 02, 2014, 23:50:58 PM

Title: setting order status without BE admin site
Post by: baroen on June 02, 2014, 23:50:58 PM
How can I set the status of an order from a 3rd party program?
I want to set the status to sent, after printing a shipping label using the shippers labelsoftware.
That software offers the ability to execute a script to the database, which I use now to record the trackingnumber in the order comment field.
I also want to set the status to sent, after printing a label. But what database changes should I make?
Title: Re: setting order status without BE admin site
Post by: GJC Web Design on June 03, 2014, 00:35:10 AM
UPDATE `jos_virtuemart_orders` SET `order_status` = 'C' WHERE `jos_virtuemart_orders`.`virtuemart_order_id` = 1;

1 is what ever the order id (internal VM id order number)

and the history entry

INSERT INTO `jos_virtuemart_order_histories` (`virtuemart_order_history_id`, `virtuemart_order_id`, `order_status_code`, `customer_notified`, `comments`, `published`, `created_on`, `created_by`, `modified_on`, `modified_by`, `locked_on`, `locked_by`) VALUES (NULL, '1', 'C', '0', '', '1', '2014-06-03 11:23:09', '0', '2014-06-03 11:23:09', '0', '0000-00-00 00:00:00', '0');
Title: Re: setting order status without BE admin site
Post by: baroen on June 03, 2014, 10:14:06 AM
That's what I found also, but I thought I had read somewhere that setting this status directly in the db, does not trigger other automatic actions like setting the same status on all order lines. Perhaps also other things happen in the background?
If this simple update is all thats needed, is would be great offcourse, but I just want to be sure.
Title: Re: setting order status without BE admin site
Post by: GJC Web Design on June 03, 2014, 10:27:43 AM
No changes directly in the database will trigger anything.. for that you need to build and call a plugin to trigger other events
Title: Re: setting order status without BE admin site
Post by: baroen on June 03, 2014, 11:45:39 AM
That's what I meant, sorry for being unclear in my question.
What events are triggered when one sets the order status the normal way, using the VM admin from the BE?
Title: Re: setting order status without BE admin site
Post by: GJC Web Design on June 03, 2014, 12:06:22 PM
from memory  plgVmConfirmedOrder ($cart, $order) is triggered

filter by if($order->order_status == 'C') {...}
Title: Re: setting order status without BE admin site
Post by: baroen on June 03, 2014, 16:16:08 PM
I think that is the information what I am looking for, thanks. Please excuse me if I am pushing your patience, but how do I trigger this from a mysql script? Can I just CALL the plgVmConfirmedOrder.php form within my script?
I am a real PHP newb, how does the syntax of plgVmConfirmedOrder looks like? will just plgVmConfirmedOrder(9877, 1) do for setting order 9877 to status 1?
Title: Re: setting order status without BE admin site
Post by: GJC Web Design on June 03, 2014, 16:26:20 PM
Sorry - will be nothing like that - this is an internal function that is called AFTER you update an order - does what ever house keeping might be needed by other plugins & extensions etc

what your trying to do isn't simple - basically you need to make a POST to the function updatestatus but with all the problems of being outside of Joomla admin etc so your not authorised, no token etc - all the things that stop anyone from posting to your Joomla admin

the post will look like below - but this is hard core coding to integrate it into Joomla admin

order_status=C&comments=&customer_notified=0&customer_notified=1&include_comment=0&include_comment=1&orders%5B140%5D%5Bupdate_lines%5D=0&orders%5B140%5D%5Bupdate_lines%5D=1&task=updatestatus&last_task=updatestatus&option=com_virtuemart&view=orders&coupon_code=&current_order_status=P&virtuemart_order_id=140&d3f4d7ebbccdadd9c357d975c6bf068b=1

If you simply update the DB what are you missing then?  Just the history isn't it unless you do other things after the Status changes?