News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Order confirmation email sent before PayPal payment processed

Started by davidm, May 01, 2008, 12:57:41 PM

Previous topic - Next topic

Datatonic

Brilliant stuff,

I always found it odd that this was never a properly implemented option, especially for instant payment methods.

I understand the pending order email's use for cheques/cod/po's etc but when you take someone's credit card details the email should only go out after the transaction has been completed.

I suppose to cover all edge cases, it would be good to send the invoice on confirmed and a different email on pending - so that a user knows the order has been placed and either - in the case of echeques they need to wait or in the case of an error, that it needs attention.

I look forward to trying this out myself.

angek

OK guys, here's the alpha release of the patch.
Please be sure to back up the components/com_virtuemart and administrator/components/com_virtuemart directories before applying this patch.

Your feedback, suggestions etc are most welcome.

[attachment cleanup by admin]

Datatonic

All seems to be working nicely, but the customer is still getting the status changed email.

Any thoughts?

Thanks again for a great improvement to VM.

I'm going to look into putting this in place with PayPal Pro in the next couple of days, it will be the UK version, but will keep you posted.

angek


cinos

Just tried it out and I'm getting the same problem as Datatonic in that the status changed email is still sent (the one informing of the change from pending to confirmed).

Also the customer is not actually getting the invoice email. :(

Basically I (the seller) recieve the pending purchase order and the customer (when payment has been recieved) gets a status change email and a paypal payment confirmation email. No invoice.

Anyone else finding this?

cinos

Just restored the back up and the purchase order is being sent to the customer again. Albeit at the old, bad time (pending status).

Another problem I noticed with the patch was that the option to surpress the email didn't appear to make a difference, regardless of whether it was turned off or on. Though this was most likely because the email was actually not sending in the first place. :)

Datatonic

Hi, there seems to be another problem.

The purchase order is being suppressed to the customer for all payment methods, rather than just PayPal.

I've decided to go down another route, using your idea as a starting point.

My aim is to have things run as follows:-


  • Purchase Order is sent out to all customers.
  • Order Status Email is sent after transaction.
  • If Order Status Changes to Pending (for PayPal Echeques and Purchase Orders), normal order status email is sent
  • If Order Status Changes to Confirmed, email contains a link to generate invoice.

When link in Confirmed Status email is clicked, they are taken to a page that does similar to the current operations you have in Checkout.Result.php, whereby both Vendor and Customer are sent an invoice.

This for me covers all bases and does what I need.

Hope you get the status email and purchase order suppression sorted. 

Thanks again for all your work on a very useful mod.

Ro.

Datatonic

Hi I have gone down another route and sucessfully implemented it.

In this method the customer receives the purchase order as normal (although this could be shut off)

They then receive the order status change email.

In the order status change email, if their order status is confirmed they are presented with a link to a new checkout.invoice.php page.

If their order status is anything other than confirmed, they are shown the original link.

If they are not logged in they are prompted to do so, and as Virtuemart seems to be refusing to re-direct at login for me, I have added a javascript backlink to the com_user page.

Then when they return to (or go straight to if already logged in) the checkout.index.php page, they are presented with some text stating that their invoice has been processed and sent.

This page calls a new class ps_send_invoice.php which sends out the Invoice Email to the customer.

It is a very long winded way of doing things and I'm sure I'll change it, it just seemed to be the best way of dealing with things, as I have PayPal, PayPalPro and Purchase Order as payment methods.  I also have purchase codes associated to orders that are only displayed in the confirmation email and order details once an order is confirmed.

If anyone would like the files, let me know.

Ro.

brandonjp

Well done, Datatonic!!  Based on this thread...I think we'd all be interested, especially if it actually works.  You should post them on this thread.

Quote from: Datatonic on February 04, 2009, 03:16:46 AM
Hi I have gone down another route and sucessfully implemented it.

In this method the customer receives the purchase order as normal (although this could be shut off)

They then receive the order status change email.

In the order status change email, if their order status is confirmed they are presented with a link to a new checkout.invoice.php page.

If their order status is anything other than confirmed, they are shown the original link.

If they are not logged in they are prompted to do so, and as Virtuemart seems to be refusing to re-direct at login for me, I have added a javascript backlink to the com_user page.

Then when they return to (or go straight to if already logged in) the checkout.index.php page, they are presented with some text stating that their invoice has been processed and sent.

This page calls a new class ps_send_invoice.php which sends out the Invoice Email to the customer.

It is a very long winded way of doing things and I'm sure I'll change it, it just seemed to be the best way of dealing with things, as I have PayPal, PayPalPro and Purchase Order as payment methods.  I also have purchase codes associated to orders that are only displayed in the confirmation email and order details once an order is confirmed.

If anyone would like the files, let me know.

Ro.

Datatonic

Shall do.

Have now changed it a little so that there is no clicking involved for the customer.

Have also changed notify customer so that differant messages are sent for differant statuses.

Will have it finished in a day or so then will post the code.

RO.

Datatonic

Ok this is now finished and tested as working on my system.  Joomla 1.5.9 and Virtuemart 1.1.3.  I have stripped the files of all other mods I have made, so they are additions to the vanilla 1.1.3 files.

The files in the zip are as follows:-

/administrator/components/com_virtuemart/languages/common/english.php

Changes are to include the new status change methods and include the new invoice label.  If you have modified the default file in any way you will need to merge my changes into your version.  If you have a vanilla install you can simply overwrite it.

/administrator/components/com_virtuemart/classes/ps_order.php

Changes are changing the messages and if required URL's used in the order status changed emails.  Call added to new class and function to send invoice on order status changing to confirmed.

If you have modified the default file in any way you will need to merge my changes into your version.  If you have a vanilla install you can simply overwrite it.

/administrator/components/com_virtuemart/classes/ps_send_invoice.php

Brand new file (basically a cloned and edited ps_checkout.php but it does the job nicely.  Simply copy this into the classes folder.

/components/com_virtuemart/themes/default/templates/order_emails/invoice_email.tpl.php

Brand new file basically a cloned and confirmation_email.tpl.php but it does the job nicely.  Simply copy this into the order_emails folder or if you would like to edit the layout, please go ahead.

What this achieves is as follows:-

Purchase order emails are still sent out when order pending.
When order status changes to Confirmed order status email is sent out and invoice generation is triggered and the invoice email is sent out.

I am sure with some more work, you could disable the order status and or purchase orders but for my purposes I wanted them to stay.


[attachment cleanup by admin]

MikeUK

Looks like you've been busy! :)

I presume the clone of ps_checkout is stripped down and put there to allow it to be called one further time after order status changes to confirmed (with the then unnecessary bits taken out)?

Nice solution.
Get answers faster:
    [li]
Search forum. You might find answer[/li]
[li]Use existing threads. Keep Q + A consolidated[/li]
[li]Troubleshooting? See http://forum.virtuemart.net/index.php?topic=60033.0[/li]
[li]For admin user manual - http://virtuemart.net/documentation/User_Manual/index.html[/li]
[li]For coding (developer manual) - http://virtuemart.net/documentation/Developer_Manual/index.html[/li][/list]

I can build your online shop, setup or customize Virtuemart or help your existing shop maximize its potential. Email / PM for info

Datatonic

I told you things had been hectic!

Nope it is pretty much as is, as I was time pressed and just wanted it working! 

I also wanted a solution that was a minimal hack of core files.  Would be great if someone trimmed it down though.

Datatonic

#####UPDATE#####

Due to sleepless nights and far too much coffee I've just noticed that I posted the wrong version on here.  The original zip had my version in it with a load of hacks.  This will break it for those without them.  So the new attachment has them without them and will work.  Really sorry!

###########

katiepants

Datatonic, you are a GENIUS! I love you!!!! This is EXACTLY the process I was looking for. Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you!!!!!!