I think all of this (including my html email problem) is due to some confusion created by the code duplicates in papypal_ipn.php and checkout_process.php. I understand why the order has to be treated in the first in order to be sent to PayPal before entered into the database. But why do the last process tasks (email confirmation, stock update and update bestsellers list) also have to be done within the payment module, within the before_process - function???
I made the following:
1. outcommented the code in paypal_ipn.php between
// initialized for the email confirmation
and end of
tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
with the exception of
tep_session_unregister('cart_PayPal_IPN_ID');
2. changed in checkout_process.php
require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_totals = $order_total_modules->process();
to
if(!class_exists('order_total')) {
include(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_totals = $order_total_modules->process();
}
(if you do not apply this there will be a fatal error "cannot redeclare class order_total...")
It works with one exception (stock and bestseller update not tested as I don't use them): The email confirmation does not contain the order totals. So I tried to add $order_totals to the global vars in function before_process in paypal_ipn.php:
function before_process() {
global $customer_id, $order, $sendto, $billto, $payment, $currencies, $cart, $cart_PayPal_IPN_ID, $order_totals;
Now the order totals showed up in the email but the the order was duplicated in the database - the first marked as verified by paypal the second as pending. In the paypal account only the first was showing up as completed.
I'm sure this is a small issue for a big programmer. Is anyone of them ever reading this "official support for paypal_ipn"?