Hello,
I would like to enable a extension by code using a condition to make it.
For example, I would like to enable a extension every wednesday. From this link(http://forum.opencart.com/viewtopic.php?t=64752), I saw I can use the function Date, but I don't know how to enable the extension by code. Even in the database I don't know where this status is stored.
I appreciate any help
Best not to do it that way. Instead leave the extension installed and enabled at all times
What type of extension is it?
If payment, you can do this
1. EDIT: catalog/model/payment/xxx.php
2. FIND:
3. BEFORE, ADD:
if it is an order total
1. EDIT: catalog/model/total/xxx.php
2. FIND:
3. AFTER, ADD:
if it is a shipping extension
1. EDIT: catalog/model/shipping/xxx.php
2. FIND:
3. AFTER, ADD:
What type of extension is it?
If payment, you can do this
1. EDIT: catalog/model/payment/xxx.php
2. FIND:
Code: Select all
if ($status) {
Code: Select all
if (date('l') != 'Wednesday') { return false; }
if it is an order total
1. EDIT: catalog/model/total/xxx.php
2. FIND:
Code: Select all
public function getTotal(&$total_data, &$total, &$taxes) {
Code: Select all
if (date('l') != 'Wednesday') { return false; }
if it is a shipping extension
1. EDIT: catalog/model/shipping/xxx.php
2. FIND:
Code: Select all
function getQuote($address) {
Code: Select all
if (date('l') != 'Wednesday') { return false; }
Hello Qphoria,
Thank you for answer.
In this case I would like to enable a banner. I could do like the link I referenced, but it should have a position in the middle of others modules.
Before asking here, I had it done by editing /catolog/controller/commom/content_top.php
After this:
I added this code ( the banner_id of my banner is 13) :
But I was looking for a better and more generic way. And I prefer changing in the DB because the status would be consistent with the admin panel too. But it seems not easy to do.
So, using your help, I edited the file catalog/controller/module/banner.php
after this code:
I added ( the banner_id of my banner is 13):
and this is working. 
Anyways, I think Opencart could have a better documentation...or it has and I don't know where check this.
Once again, thanks for your time and help.
Thank you for answer.
In this case I would like to enable a banner. I could do like the link I referenced, but it should have a position in the middle of others modules.
Before asking here, I had it done by editing /catolog/controller/commom/content_top.php
After this:
Code: Select all
if ($modules) {
foreach ($modules as $module) {
Code: Select all
if(date('D') == 'Wed'){
if (isset($module['banner_id']) && $module['banner_id'] == 13) $module['status'] = 1;
}
So, using your help, I edited the file catalog/controller/module/banner.php
after this code:
Code: Select all
foreach ($results as $result) {
Code: Select all
if ((date('l') != 'Wednesday') && ($result['banner_id'] == 13)){
unset($result);
break;
}

Anyways, I think Opencart could have a better documentation...or it has and I don't know where check this.
Once again, thanks for your time and help.
Who is online
Users browsing this forum: Baidu [Spider] and 35 guests