Jump to content

How to read Opening hours data from Shop tabs


bonbontamura

Recommended Posts

Hallo,

maybe anyone can help me, or we can work together if someone is interested.

the target is:
I want to show the opening hours in stores.php page OUTSIDE the map. Of course I can type it manually in my stores.tpl but it would be hard for my employee if she has to edit it :). so the page stores.php should read the opening hours from the database.

What I did now (See pictures):
1. fill in the opening hours in shops tab
2. edit my stores.tpl file and insert this line somewhere:

{$store.hours|escape:'htmlall':'UTF-8'}



The output wasn't as I expected. It showed the hours but it didn't serialized the days (see pictures)

What did I do wrong? can someone help me please?

thanks in advanced!

47413_kpn7iFmqd6GmON6rjpxk_t

47412_MDvOeOQMt06ZtINN8NCM_t

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...

FIND

 

foreach ($stores AS &$store)
	    $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');

 

//foreach ($stores AS &$store)
	    //$store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');

		$days[1] = 'Monday';
		$days[2] = 'Tuesday';
		$days[3] = 'Wednesday';
		$days[4] = 'Thursday';
		$days[5] = 'Friday';
		$days[6] = 'Saturday';
		$days[7] = 'Sunday';

		foreach ($stores as &$store)
		{
			$store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');

			$days_datas = array();

			$other = '';
			if (!empty($store['hours']))
			{
				$hours = unserialize($store['hours']);

				for ($i = 1; $i < 8; $i++)
				{
					$hours_datas = array();
					$hours_datas['day'] = $days[$i];
					$hours_datas['hours'] = $hours[(int)($i) - 1];
					$days_datas[] = $hours_datas;
				}
				$store['days_datas'] = $days_datas;
			}
		}

 

PLACE IN FOREACH IN TEMPLATE STORES.TPL

		<p><strong>{l s='Hours:'}</strong></p>
		<ul class="hours">{foreach from=$store.days_datas item=one_day}
			<li><span>{l s=$one_day.day}</span>{$one_day.hours}</li>
		{/foreach}</ul>

Edited by Pit Group Intech B.V. (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...