Jump to content

Shop-For-Processwire: Send Confirmation Mail With Order Content


Pascal
 Share

Recommended Posts

Hi, I'm just developing a little webshop with ProcessWire. I am trying to get an confirmation mail sent to the customer when the order is completed. Is there any way to get the content of the order confirmation page directly into the email body? I already put this into the ShoppingCheckout module:

// Payment ok, order is done!
else {
$from = "From: <$order->email>\n";
$from .= "Reply-To: $order->email\n";
$from .= "Content-Type: text/html\n";
mail("pascal.tarris@gmail.com", __("Your Order with Reinkarnation"), $mailbody, $from);

Now can I somehow get all the markup from the confirmation page into $mailbody?

Thank you in advance,

Pascal

Link to comment
Share on other sites

You could alternatively set up a template file for this (just the file, not in the admin) and pass variables to it like this:

$t = new TemplateFile($config->paths->templates . "your-template.php");
$t->forename = "Bob";
$t->surname = "Bobness";
$mailbody = $t->render();

and that gives you a simple way to parse data from your page into a separate template file and send it via email. Essentially, $forename and $surname can then be used in that template file (or $this->forename and $this->surname if you're adding this code in a module and not in a template file).

In the dev branch there is also an email class called WireMail, so for the sake of completeness, if you wanted to use the dev branch you could do something like this:

$mail = wireMail();
$mail->to($customeremail)->from('sales@yoursote.com');
$mail->subject("Thank you for your order");
$t = new TemplateFile($config->paths->templates . "your-template.php");
$t->forename = "Bob";
$t->surname = "Bobness";
$mail->bodyHTML($t->render());
$mail->send();
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...