AffordableDomainsCanada Posted January 5, 2017 Share Posted January 5, 2017 I need to make a hook so when a new order is placed, and the payment method 'PayPal' is selected, email template (Insert number here) is automatically sent, and if payment method 'Credit Card' is selected, email template (Insert number here) is automatically sent. I am trying to combat fraud, and want all new orders and the clients to sign an agreement and payment release form and up to now I have been manually reviewing orders, and with the influx in recent orders, automation would be nice. any help ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 5, 2017 Share Posted January 5, 2017 do you need a hook for this? couldn't you just use the one template for both, and use some Smarty code to determine the payment method and then output the appropriate text ? 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 5, 2017 Author Share Posted January 5, 2017 I need it to be 2 template options. I dont want the paypal form being emailed out to my credit card customers, and vice versa. If using some smarty code is easier I can make it work that way! 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 6, 2017 Author Share Posted January 6, 2017 I have created a new email template to include both payment methods and instructions on how to submit the documents. I just need to know how I can make the template be sent out after a order is placed when the invoice is being created. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 6, 2017 Share Posted January 6, 2017 I have created a new email template to include both payment methods and instructions on how to submit the documents. I just need to know how I can make the template be sent out after a order is placed when the invoice is being created. oh I assumed you were going to be editing one of the existing email templates that are automatically sent (Order Confirmation, Invoice or optionally a Product Welcome). of the three, i'd have been more tempted to add this text to an existing invoice email template - for two reasons... 1. in the invoice templates, you'd automatically have access to the {$invoice_payment_method} Smarty variable - and that would give you a value to base a simple {if} statement on to determine the appropriate text to add... a similar variable exists in the Product Welcome templates too. {if $invoice_payment_method eq "Paypal"}some text{else}some other text{/if} 2. by default, WHMCS uses two different email templates for invoice creation - one for Credit Cards and one for other payment gateways - so you should automatically have a built-in method of differentiating your credit card and paypal customers. http://docs.whmcs.com/Payment_Gateways The type of payment gateway selected influences which invoice notification email template it sent; Third Party Gateways will send the "Invoice Created" email template, whilst Merchant and Tokanisation Gateways will send the "Credit Card Invoice Created" email template. This allows you to customise the payment instructions to clients for the different payment processes. optionally, I suppose if your release form is a PDF document, you could also attach the appropriate version to the specific invoice email template. 1 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 7, 2017 Author Share Posted January 7, 2017 (edited) Will this work ? {if $invoice_payment_method eq "PayPal"} PayPal Info Here {elseif $invoice_payment_method eq "Stripe"} Credit Card Info Here {elseif $invoice_payment_method eq "Offline Credit Card"} Offline Credit Card Process Here {elseif $invoice_payment_method eq "Mail In Payment"} e-Transfer Process Here {else} Main Order Confirmation Here {/if} Edited January 7, 2017 by AffordableDomainsCanada 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 7, 2017 Share Posted January 7, 2017 Will this work ? it should now that you've changed the code to use elseif - but create a test account within your WHMCS, make a dummy order or invoice, change the payment method in the admin area, send the email again and ensure the text is showing correctly for each. 1 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 7, 2017 Author Share Posted January 7, 2017 is there anyway I can get the payment gateway to display in the email template ? is there any smarty tags for that ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 7, 2017 Share Posted January 7, 2017 is there anyway I can get the payment gateway to display in the email template ? is there any smarty tags for that ? yes, you just add {$invoice_payment_method} to your template. 1 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 7, 2017 Author Share Posted January 7, 2017 Somethings not right, only the {else} Main Order Confirmation Here {/if} is being sent in the order email 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 7, 2017 Author Share Posted January 7, 2017 {$invoice_payment_method} doesnt appear to be working either 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 7, 2017 Author Share Posted January 7, 2017 I think i got it working, it was the email template I was using. 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted January 8, 2017 Author Share Posted January 8, 2017 Okay I think I got it working how it should be but then I got thinking, this is going to send everytime the gateway is triggered. is there a way to make it so its displayed ONLY for new orders ? for existing clients when the invoice created template is sent, the paragraph in the {else} will be displayed .. hope that makes sense 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 8, 2017 Share Posted January 8, 2017 I think i got it working, it was the email template I was using. it sounded like you were still trying to do it in the order confirmation email, and not the invoice templates... with WHMCS, always remember that the general emails don't necessarily have access to invoice variables... and the invoice templates don't have full access to the order details. Okay I think I got it working how it should be but then I got thinking, this is going to send everytime the gateway is triggered. is there a way to make it so its displayed ONLY for new orders ? for existing clients when the invoice created template is sent, the paragraph in the {else} will be displayed .. hope that makes sense it makes sense... but the simplest test for new orders is whether an orderID exists... if so, it's an order; if not, it's a renewal invoice - there are potential exceptions to that rule, but in general it's true... but the invoice email templates don't have access to the order number, so that's irrelevant... unless you wrote a hook to give it that info, but we're on the road of trying to avoid hooks with this. about the only practical way I can think to do this, using existing invoice email template variables, would be to test if the invoice and signup dates are the same - if so, they're a new customer and it's their 1st invoice*; if they don't match, then it's a new order at a later date, or a renewal, from an existing client. {if $invoice_date_created == $client_signup_date} {if $invoice_payment_method eq "PayPal"} PayPal Info Here {elseif $invoice_payment_method eq "Stripe"} Credit Card Info Here {elseif $invoice_payment_method eq "Offline Credit Card"} Offline Credit Card Process Here {elseif $invoice_payment_method eq "Mail In Payment"} e-Transfer Process Here {/if} {else} Main Order Confirmation Here {/if} note - i've moved your else out of the first {if} block into the second. * I can only see two potential flaws with this - one is reasonably possible, the other is extraordinarily unlikely. 1. if the new customer made multiple orders (generating multiple invoices) on their signup date, then they would all show the additional information... it's possible that a customer could do this, but I wouldn't have thought it likely... and i'm not talking about ordering multiple items in one go, but them making one order, then another, then another on that same first day etc... 2. if the order. from a new customer, was made at 23:59:59 and for some reason, e.g. server load, the signup/invoices dates were different - but I would have thought that would be freakishly unlikely to occur. other that that, it should work. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.