Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product option name as date


cableredi

Recommended Posts

I have a product option value as a date. I would like to only display those values > current date. I am having a hard time modifying the SQL to do this and would like some help. Any suggestions?

 

Ex: Product = ticket

Product Option = concert

Product Option Values = 10/05/2007, 12/15/2007, 03/10/2008, 05/15/2008

 

I would only like to display (as of 1/21/08) 03/10/2008 and 05/15/2008 in the drop down for the Ticket/Concert product attributes from the product info page

 

thanx in advance

Link to comment
Share on other sites

1. Backup!

2. Make sure you backed up!

3. The options are pulled in a query in product_info.php, leave the query alone, find the following right behind it:

 

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

 

4. You only want to add the query results to the array if products_options_id is not the one with the date, or if it is, only if the date is in the future.

5. Did you backup yet?

 

Hope this helps ...

Even at a Mensa convention someone is the dumbest person in the room.

Link to comment
Share on other sites

Thank you but can you you be a little more specific.

 

I am guessing I add an 'if' clause after the following code:

 

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] .

$currencies->display_price($products_options['options_values_price'],

tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

 

Now, how do I compare $products_options['products_options_values_name'] to date('m/d/Y')? - both in the same format

 

Thanx again

Link to comment
Share on other sites

Nope, you'd want to enclose that entire statement in an if-clause like

 

if ($products_options['products_options_values_id'] != '5') { // the id for the Date option

if (strtotime($products_options['products_options_values_name']) > strtotime(date("Y-m-d"))) {

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

} else {

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

 

Don't rely on this to work - should be close though - you'll probably have to play with the date format a bit ...

Even at a Mensa convention someone is the dumbest person in the room.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...