Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product of the Week


Recommended Posts

Hey there,

 

I've been working on modifying Featured Products 1.5.4 so that the user can specify a single product to be featured in the Index page, as a Product of the Week sort of thing.

 

I've managed to edit the sql query in the featured prods module to query for the index column, which i've added to the featured table in my db.

I've also added another set of status buttons in featured.php so that it's possible to toggle which one is the POW from the featured products page in admin.

 

However, i'm having some problems getting the sql query to edit the db correct.

 

Basically, all i've done is coppied the status change stuff, and changed the relavent fields and links...

 

The DB query

    function tep_set_featured_index($featured_id, $index) {
   if ($index == '1') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '1', expires_date = NULL, date_status_change = NULL, where featured_id = '" . $featured_id . "'");
   } elseif ($index == '0') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '0', date_status_change = now() where featured_id = '" . $featured_id . "'");
   } else {
     return -1;
   }
 }

 

The setindex case

	case 'setindex':
     tep_set_featured_index($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']);
     tep_redirect(tep_href_link(FILENAME_FEATURED, '', 'NONSSL'));
     break;

 

The Index buttons

<?php
     if ($featured['index'] == '1') {
       echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . tep_href_link(FILENAME_FEATURED, 'action=setindex&flag=0&id=' . $featured['featured_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
     } else {
       echo '<a href="' . tep_href_link(FILENAME_FEATURED, 'action=setindex&flag=1&id=' . $featured['featured_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
     }
?>

featured_pow.jpg

 

If i click on either the green of the red buttons to toggle the POW, it gives me a 1064 mysql error with my code - however i cant see where it is, as the code is identical to the status update query, apart from changin a different field.

 

Any ideas on what might be causing this?

 

Cheers

Fatmcgav

Link to comment
Share on other sites

Hey there,

 

I've been working on modifying Featured Products 1.5.4 so that the user can specify a single product to be featured in the Index page, as a Product of the Week sort of thing.

 

I've managed to edit the sql query in the featured prods module to query for the index column, which i've added to the featured table in my db.

I've also added another set of status buttons in featured.php so that it's possible to toggle which one is the POW from the featured products page in admin.

 

However, i'm having some problems getting the sql query to edit the db correct.

 

Basically, all i've done is coppied the status change stuff, and changed the relavent fields and links...

 

The DB query

    function tep_set_featured_index($featured_id, $index) {
   if ($index == '1') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '1', expires_date = NULL, date_status_change = NULL, where featured_id = '" . $featured_id . "'");
   } elseif ($index == '0') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '0', date_status_change = now() where featured_id = '" . $featured_id . "'");
   } else {
     return -1;
   }
 }

 

The setindex case

	case 'setindex':
     tep_set_featured_index($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']);
     tep_redirect(tep_href_link(FILENAME_FEATURED, '', 'NONSSL'));
     break;

 

The Index buttons

<?php
     if ($featured['index'] == '1') {
       echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . tep_href_link(FILENAME_FEATURED, 'action=setindex&flag=0&id=' . $featured['featured_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
     } else {
       echo '<a href="' . tep_href_link(FILENAME_FEATURED, 'action=setindex&flag=1&id=' . $featured['featured_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
     }
?>

featured_pow.jpg

 

If i click on either the green of the red buttons to toggle the POW, it gives me a 1064 mysql error with my code - however i cant see where it is, as the code is identical to the status update query, apart from changin a different field.

 

Any ideas on what might be causing this?

 

Cheers

Fatmcgav

 

Anybody????

 

Cheers

Fatmcgav

Link to comment
Share on other sites

K, i'm getting this SQL error now if i try to disable a product:

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 'index = '0', date_status_change = now() where featured_id = '1'

 

update featured set index = '0', date_status_change = now() where featured_id = '1'

 

And This one if i try to enable a product:

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 'index = '1', expires_date = NULL, date_status_change = NULL, wh

 

update featured set index = '1', expires_date = NULL, date_status_change = NULL, where featured_id = '3'

 

The corresponding section in featured.php is:

    function tep_set_featured_index($featured_id, $index) {
   if ($index == '1') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '1', expires_date = NULL, date_status_change = NULL, where featured_id = '" . $featured_id . "'");
   } elseif ($index == '0') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '0', date_status_change = now() where featured_id = '" . $featured_id . "'");
   } else {
     return -1;
   }
 }

 

Any ideas ppl?

 

Cheers

Fatmcgav

Link to comment
Share on other sites

  • 3 weeks later...
K, i'm getting this SQL error now if i try to disable a product:

And This one if i try to enable a product:

The corresponding section in featured.php is:

    function tep_set_featured_index($featured_id, $index) {
   if ($index == '1') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '1', expires_date = NULL, date_status_change = NULL, where featured_id = '" . $featured_id . "'");
   } elseif ($index == '0') {
     return tep_db_query("update " . TABLE_FEATURED . " set index = '0', date_status_change = now() where featured_id = '" . $featured_id . "'");
   } else {
     return -1;
   }
 }

 

Any ideas ppl?

 

Cheers

Fatmcgav

Somebody out there must know how to fix this problem, PLEASE.

I'm completely at a wits end with this one.

 

Somebody, PLEASE...

Link to comment
Share on other sites

  • 1 year later...

Y not use star product instead? Just change the title so instead of saying Star Product its says This Weeks Star Product?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...