Thank you
Printable View
Thank you
Hi,
I am using the Swipe HQ payment module, I also have quantity discounts installed. For some reason on the order confirmation e-mail the discount gets taken of the total twice - it doesn't do this anywhere else, just on the confirmation e-mail and only when using the swipeHQ payment module.
Below is the code I believe to be responsible for sending the order confirmation e-mail from the swipehq module:
//send emails
if (!empty($_REQUEST['user_data'])) {
$order_id = $_REQUEST['user_data'];
if (!empty($_SESSION['swipehq_order_' . $order_id])) {
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
require_once('includes/languages/english/checkout_process.php');
require_once(DIR_WS_CLASSES . 'order.php');
require_once(DIR_WS_CLASSES . 'payment.php');
$payment_class = new payment($_SESSION['payment']);
$order = unserialize($_SESSION['swipehq_order_' . $order_id]);
require_once(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_totals = $order_total_modules->process();
$order->send_order_email($order_id, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');
}
}
For some reason this is causing zencart to take the discount of the total twice (but only on the order confirmation e-mail).
Below is an example of what the confirmation e-mail looks like:
Sub-Total: $135.60
Fastways Courier
(Delivery to 2110 - Please allow 2-3 working days for delivery once payment has been confirmed1 box(es) 1.16kg(s)): $4.50
Quantity Discount: -$6.78
GST: $16.52
Total: $126.54 (This should be $133.32, but instead of the correct discount of 6.78 being applied, 13.56 is being taken of the total)
I have e-mailed SwipeHQ re this, but they say it is due to the mods I have installed and can't help.
I believe it is the code below that is causing the problem, but can't figure out what I could change to get the confirmation e-mail sent with the correct total.
require_once(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_totals = $order_total_modules->process();
Any help would be very appreciated.
Thanks,
Mike.
You're going to have to do some debugging. Start printing out the variables after the line that says $order = unserialize($_SESSION['swipehq_order_' . $order_id]);
and see where things are going awry.
Hi,
Sorry, I am not very good at PHP - I tried using print_r and echo to print the variables, but it is just causing the site to crash. How do I go about printing variables?
(I have also check Zencarts error log but there is nothing coming up in there).
Thanks,
Mike.
Hi again,
Just found this post: http://www.zen-cart.com/showthread.p...tudy-variables, I will give some of the suggestions here a go and report back. Thanks for pointing me in the right direction Scott.
Regards,
Mike
Hi again,
Below is the contents of the order_total array being used for the confirmation e-mail.
order_total Object
(
[modules] => Array
(
[0] => ot_subtotal.php
[1] => ot_shipping.php
[2] => ot_quantity_discount.php
[3] => ot_tax.php
[4] => ot_total.php
)
)
</pre><br><br> <pre>Array
(
[0] => Array
(
[code] => ot_subtotal
[title] => Sub-Total:
[text] => $135.60
[value] => 135.6
[sort_order] => 100
)
[1] => Array
(
[code] => ot_shipping
[title] => Fastways Courier (Delivery to <b>2110</b> - Please allow 2-3 working days for delivery once payment has been confirmed<br>1 box(es) 1.16kg(s)):
[text] => $4.50
[value] => 4.49995
[sort_order] => 200
)
[2] => Array
(
[code] => ot_quantity_discount
[title] => Quantity Discount:
[text] => -$6.78
[value] => 6.78
[sort_order] => 295
)
[3] => Array
(
[code] => ot_tax
[title] => GST:
[text] => $16.52
[value] => 16.51695
[sort_order] => 300
)
[4] => Array
(
[code] => ot_total
[title] => Total:
[text] => $126.54
[value] => 126.53995
[sort_order] => 999
)
All information is correct with the exception of the total. I can only assume that the swipehq code is somehow telling the order_total module to take the discount of the total twice - although I can't figure out where or how. Any ideas?
Thanks,
Mike
I'll bet you the same thing happens if you use the (built in) Group Discounting module, btw.
Try this: Instead of creating a new $order_total_modules, unserialize it the way you unserialize the order (you would of course have to serialize it when you serialize the order too).
Hi Scott,
You were correct in your assumption. I have been talking with SwipeHQ about your suggestion, but have been stonewalled. I tried to work it out myself but couldn't get it to work (mostly because it was trial and error and I really don’t know what I am doing).
The other thought I had was would it be possible to pull the information from the database (like the admin invoice does)? I've look at the tables but can't find where the quantity discount is recorded.
Thanks,
Mike.
It's in the order totals table. Sorry they're not cooperating - did you tell them the same problem will exist with built-in Group Discounts?
Thanks, I obviously didn't look far enough through the orders to find one that qualified for a discount (silly me)
Yes, I mentioned to them that the issue wasn't just with the mod, I think they are just to busy to care at the moment.
Could I perhaps try something likes this:
$order_totals = $db->Execute("select , text, from " . TABLE_ORDER_TOTALS . "
where orders_id = '" . (int)$oID . "'");
Although now that I have written that it doesn't look like it would work.
Regards,
Mike.