
Originally Posted by
vandijkstef
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.
The v1.5.x (and earlier versions) architecture of Zen Cart's checkout flow doesn't store the order in the db until after the payment module completes its steps.
The normal flow is that the payment module runs its before_process() method to take the data from the payment page and submit it in real-time to the payment gateway (or receive the response from the offsite gateway after completing payment and returning to the site). Then optionally runs an after_process() method if present (often just to update internal logs, if anything at all).
Then it writes the order to the database. The premise here is that only the orders that have been accepted by the payment process (ie: usually this means "payment received" or at least payment is pending because of a valid credit card authorization or the customer has agreed to send a check in the mail) actually make it into the database.
Then it sends the email.
Then it shows the checkout-success page to the customer.
The money_order.php module is an example of allowing pending-payment orders to get saved.
As for skipping the email confirmation, there's nothing in that part of the code to detect which payment method was used in order to take alternate action.
As much as I hate using $GLOBALS, you could add a line to the beginning of the send_order_email() method of the order class to check something like
Code:
if ($GLOBALS[$_SESSION['payment']]->code == 'my_module_code_string') return;
That would check the comparison against this line in your payment module:
Code:
$this->code = 'my_module_code_string';