Crossposted from the General board:
http://forum.virtuemart.net/index.php?topic=95153.0
I've got Paypal (Sandbox) configured and working for VM2.0.0 on J!1.7.3. All my shoppers are anonymous (not registered / logged in).
Mostly works well, but for some reason that I can't yet fathom, successful orders return to the VM store but instead of seeing your order details, the shopper sees an error:
You must provide at least one recipient email address.
Invalid address: You must provide at least one recipient email address.
It seems in my case that when Paypal confirms the payment, VM2.0.0 on J!1.7.3 is trying to send 4 emails, of which only three get delivered and one fails:
Delivered to Shop admin address:
[7cbcae91], Confirmed order by Mr Mike Thomson, total £40.00
[], Confirmed order by Mr Mike Thomson, total £10.00
Delivered to shopper's address:
[7cbcae91], Confirmed order at Online Gallery, total £40.00
It seems that the spurious emails both relate to an empty order with a default shipping cost of £10 and no order items. I think this is what's triggering the error, as there's no shopper associated with the empty order, therefore no email address when it's attempted to be sent to them.
OK, a rather unsatisfactory workaround follows;
o The desired order is placed as you'd expect (this is good)
o You don't get the spurious email to the store admin address (this is good)
o The shopper doesn't get the 'you must provide at least 1 recipient emaill address' error (this is good too)
o The shopper doesn't see the page with their order on it, just a 'thanks for your order' message (this is sub-optimal).
However, I have no idea yet why this behaviour (duplicate triggers from Paypal?) is being provoked.
Anyone else able / interested in digging deeper?
Cheers
Mike
# diff -u ./components/com_virtuemart/controllers/*pluginresponse.php
--- ./components/com_virtuemart/controllers/ORIGINAL_pluginresponse.php 2012-01-02 19:55:57.000000000 +0100
+++ ./components/com_virtuemart/controllers/pluginresponse.php 2012-01-02 21:30:34.000000000 +0100
@@ -85,10 +85,14 @@
$order = new VirtueMartModelOrders();
$orderitems = $order->getOrder($virtuemart_order_id);
//vmdebug('PaymentResponseReceived CART', $orderitems);
- $cart->sentOrderConfirmedEmail($orderitems);
- //We delete the old stuff
- $cart->emptyCart();
+ if ( ! empty($orderitems['items'])) {
+ $cart->sentOrderConfirmedEmail($orderitems);
+ //We delete the old stuff
+
+ $cart->emptyCart();
+ }
+
break; // This was the active plugin, so there's nothing left to do here.
}
}
I have no idea why this happened, but after testing on a fresh install of J!1.7.3 and VM2.0.0 (stable) I can't reproduce the problem, so it's clearly a PEBCAK - Problem Exists Between Chair And Keyboard.