Hello everyone, someone could help me to integrate this little php script in opencart 3.032
<? Php
date_default_timezone_set ( 'Europe / Paris');
$ hour = date ("H");
$ day = date ("D");
if (($ time> 07 AND $ time <12) OR ($ time> 16 AND $ time <18) AND ($ day <> "Sat" OR $ day <> "Sun")):?>
<b> <font color = "green"> We are currently open. </ font> </ b>
<? php else:?>
<font color = "red"> <b> We are currently closed. </ b> </ font>
<? php endif; ?>
Thank you
I would like to put it at the top of each category
<? Php
date_default_timezone_set ( 'Europe / Paris');
$ hour = date ("H");
$ day = date ("D");
if (($ time> 07 AND $ time <12) OR ($ time> 16 AND $ time <18) AND ($ day <> "Sat" OR $ day <> "Sun")):?>
<b> <font color = "green"> We are currently open. </ font> </ b>
<? php else:?>
<font color = "red"> <b> We are currently closed. </ b> </ font>
<? php endif; ?>
Thank you
I would like to put it at the top of each category
Simply assign a variable inside the controller (like $data['my_variable']) and handover it to the template.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Bad, better to hire some professional, see forum for such in the signature.
What?
php?
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Incomplete code posted. The $time variable is not defined in your instructions in order to use it in your IF statement.carrousel wrote: ↑Thu Jul 04, 2019 2:38 amHello everyone, someone could help me to integrate this little php script in opencart 3.032
<? Php
date_default_timezone_set ( 'Europe / Paris');
$ hour = date ("H");
$ day = date ("D");
if (($ time> 07 AND $ time <12) OR ($ time> 16 AND $ time <18) AND ($ day <> "Sat" OR $ day <> "Sun")):?>
<b> <font color = "green"> We are currently open. </ font> </ b>
<? php else:?>
<font color = "red"> <b> We are currently closed. </ b> </ font>
<? php endif; ?>
Thank you
I would like to put it at the top of each category
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Some code for you to play with:
Or install attachment and Refresh modifications.
Code: Select all
<modification>
<name>PprMkr - Opened or Closed</name>
<code>PprMkr_Opened_Closed</code>
<version><![CDATA[3.0.3.2]]></version>
<author>Roelie @ PprMkr</author>
<email>opencart@pprmkr.nl</email>
<file path="catalog/controller/product/category.php">
<operation>
<search><![CDATA[$data['products'] = array();]]></search>
<add position="before"><![CDATA[
// Set table
// weekday nr => times
$our_opening_times_table = array(
'0' => [],
'1' => ['7:00' => '12:00','16:00' => '18:00'],
'2' => ['7:00' => '12:00','16:00' => '18:00'],
'3' => ['7:00' => '12:00','16:00' => '18:00'],
'4' => ['9:00' => '12:00','16:00' => '18:00'],
'5' => ['7:00' => '12:00','16:00' => '18:00'],
'6' => []
);
date_default_timezone_set('Europe/Paris');
$weekday = date('l'); // Sunday - Saturday
$weekday_nr = date('w'); // 0 - 6
$store_opened = false;
$times_today = '';
// get weekday from table and loop trough times
foreach ($our_opening_times_table[$weekday_nr] as $start_time => $end_time) {
$times_today .= ' ' . $start_time . ' - ' . $end_time;
if (strtotime($start_time) < strtotime(date("H:i")) && strtotime(date("H:i")) < strtotime($end_time)) {
$store_opened = true;
}
}
$data['store_opened_closed'] = 'This ' . $weekday . ', ' . date("H:i") . ', our store is currently <b>';
if ($store_opened) {
$data['store_opened_closed'] .= '<span style="color:green;">open</span>';
} else {
$data['store_opened_closed'] .= '<span style="color:red;">closed</span>';
}
$data['store_opened_closed'] .= '</b>. Times today :' . $times_today;
]]></add>
</operation>
</file>
<file path="catalog/view/theme/default/template/product/category.twig">
<operation>
<search><![CDATA[{{ content_top }}]]></search>
<add position="before"><![CDATA[
<h3>{{ store_opened_closed }}</h3>
]]></add>
</operation>
</file>
</modification>
Who is online
Users browsing this forum: No registered users and 226 guests