Author Topic: How to override specific templates?  (Read 5228 times)

Offline Ollie

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +27/-1
    • View Profile
    • Assistech
How to override specific templates?
« on: August 25, 2016, 08:42:44 AM »
I want to override email template (`/template/mail/order_confirm.tpl`) via my extension, but AbanteCart doesn't allow to do that for some reason. Also I'd like to modify products list, before sending email, but I don't see any `Init` or `Update` hooks inside the Order Model which performs sending (`admin/model/sale/order.php`), so I can't do that. The only `hk_confirm`
hook is called before products list generation, so it doesn't help.
Assistive technologies for people with special needs:
https://assistech.com/store/

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: How to override specific templates?
« Reply #1 on: August 25, 2016, 09:10:31 AM »
I wonder why it is not allowed. You should be able to include this and it will automatically replace it.
Double check that you have it in correct directory and included file path in main.php of extension.
Extension should be enabled
“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline Oleksandr

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
Re: How to override specific templates?
« Reply #2 on: August 25, 2016, 10:56:57 AM »
I wonder why it is not allowed. You should be able to include this and it will automatically replace it.

Email template is called using template->fetch method:
github.com/abantecart/abantecart-src/tree/master/public_html/storefront/model/checkout/order.php#L563

And it seems like this method doesn't look into extensions folder:
github.com/abantecart/abantecart-src/tree/master/public_html/core/lib/template.php#L28-L57

Am I wrong?
« Last Edit: August 25, 2016, 01:30:15 PM by Oleksandr »

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: How to override specific templates?
« Reply #3 on: August 26, 2016, 07:24:21 AM »
Now I get it. You are right. I was thinking of regular templates.

Currently, you can override it only with new template or replace this file in default template.

Code: [Select]
if (file_exists(DIR_TEMPLATE . $this->config->get('config_storefront_template') . '/template/' . $filename)){
$filename = $this->config->get('config_storefront_template') . '/template/' . $filename;
} else{
$filename = 'default/template/' . $filename;
}
“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline Oleksandr

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
Re: How to override specific templates?
« Reply #4 on: August 26, 2016, 07:39:35 AM »
Now I get it. You are right. I was thinking of regular templates.

Currently, you can override it only with new template or replace this file in default template.
Thank you.
So, there is no way to do that via extension?
1. I can't force Order model to use some other template, correct?
2. Replacing original template is not extension way.

Confirm, please.

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: How to override specific templates?
« Reply #5 on: September 09, 2016, 09:04:56 PM »
Unfortunately, you are correct. You can not replace this with an extension approach.

We will try to put an extension override in here for 1.2.9 or 1.3

Let's keep this post open and we will come back once we will have a code change here.
“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline Ollie

  • Sr. Member
  • ****
  • Posts: 253
  • Karma: +27/-1
    • View Profile
    • Assistech
Re: How to override specific templates?
« Reply #6 on: September 10, 2016, 01:29:58 PM »
We will try to put an extension override in here for 1.2.9 or 1.3
Let's keep this post open and we will come back once we will have a code change here.

Thank you. It would be great if you could include it in 1.2.9.
Assistive technologies for people with special needs:
https://assistech.com/store/

 

Powered by SMFPacks Social Login Mod