Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Date available


stevennickelby

Recommended Posts

Hello there,

 

If I don't know the specific day of when a product is available,

 

is there a way to specify just a month of the year and still get it to display in product info,

 

for instance...

 

if product A is available sometime in September

 

can the date available have no day so it would just display september 2006,

 

instead of having to specify a day to make it work?

 

???????please help :(

Link to comment
Share on other sites

You'd need to change the database field type to varchar. Then you need to do whatever editing necessary to get product_info.php displaying like you wish it to.

 

Thanks for yur reply!,

 

Is changing the field to varchar absolutely neccessary?(i'm not sure how to do that)

 

I tried to write a script in "product_info" which was supposed to use a text from the language file if

the date available was "2010-00-00 00:00:00" but it never worked,

 

I'm a baby in php!, could you give me some more help?

 

heres the script i added...

 

<?php if ($product_info['products_date_available'] > date('Y-m-d H:i:s'))

echo sprintf(TEXT_DATE_AVAILABLE, tep_date_short($product_info['products_date_available'])); ?>

 

<?php

if ($product_info['products_date_available'] = ('2010-00-00 00:00:00'))

echo TEXT_TBA; ?>

 

the top one is already in product_info so i wrote the one (wrapped in bubble) underneith.

 

because it didn't work I did a search for products_date_available and found this in the last quarter of scripting (in product_info)....

}

 

if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {

 

so I added...

}

if ($product_info['products_date_available'] > ('2010-00-00 00:00:00')) {

 

and still it didn't work....i would just like to be able to display the year and month if I can- if I don't know the day,

and if it can't do that then just a description that can be used from the language file?

 

please help

Link to comment
Share on other sites

there are times I wish to display the exact day as well :)

 

 

for instance if the product is available 21st of september 2007

then it would display the full date,

 

but if the actual day was not known and it was just september 2007

then it would show just that.

 

I appreciate your help!

Link to comment
Share on other sites

Okay... so you want to make a date of '2006-06-00' mean:

 

June, 2006

 

and '2006-06-03' mean:

 

June 3rd, 2006 (or however you have it normally formatted in OSC)?

 

 

Yikes.

 

 

I guess the easiest is to check the day. If the day is 0, then you know you only want to display the month and year. If the day is not 0, display it as a standard date. I'd suggest adding another field to your select statement. Let MySQL handle it with it's date functions so you don't need to do string parsing in PHP. Something like:

 

(line 72 products_info.php)

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, IF( DAY( p.products_date_available ) = 0, DATE_FORMAT( p.products_date_available, '%M, %Y' ), DATE_FORMAT( p.products_date_available, '".DATE_FORMAT_LONG."' ) AS products_date_available_formatted, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

Then line 189:

 

	if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, $product_info['products_date_available_formatted']); ?></td>
  </tr>
<?php
} else {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, $product_info['products_date_available_formatted']); ?></td>
  </tr>
<?php
}
?>

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I tried the code but it came up with the error....

 

 

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 'AS products_date_available_formatted, p.manufacturers_id from pr

 

select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, IF( DAY( p.products_date_available ) = 0, DATE_FORMAT( p.products_date_available, '%M, %Y' ), DATE_FORMAT( p.products_date_available, '%A %d %B, %Y' ) AS products_date_available_formatted, p.manufacturers_id from products p, products_description pd where p.products_status = '1' and p.products_id = '272' and pd.products_id = p.products_id and pd.language_id = '1'

 

I'm not to sure what it could be?

 

 

I think it could be...if that's any help

IF( DAY( p.products_date_available ) = 0, DATE_FORMAT( p.products_date_available, '%M, %Y' ),

DATE_FORMAT( p.products_date_available, '".DATE_FORMAT_LONG."' )

AS products_date_available_formatted,

 

thanks again so far!

Link to comment
Share on other sites

Missing the closing parenthesis for the IF statement:

 

IF( DAY( p.products_date_available ) = 0, DATE_FORMAT( p.products_date_available, '%M, %Y' ),
DATE_FORMAT( p.products_date_available, '".DATE_FORMAT_LONG."' ) ) 
AS products_date_available_formatted,

 

So that whole line should be:

 

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, IF( DAY( p.products_date_available ) = 0, DATE_FORMAT( p.products_date_available, '%M, %Y' ), DATE_FORMAT( p.products_date_available, '".DATE_FORMAT_LONG."' ) ) AS products_date_available_formatted, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

The code runs, but it comes up with something strange.

 

theres no image or information and the price is $0.00

 

and it displays a line of text which says "This product was added to our catalog on ."

 

 

Probably because that query is returning no rows. Add

 

echo "select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'";

 

Right after that line and post the query that is displayed. Run it in phpMyAdmin and see what it returns.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...