Jump to content
Sign in to follow this  
Taking the Lead

Trouble with installing "Happy Hour offer" contribution

Recommended Posts

Hi

I do not normally have too much difficulty with installing contributions but this one has got me beat. I have tried to install it twice now - both times I can see it in admin, I can adjust it so as to present an item for the "Happy hour" - but nothing happens in the shop. Tried altering time, date and position with no luck - Has anyone successfully installed it ?

 

Is there anyone who cares to to have a look at my installation to see whats amiss?

 

Thanks John

Share this post


Link to post
Share on other sites

John,

 

I am having the exact same problem. Happy Hour seems to work fine in the admin side, but nothing shows on the shop side. I too have installed it twice and changed settings with no avail. I even alter the database, which will cause an error, so I know that something is working, but nothing shows when everything is installed "correctly".

 

I was really excited by this contribution, it's exactly what my client wanted on their wite, it's just a shame that it's not currently working.

 

I'm getting ready to send the author of the contribution a message asking about this problem. When, or if, I hear anything, I'll follow it up here.

 

Melvins138

Share this post


Link to post
Share on other sites

I have it installed and working but I stumbled on the same problem as you guys. What did the trick is to change

in (catalog)/includes/boxes/happy_hours_special_basic.php the part of the query saying

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() > hhs.happy_hours_beginning_date and now() < hhs.happy_hours_end_date

to

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date)

Note that the query should read 'larger or equal' and 'smaller or equal' otherwise nothing will show.

 

Love this contribution but I wish the author had made a support thread for this.

Share this post


Link to post
Share on other sites

Wheeloftime,

 

Nice!!! That seemed to get it showing on the shop side by replacing line 20 with:

 

if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, hhs.specials_price_happy_hours, hhs.status_happy_hours, hhs.happy_hours_beginning_date, hhs.happy_hours_end_date, hhs.happy_hours_beginning_time, hhs.happy_hours_end_time, hhs.specials_date_added from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " hhs where p.products_status = '1' and p.products_id = hhs.products_id and pd.products_id = hhs.products_id and pd.language_id = '" . (int)$languages_id . "' and hhs.status_happy_hours = '1' and '" . $uhrzeit . "' BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() >= hhs.happy_hours_beginning_date and now() <= hhs.happy_hours_end_date order by hhs.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

 

Now there seems to be a problem with the shopping cart side, because it's not recognizing the price change. I'll have to see if there is a solution in shopping_cart.php.

 

Once again thanks,

Melvins138

Share this post


Link to post
Share on other sites
Wheeloftime,

 

Nice!!! That seemed to get it showing on the shop side by replacing line 20 with:

 

if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, hhs.specials_price_happy_hours, hhs.status_happy_hours, hhs.happy_hours_beginning_date, hhs.happy_hours_end_date, hhs.happy_hours_beginning_time, hhs.happy_hours_end_time, hhs.specials_date_added from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " hhs where p.products_status = '1' and p.products_id = hhs.products_id and pd.products_id = hhs.products_id and pd.language_id = '" . (int)$languages_id . "' and hhs.status_happy_hours = '1' and '" . $uhrzeit . "' BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() >= hhs.happy_hours_beginning_date and now() <= hhs.happy_hours_end_date order by hhs.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

 

Now there seems to be a problem with the shopping cart side, because it's not recognizing the price change. I'll have to see if there is a solution in shopping_cart.php.

 

Once again thanks,

Melvins138

 

Read the install.txt carefully as there is a couple of changes to be done within the classes/shopping_cart.php. I didn't have to do these changes as I had already done similar ones for another contribution which worked perfectly also for the happy hours contrib.

Share this post


Link to post
Share on other sites
Read the install.txt carefully as there is a couple of changes to be done within the classes/shopping_cart.php. I didn't have to do these changes as I had already done similar ones for another contribution which worked perfectly also for the happy hours contrib.

 

 

Could you point me in the right direction on what those changes are? I've re-read the install, and it is a little vague.

 

 

Melvins138

Share this post


Link to post
Share on other sites
Could you point me in the right direction on what those changes are? I've re-read the install, and it is a little vague.

Melvins138

 

There are 2 changes described for the classes/shopping_cart.php and both are for the part starting with

$specials_query =

When you search for that inside the shopping_cart.php you will find:

		  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

The idea is to comment this part out by putting /* and */ around it and add below

// Happy hours specials		  
	   	 if ($specials_price = tep_get_products_special_price($prid)) { 
				 $products_price = $specials_price;
			 }
