News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Plugin for order confirmation

Started by al_foto, February 28, 2013, 15:20:41 PM

Previous topic - Next topic

al_foto

I need some specific code to run after order payment, have found a plugin basis on which to develop it which includes a statement like:

if($order['details']['BT']->order_status == 'C') {
// do something if the order is confirmed.
}


all I need is to get user email and product SKU code for all products in the order ( in a loop).
In old version I used $q = "SELECT first_name,last_name,user_email FROM #__{vm}_order_user_info,#__{vm}_orders ";
$q .= "WHERE #__{vm}_orders.order_id = '".$db->getEscaped($d["order_id"])."' ";
$q .= "AND #__{vm}_orders.user_id = #__{vm}_order_user_info.user_id ";
$q .= "AND #__{vm}_orders.order_id = #__{vm}_order_user_info.order_id ";
$db->query($q);
$db->next_record();
$useremail = $db->f("user_email");
$uname = $db->f("first_name").'%20'.$db->f("last_name");
$q = "SELECT order_item_id, order_item_sku FROM #__{vm}_order_item WHERE order_id=".$db->getEscaped($d['order_id']);
$db->query($q);

while ($db->next_record()) {
//here I call my code
}


but not sure how to do it now with 2.

On the old version I simply edited the ps_order.php file but this went a problem for updating virtuemart, I believe the correct way is a plugin, right ?

Any guide or sample would be appreciated.   :)
Joomla 2.5.9 / Virtuemart 2.0.18a

PRO

you would do this in the payment method plugin

OnConfirmedOrder


reinhold

#2
When a order is posted, VM calls the function plgVmConfirmedOrder($cart, $order) function of all vmshipment, vmcustom, vmpayment and vmcalculation plugins (unfortunately, vmshopper plugins are NOT called, although they would make most sense for this trigger).

If you want this only for some products, I would suggest a custom field plugin and attaching that custom field only to the products that you want to track.
For an example, see my new, free "AcyMailing subscribe Buyers Plugin for VirtueMart 2" (http://www.open-tools.net/virtuemart-2-extensions/vm2-acy-subscribe-buyers-plugin.html ). There, I subscribe the buyer to the AcyMailing lists using the plgVmConfirmedOrder trigger. (You can also see how you can iterate over all order items....)

If you want to call that for every order, it would probably make most sense to us a plugin of type vmcalculation (just a different base class, different plugin dir, everything else is exactly the same as for vmcustom plugins).

al_foto

 
Quote from: reinhold on March 01, 2013, 00:56:39 AM
When a order is posted, VM calls the function plgVmConfirmedOrder($cart, $order) function of all vmshipment, vmcustom, vmpayment and vmcalculation plugins (unfortunately, vmshopper plugins are NOT called, although they would make most sense for this trigger).

If you want this only for some products, I would suggest a custom field plugin and attaching that custom field only to the products that you want to track.
For an example, see my new, free "AcyMailing subscribe Buyers Plugin for VirtueMart 2" (http://www.kainhofer.com/virtuemart-2-extensions/vm2-acy-subscribe-buyers-plugin.html ). There, I subscribe the buyer to the AcyMailing lists using the plgVmConfirmedOrder trigger. (You can also see how you can iterate over all order items....)

If you want to call that for every order, it would probably make most sense to us a plugin of type vmcalculation (just a different base class, different plugin dir, everything else is exactly the same as for vmcustom plugins).


Thanks so much Reinhold, I believe this is what I'm looking for, your code looks great for my purpose.  ;)
Joomla 2.5.9 / Virtuemart 2.0.18a