Page 1 of 2
Putting the total in a custom .tpl
Posted: Tue Mar 08, 2016 1:51 am
by waynegrappler
Hi
Going round in circles on this one.
I'm making my own order confirmation email by editing the .tpl file it uses.
I'm trying to put a line in at line 50 that attempts to insert the total into the BACs details
Here's the bit before and after the line (the line with $totals in)
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
Please follow these instructions carefully<P ...>
Make your payment for £ <?php echo $totals['text']; ?> to the following bank account:<P ...>
Bank: TSB<BR ...>
It all appears in the email except the total. I just a pound sign - I'm working on the assumption that $totals is a variable. My knowledge of PHP is almost zero so It's vary likely I'm doing something really stupid.
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 4:05 am
by abxweb
Which file are you trying to change and please explain lil more what are you trying to achieve. I will write simple vqmod for you to achieve what u want.
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 8:07 pm
by waynegrappler
file is www/catalog/view/theme/default/template/mail/order.tpl
I want to place the total order cost that is displayed on the confirmation email as detailed
<td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;">
Please follow these instructions carefully<P ...>
Make your payment for £ORDER TOTAL HERE to the following bank account:<P ...>
Bank: TSB<BR ...>
Account Name: <BR ...>
Sort Code: <BR ...>
Account Number: <BR ...>
Payment Referance: <?php echo $order_id; ?><P ...>
Once you have made your payment reply to this email so that we can confirm your payment has been made, as soon as we confirm your payment your goods will be shipped
</td>
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 8:56 pm
by artcore
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 9:35 pm
by waynegrappler
Will this include the currency symbol? Can't test until later.
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 10:41 pm
by artcore
Code: Select all
$data['bank'] = nl2br(str_replace('{total}',$this->currency->format(max(0, $this->cart->getTotal())),$this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id'))));
It does and above is adjusted for OC2
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 10:59 pm
by ocart777
artcore wrote:Code: Select all
$data['bank'] = nl2br(str_replace('{total}',$this->currency->format(max(0, $this->cart->getTotal())),$this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id'))));
It does and above is adjusted for OC2
nice there

but..instead of
should be
for OC2.X
Re: Putting the total in a custom .tpl
Posted: Wed Mar 09, 2016 11:08 pm
by waynegrappler
Using OC 2.1.0.2 cant find this
In admin open up the bank transfer module and change your text to include the {total} at a strategic spot.
Something like:
Pay {total} immediately to:
Bankaccount number...
Thank you!
I dont want to display the total in the bank transfer window in open cart only in a second location in the confirmation email received by the customer
Does this make sense?
Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 12:28 am
by artcore
In the admin side change the banktransfer instructions description to include the {total} somewhere. It's in payments modules > bank transfer
@ocart777: thanks!

Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 2:03 am
by waynegrappler
Im trying to get the total from the confirmation email bottom right into the part indicated with the red arrow, see attachment
Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 2:16 am
by ocart777
waynegrappler wrote:Im trying to get the total from the confirmation email bottom right into the part indicated with the red arrow, see attachment
use the same method. search for
Code: Select all
$comment .= $this->config->get('bank_transfer_bank' . $this->config->get('config_language_id')) . "\n\n";
replace with
Code: Select all
$comment .= str_replace('{total}', $this->currency->format($this->cart->getTotal()), $this->config->get('bank_transfer_bank' . $this->config->get('config_language_id'))) . "\n\n";
Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 2:42 am
by waynegrappler
It still not working, is this the right file /www/catalog/controller/payment/bank_transfer.php
I dont understand how this will alter the order.tpl file to display the info im want
Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 3:01 am
by ocart777
waynegrappler wrote:It still not working, is this the right file /www/catalog/controller/payment/bank_transfer.php
I dont understand how this will alter the order.tpl file to display the info im want
all the edit was made only for "catalog/controller/payment/bank_transfer.php"
the mail was sent out because once payment confirm button clicked it will call the confirm function from this file then trigger the "addOrderHistory" function from "catalog/model/checkout/order.php" which will send the email using the order.tpl template(somebody please correct me if i am wrong)
Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 3:30 am
by artcore
Correct ocart777!
The text from the admin bank transfer module - the instructions for customers to pay - is sent upon confirming.
All my mod does is add the current total by replacing the place holder {total} which you have to add to the description, with the cart total.
/admin/index.php?route=payment/bank_transfer
add the {total} placeholder in the text.
/catalog/controller/payment/bank_transfer.php
Change $data['bank...etc with ocart777's modified version for oc2.
Rrefresh modification cache maybe and it should work.
I'll write an ocmod for this tomorrow

Re: Putting the total in a custom .tpl
Posted: Thu Mar 10, 2016 7:54 pm
by artcore
Here you go. Tested on 2.1.0.2
I'll add it to the market for free later on
Re: Putting the total in a custom .tpl
Posted: Fri Mar 11, 2016 4:40 pm
by waynegrappler
Thanks for that any chance you could tell me how to implement it
Re: Putting the total in a custom .tpl
Posted: Fri Mar 11, 2016 5:37 pm
by artcore
Sure.
Use the extension installer to upload the ocmod.xml and hit refresh 9n the modification page.
Done.
Re: Putting the total in a custom .tpl
Posted: Fri Mar 11, 2016 6:12 pm
by waynegrappler
Ok have installed the the file and added the place holder {total} to the bank transfer instruction but (see attached pic) i still have no total in the instruction line on the confirmation email
This is the actual email received by the customer
Re: Putting the total in a custom .tpl
Posted: Fri Mar 11, 2016 6:52 pm
by artcore
It will only be for new orders.
Tested and confirmed working on 2102
Re: Putting the total in a custom .tpl
Posted: Fri Mar 11, 2016 7:05 pm
by waynegrappler
In order to add the line to the email confirmation i addd "Payment Referance: <?php echo $order_id; ?><P ...>" to order.tpl to give the details in capture1.jpg attached and this works fine.
Now i want to copy the total order amount to the line indicated in capture.jpg
I have installed the extension and placed the {total} in the bank transfer instruction and it does show the total with open cart on my site but still does not display in the line i want it to on the confirmation email received by the customer
what am i doing wrong, the ID mod i made was so simple