// End Happy hours specials

So in the end you would have

/*
  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  }

*/

// Happy hours specials		  
   if ($specials_price = tep_get_products_special_price($prid)) { 
				 $products_price = $specials_price;
			 }
// End Happy hours specials

As said you will find the "$specials_query = " two times and for both occurences the changes are the same.

That should be it for the shopping cart to display the price correctly.

Share this post


Link to post
Share on other sites

Hi Wheels - thanks for that but unfortunately I seem to have messed it up somehow and I still can not get anything to show on the shop side - if I pm you with details can you scan an eye over it for me? John

Share this post


Link to post
Share on other sites

I'm having the same problem and have updated the 2 $specials_query blocks in classes/shopping_cart.php

 

- The happy hour box shows up with the special price.

- click on that to get to product page which shows original price

- click add to cart and it goes to cart but at the original price

 

 

This is a pretty heavily mod'd store but this contribution seems to be pretty straight forward.

The only thing I can think of which may be in conflict is the credit class /voucher contribution.

 

 

Anyone with advice/thoughts on this please tell :)

 

 

tia.


-caz

-----------

... trying to prove that I am a Believer :)

-----------

Share this post


Link to post
Share on other sites
I'm having the same problem and have updated the 2 $specials_query blocks in classes/shopping_cart.php

 

- The happy hour box shows up with the special price.

- click on that to get to product page which shows original price

- click add to cart and it goes to cart but at the original price

This is a pretty heavily mod'd store but this contribution seems to be pretty straight forward.

The only thing I can think of which may be in conflict is the credit class /voucher contribution.

Anyone with advice/thoughts on this please tell :)

tia.

 

