
Originally Posted by
vandijkstef
Your solution sounds template specific, not module specific. In this case my "vanilla" payment methods will probably break (CoD/Freeshipper/moneyorder etc.)
Is this file being called upon leaving the store to a payment gateway, or upon return from the payment gateway?
My guess it's upon leaving to a gateway, not sure..
I now see this function "$payment_modules->before_process();", I'll dive into that.
Umm, not sure what you mean by module specific when the solution provided is to modify a module that is (happens to be) template overrideable...
If referring to making that change only for a specific payment module, then that was not initially expressed and therefore a suggestion/solution was not provided to address the one specific payment module that is in question. If that is the case/desired then the edit provided by lat9 could be modified to account for which payment module is being used/processing the payment and therefore could provide the email action in the above code for all payment modules except the one that needs to be handled separately.
As for when the file is being processed, it is somewhat of a yes to your question of before or after the payment module has processed it... Perhaps your solution does lie within the before_process code for the applicable payment processor such that it has the appropriate checks to allow completion of the process outlined in the module (without edit) or perhaps the need for observers to integrate with the notifiers that have been provided... There are other notifiers (includes/classes/order.php) that can be used to modify the email being sent or not, and then later the email could be sent if the modifications in the before_process function above are not sufficient to provide the end goal.
Again though, the posted request was:
I'm looking for a way to:
- Still get the order in the database upon leaving ZC to a payment page.
- NOT send the order confirmation. I'll call this function later on.
And the solution provided did that...
To identify the payment module, could modify lat9's suggestion to something like the following:
Code:
// load the before_process function from the payment modules
$payment_modules->before_process();
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_BEFOREPROCESS');
// create the order record
$insert_id = $order->create($order_totals, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE');
$payment_modules->after_order_create($insert_id);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_AFTER_ORDER_CREATE');
// store the product info to the order
$order->create_add_products($insert_id);
$_SESSION['order_number_created'] = $insert_id;
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS');
//send email notifications
if ($GLOBALS[$payment_modules->selected_module]->code != 'specialpaymentmodule') {
$order->send_order_email($insert_id, 2);
}
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');
Where $payment_modules->selected_module identifies the payment module... The above would perform the send_order_email action if the payment module of choice for the order is anything but specialpaymentmodule...