News:

Looking for documentation? Take a look on our wiki

Main Menu

Modify plugin to set confirmed some orders

Started by supermac, February 29, 2012, 13:23:02 PM

Previous topic - Next topic

supermac

I'd like to set automatically confirmed the orders made with a payment named "cash" (that use standard payment plugin).

I now that is a "dirty solution" and I'm not a php programmer, but I think that to obtain what I need I should modify the php file \plugins\vmpayment\standard\standard.php (<-please confirm if that's right)
And I think I should write some rows of code into function plgVmConfirmedOrder($cart, $order) (<-please confirm if that's right)

In detail, I should check if
$this->processConfirmedOrderPaymentResponse(true, $cart, $order, $html);
returns true then I should write something that sounds like
"if payment's name is 'cash' set order_status = 'C' in jos_virtuemart_orders WHERE order_number (or virtuemar_order_id) = x" (<-please confirm if that's right)
and then exit the function returning true or false as above.

If that's right and someone support me I'd like to try...

To change the order_status I seen that Paypal plugin use the following code:
$method = $this->getVmPluginMethod($payment->virtuemart_paymentmethod_id);
$new_status = $method->status_success;

if ($virtuemart_order_id) {
    if (!class_exists('VirtueMartModelOrders'))
require( JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php' );
    $modelOrder = new VirtueMartModelOrders();
    $order['order_status'] = $new_status;
    $order['virtuemart_order_id'] = $virtuemart_order_id;
    $order['customer_notified'] = 1;
    $order['comments'] = JTExt::sprintf('VMPAYMENT_PAYPAL_PAYMENT_CONFIRMED', $order_number);
    $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, true);
}

May I reuse it in standard plugin?

alatak

Hi,

yes the code you gave is the correct one.

QuoteMay I reuse it in standard plugin?
Yes of course :).

supermac

Mistake: I've to set 'S' the order_status, not 'C'

Question:
when I set 'S' in order_status, stock quantity and ordered quantity update automatically (updateStatusForOneOrder do that too?) or have I to do something else?

Dishmaster J

Hey supermac,

I'm also trying to setup a payment method to automatically confirm and I was wondering if your code ended up working and if so could you explain where to insert it (I'm also not a php programer).

Thanks!

alatak

Hello,

In the latest version of VM, we have added a paramter for the standard payment plugin: "Order Status for Pending transactions"
Just set it to confirm, and it will work :)

Dishmaster J

Thanks so much for the response alatak!

I'm running version 2.0.10 but I can't seem to find where to enable the "Order Status for Pending transactions" parameter you mentioned. Is it supposed to appear in the "VM-Payment, Standard" window of the plugin manager or somewhere within the VirtueMart menus? I'm attaching a screen grab of my Standard Payment plugin in case I'm just missing where the parameter is.

Thanks again!



[attachment cleanup by admin]

alatak

Hello

Just like all the plugins in VirtueMart, you should create a VirtueMart payment methods, and the parameters are there. They do not appear in the Joomla plugin manager.
I don't remember when i have added this feature. May it is only available in one of the 2.0.11 versions.

Dishmaster J

Okay great! Thanks for the guidance. It doesn't appear to be an option in the payment methods area so it must be in the 2.0.11 version.

I'm excited for the update and thanks for adding this function!