I forgot to mention that you also need to alter the query within the function tep_get_products_special_price to

	$product_query2 = tep_db_query("select specials_price_happy_hours from " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " where products_id = '" . (int)$product_id . "' and status_happy_hours='1' and '" .$happy_time. "'
										 BETWEEN happy_hours_beginning_time and happy_hours_end_time and now() >= happy_hours_beginning_date and now() <= happy_hours_end_date");

 

It also needs the 'larger or equal' and 'smaller or equal' to function properly.

 

HTH

Share this post


Link to post
Share on other sites
I forgot to mention that you also need to alter the query within the function tep_get_products_special_price to

	$product_query2 = tep_db_query("select specials_price_happy_hours from " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " where products_id = '" . (int)$product_id . "' and status_happy_hours='1' and '" .$happy_time. "'
										 BETWEEN happy_hours_beginning_time and happy_hours_end_time and now() >= happy_hours_beginning_date and now() <= happy_hours_end_date");

 

It also needs the 'larger or equal' and 'smaller or equal' to function properly.

 

HTH

 

 

That did the trick!!!!! Thank you, Thank you.

 

I might take the notes from this thread and make an update to the contribution.

 

Melvins

Share this post


Link to post
Share on other sites
That did the trick!!!!! Thank you, Thank you.

 

I might take the notes from this thread and make an update to the contribution.

 

Melvins

 

Glad to hear you have it running !

You might take a look at some other change I did almost immediately within the admin/happy_hours_special.php as I got sick of filling in the date, month, year, hours, minutes, seconds for all those fields.

<tr>
<td> <b><?php echo HAPPY_HOURS_DISCOUNT; ?></b></td><td> </td>
</tr>
<tr>
		<td class="main" width="200"><?php echo TEXT_SPECIALS_BEGINNING_HAPPY_HOURS_DATE; ?> </td><td class="main" >
					<?php  echo
								tep_draw_input_field('happy_hours_day', (isset($sInfo->happy_hours_beginning_date) ? substr($sInfo->happy_hours_beginning_date, 8, 2) : date(d)), 'size="2" maxlength="2" class="cal-TextBox"') . 'Dag '.
								tep_draw_input_field('happy_hours_month', (isset($sInfo->happy_hours_beginning_date) ? substr($sInfo->happy_hours_beginning_date, 5, 2) : date(m)), 'size="2" maxlength="2" class="cal-TextBox"') . 'Maand '.
								tep_draw_input_field('happy_hours_year', (isset($sInfo->happy_hours_beginning_date) ? substr($sInfo->happy_hours_beginning_date, 0, 4) : date(Y)), 'size="4" maxlength="4" class="cal-TextBox"') . 'Jaar';
					?>
					</td>
					</tr>
					<tr>
								<td class="main" width="200"><?php echo TEXT_SPECIALS_END_HAPPY_HOURS_DATE; ?> </td><td class="main" >
					<?php echo
								tep_draw_input_field('happy_hours_end_day', (isset($sInfo->happy_hours_end_date) ? substr($sInfo->happy_hours_end_date, 8, 2) : date(d)), 'size="2" maxlength="2" class="cal-TextBox"') . 'Dag '.
								tep_draw_input_field('happy_hours_end_month', (isset($sInfo->happy_hours_end_date) ? substr($sInfo->happy_hours_end_date, 5, 2) : date(m)), 'size="2" maxlength="2" class="cal-TextBox"') . 'Maand '.
								tep_draw_input_field('happy_hours_end_year', (isset($sInfo->happy_hours_end_date) ? substr($sInfo->happy_hours_end_date, 0, 4) : date(Y)), 'size="4" maxlength="4" class="cal-TextBox"') . 'Jaar';
					?>
					</td>
					</tr>


<tr>
		<td class="main" ><?php echo TEXT_SPECIALS_BEGINNING_HAPPY_HOURS_TIME; ?> </td><td class="main" width="400">
					<?php echo
								tep_draw_input_field('happy_specials_hour', (isset($sInfo->happy_hours_beginning_time) ? substr($sInfo->happy_hours_beginning_time, 0, 2) : date(H)+1), 'size="2" maxlength="2" class="cal-TextBox"') . 'Uur '.
										  tep_draw_input_field('happy_hours_minutes', (isset($sInfo->happy_hours_beginning_time) ? substr($sInfo->happy_hours_beginning_time, 3, 2) : '00'), 'size="2" maxlength="2" class="cal-TextBox"'). 'Min '.
										  tep_draw_input_field('happy_hours_secondes', (isset($sInfo->happy_hours_beginning_time) ? substr($sInfo->happy_hours_beginning_time, 6, 2) : '00'), 'size="2" maxlength="2" class="cal-TextBox"'). 'Sec ';


					?>

					</td>
					</tr>
					<tr>
								<td class="main" width="200"><?php echo TEXT_SPECIALS_END_HAPPY_HOURS_TIME; ?> </td><td class="main" >
					<?php echo
								tep_draw_input_field('happy_hours_end_hour', (isset($sInfo->happy_hours_end_time) ? substr($sInfo->happy_hours_end_time, 0, 2) : date(H)+3), 'size="2" maxlength="2" class="cal-TextBox"') . 'Uur '.
										  tep_draw_input_field('happy_hours_end_minutes', (isset($sInfo->happy_hours_end_time) ? substr($sInfo->happy_hours_end_time, 3, 2) : '00'), 'size="2" maxlength="2" class="cal-TextBox"'). 'Min '.
										  tep_draw_input_field('happy_hours_end_secondes', (isset($sInfo->happy_hours_end_time) ? substr($sInfo->happy_hours_end_time, 6, 2) : '00'), 'size="2" maxlength="2" class="cal-TextBox"'). 'Sec ';
					?>
						</td>
					</tr>

What I changed is that I have the day, month, year filled in automatically with a default to today. The hours are filled with the actual hour plus 1 for start time and hours plus 3 for end time. That's just arbitrary but at least there is something useful already inside the fields and it's easier to change this way. Depending on your date settings you might have to switch day and month if your first field is handled as month instead of day. The textual display for day, month, year, hour, minutes and seconds is hardcoded in Dutch and would be better tied to a language define so they would be multilanguage.

Share this post


Link to post
Share on other sites

wheeloftime .. thanks !

the extra tweak to the function worked like a charm :)


-caz

-----------

... trying to prove that I am a Believer :)

-----------

Share this post


Link to post
Share on other sites

Hi. I have a quick question. Where do i enter this in at?

$product_query2 = tep_db_query("select specials_price_happy_hours from " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " where products_id = '" . (int)$product_id . "' and status_happy_hours='1' and '" .$happy_time. "'
BETWEEN happy_hours_beginning_time and happy_hours_end_time and now() >= happy_hours_beginning_date and now() <= happy_hours_end_date");

Thanks :)

Share this post


Link to post
Share on other sites
Hi. I have a quick question. Where do i enter this in at?

$product_query2 = tep_db_query("select specials_price_happy_hours from " . TABLE_HAPPY_HOURS_SPECIALS_BASIC . " where products_id = '" . (int)$product_id . "' and status_happy_hours='1' and '" .$happy_time. "'
BETWEEN happy_hours_beginning_time and happy_hours_end_time and now() >= happy_hours_beginning_date and now() <= happy_hours_end_date");

Thanks :)

 

