VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: mtaras on March 24, 2012, 09:27:56 AM

Title: [SOLVED] How to get the order id after the order confirmed?
Post by: mtaras on March 24, 2012, 09:27:56 AM
Hi,
I try to develop a simple custom plugin.
I have use the
function plgVmConfirmedOrder($cart, $order) to do some calls when an order confirmed.
But how can I get the order id when the user  confirm the order? As I can see there is no post data on the confirm form.

Some help please.

Thanks
Title: Re: How to get the order id after the order confirmed?
Post by: carsten888 on March 24, 2012, 10:07:24 AM
In those functions the order number is available
$order['details']['BT']->order_number
so try
$order['details']['BT']->virtuemart_order_id
if that does not work, query the id from the order number

To call some script when the order is confirmed I use function plgVmOnPaymentNotification()
in that function:
if($paypal_data['payment_status']=='Completed'){
$this->add_sold_product_to_counter($virtuemart_order_id);
}


I hope that helps
Title: Re: How to get the order id after the order confirmed?
Post by: mtaras on March 26, 2012, 13:59:40 PM
Thanks for your help.
I understand the call of $order['details']['BT']->order_number but I have problem how to catch the $order var.
In paypal payment plugin these is some code like
$paypal_data = JRequest::get('post');
to retrieve the data from payment and then
$order_number = $paypal_data['invoice'];
$virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($paypal_data['invoice']);
to get the id. Then it is clearly how to retrive data.

With your code example we need to have the $order var filled with data and then to use it.
I want to use my custom plugin to all payment methods, not only on some install like paypal.

So I need to know how can I access the $order var.

Some help on this issue?

Thanks

Title: Re: How to get the order id after the order confirmed?
Post by: mtaras on March 26, 2012, 14:50:32 PM
OK I found the solution. I need to create payment plugin and not custom. When I create payment vm plugin the $order var is accessible.

Thanks.
Title: Re: [SOLVED] How to get the order id after the order confirmed?
Post by: pm4698 on July 06, 2016, 08:05:09 AM
can you tell me how you did this?hoe you called vm paymebt plugin and how the first function?