This part from the function tep_get_products_special_price you will/should find in (catalog)/includes/functions/general.php. Look at the installation instructions from HHSP.

Share this post


Link to post
Share on other sites

hrm.. okie so i set it all up and i get this in my catalog now on the front page.

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') and (now() >= hhs.happy_hours_beginning_date) and (now() <= h

select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, hhs.specials_price_happy_hours, hhs.status_happy_hours, hhs.happy_hours_beginning_date, hhs.happy_hours_end_date, hhs.happy_hours_beginning_time, hhs.happy_hours_end_time, hhs.specials_date_added from products p, products_description pd, happy_hours_specials_basic hhs where p.products_status = '1' and p.products_id = hhs.products_id and pd.products_id = hhs.products_id and pd.language_id = '1' and hhs.status_happy_hours = '1' and '05:11:42' BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date) order by hhs.specials_date_added desc limit 10

 

any idears? :blush:

 

it only says that when i changed the code in the includes/boxes/happy_hours_specials_basic.php file from

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() > hhs.happy_hours_beginning_date and now() < hhs.happy_hours_end_date

 

to

 

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date)

Edited by voldtaengler

Share this post


Link to post
Share on other sites
hrm.. okie so i set it all up and i get this in my catalog now on the front page.

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') and (now() >= hhs.happy_hours_beginning_date) and (now() <= h

select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, hhs.specials_price_happy_hours, hhs.status_happy_hours, hhs.happy_hours_beginning_date, hhs.happy_hours_end_date, hhs.happy_hours_beginning_time, hhs.happy_hours_end_time, hhs.specials_date_added from products p, products_description pd, happy_hours_specials_basic hhs where p.products_status = '1' and p.products_id = hhs.products_id and pd.products_id = hhs.products_id and pd.language_id = '1' and hhs.status_happy_hours = '1' and '05:11:42' BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date) order by hhs.specials_date_added desc limit 10

 

any idears? :blush:

 

it only says that when i changed the code in the includes/boxes/happy_hours_specials_basic.php file from

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() > hhs.happy_hours_beginning_date and now() < hhs.happy_hours_end_date

 

to

 

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date)

 

Where did you read that ?

The problem will probably be those extra ( and ) you used. Just make it look like:

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() >= hhs.happy_hours_beginning_date and now() <= hhs.happy_hours_end_date

and it shoud be okay.

Share this post


Link to post
Share on other sites
Where did you read that ?

The problem will probably be those extra ( and ) you used. Just make it look like:

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time and now() >= hhs.happy_hours_beginning_date and now() <= hhs.happy_hours_end_date

and it shoud be okay.

You posted it :P I just copy pasted what you typed as the code to change :) I will give it a try now (the new code) Thanks a lot guys for helping me out :)

Share this post


Link to post
Share on other sites
You posted it :P I just copy pasted what you typed as the code to change :) I will give it a try now (the new code) Thanks a lot guys for helping me out :)

 

Ha ha, I did ?! :lol: I don't see where but anyhow, it might not be the problem on closer look.

Take a look also at the missing opening ( directly after BETWEEN

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time)

should be

BETWEEN (hhs.happy_hours_beginning_time and hhs.happy_hours_end_time)

Share this post


Link to post
Share on other sites

ooh.. i more question.. is this based in military time? or just the standard 12 hours regardless of AM or PM?

 

BETWEEN hhs.happy_hours_beginning_time and hhs.happy_hours_end_time) and (now() >= hhs.happy_hours_beginning_date) and (now() <= hhs.happy_hours_end_date)

Note that the query should read 'larger or equal' and 'smaller or equal' otherwise nothing will show.

 

Love this contribution but I wish the author had made a support thread for this.

 

Yep.. this is what you posted.. i saw the difference the second you pointed out the new code change :)

Share this post


Link to post
Share on other sites
ooh.. i more question.. is this based in military time? or just the standard 12 hours regardless of AM or PM?

Yep.. this is what you posted.. i saw the difference the second you pointed out the new code change :)

 

Does that mean you got rid of the error ?!

As for the time; I have no idea but if military=24 hours notation then it must be military as I use it like 09:00 and 19:00 for 9 AM and 7 PM.

Share this post


Link to post
Share on other sites
yep the error seems to have dissapearred after you gave me the new working code :lol:

Thanks a lot! :thumbsup:

 

Okiedokie :thumbsup:

Share this post


Link to post
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
Sign in to follow this  

×