Jump to content
Sign in to follow this  
Snowman

[Contribution]Product Availability Options v1.0

Recommended Posts

OK, ignore that :)

 

I'm now getting an empty dropdown tho.

 

jon

hmmm

 

One day i will get everythign right first time. :blink:

 

I'll have another look thru to make sure i havent still missed soemthing

Share this post


Link to post
Share on other sites

Erm... sorry.

Where did shipping eta come from? I thought this was product availability? :blink:

If I put product_availability instead of shippingeta.. things start working.

jon


:: Web Jetty

:: ...bringing art to the digital world

:: http://webjetty.co.uk/

Share this post


Link to post
Share on other sites

DOH :rolleyes:

 

how obvious was that...

 

in mine its called shippingeta as i use it for a different purpose.

 

Ok so it should be

 

 
        <tr>
          <td class="main"><?php echo TEXT_PRODUCTS_PRODUCTS_AVAILABILITY; ?></td>
          <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('products_availability_id', $products_availability_array, $pInfo->products_availability_id); ?></td>
        </tr>

Edited by Snowman

Share this post


Link to post
Share on other sites

Also figured out on the product info page, you need to swap.

$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, 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 . "'");

for

 

$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, p.manufacturers_id, p.products_availability_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 . "'");

 

 

Does that sound right?

jon

Edited by jadjei

:: Web Jetty

:: ...bringing art to the digital world

:: http://webjetty.co.uk/

Share this post


Link to post
Share on other sites

i give up...

 

i just cant win...how did i miss that???

 

yes product_info.php does need to be changed to

 

  } else {
   $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, p.manufacturers_id,  p.shippingeta_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 . "'");
   $product_info = tep_db_fetch_array($product_info_query);

Share this post


Link to post
Share on other sites

ok if that all works now let me know and i'll recontribute it again

 

i will wait this time for those of you trying to get it tot work to say its all good b4 i repost it

Share this post


Link to post
Share on other sites

well done guys - it works great!

 

thanks to steve and jon for your help

 

regards

 

mark


Regards

 

Mark A Reynolds

Share this post


Link to post
Share on other sites

I think it's all working now apart from the bizarre text insertion problem on the Localization -> Product availability page. I too get the text deleted apart from the 2nd character on the first insert.

 

jon


:: Web Jetty

:: ...bringing art to the digital world

:: http://webjetty.co.uk/

Share this post


Link to post
Share on other sites

Thanks for a great contribution Steve.

I've been hoping someone would write something like this for a while. :)

 

I think it's probably good enough to post again.

 

jon


:: Web Jetty

:: ...bringing art to the digital world

:: http://webjetty.co.uk/

Share this post


Link to post
Share on other sites

This contribution works with multi language websites?

 

INSERT INTO `products_availability` VALUES (1, 1, 'Usually ships in 24 hours', now(), NULL);

INSERT INTO `products_availability` VALUES (4, 1, 'Usually ships in 1-2 business days', now(), NULL);

INSERT INTO `products_availability` VALUES (5, 1, 'Usually ships in 2-7 business days', now(), NULL);

INSERT INTO `products_availability` VALUES (6, 1, 'Usually ships in 1 to 2 weeks', now(), NULL);

INSERT INTO `products_availability` VALUES (7, 1, 'Usually ships in 2 to 3 weeks', now(), NULL);

INSERT INTO `products_availability` VALUES (8, 1, '<i>Limited Availability.</i> Call for Details.', now(), NULL);

INSERT INTO `products_availability` VALUES (9, 1, 'This item is not stocked. Call for Availability.', now(), NULL);

INSERT INTO `products_availability` VALUES (10, 1, 'This item has been discontinued.', now(), NULL);

INSERT INTO `products_availability` VALUES (11, 1, '<font color="#FF0000">This item is currently <b>SOLD OUT</b></foNT>', now(), NULL);

INSERT INTO `products_availability` VALUES (12, 1, '<b>Not yet released</b>', now(), NULL);

INSERT INTO `products_availability` VALUES (13, 1, 'Available for immediate download', now(), NULL);

 

This SQL its only in english, how to add other languages?

 

 

Best Regards.

Share this post


Link to post
Share on other sites

Andre

 

If you have multiple languages activated in your admin you "should" be able to add other languages. try and edit the one of the options and in theory it should show the differnt language flags, just like the rest of oscommerce does.

 

Dont quote me as i didnt test it in another language.

 

If it doesnt work, let me know and i'll have a dig around tommorrow on it..

Share this post


Link to post
Share on other sites

can you not just translate the values in the sql?? so that it shows up in the language of your choice and in the product_info.php as well??

 

Probably a stupid question by me

 

mark


Regards

 

Mark A Reynolds

Share this post


Link to post
Share on other sites

Just checked....it does allow you to add other languages and seems to be workign fine :)

 

finally i think ive got somethign doen right today :)

Share this post


Link to post
Share on other sites

Ok, I will test.

 

My website have 3 different languages now, and before install mods I want allways to know if the mod its compatible with multi language.

 

Thanks Steve.

 

 

Best Regards, Andre.

Share this post


Link to post
Share on other sites

problem: product_info.php will not show the availability

 

          <td class="main" align="right" valign="top"><?php echo TEXT_AVAILABILITY; ?> <?php echo ($products_availability_name . '+' . $product_info['products_availability_id'] . '+' . $products_availability_info['products_availability_name']); ?></td>

 

the products_availability_id will show, so that it will look like:

Availability +9+

 

I try to read by:

$products_availability = $product_info['products_availability_id'];

 

    $products_availability_info_query = tep_db_query("select e.products_availability_name from " . TABLE_PRODUCTS_AVAILABILITY . " e where e.products_availability_id = '" . (int)$products_availability . "' and e.languages_id = '" . (int)$languages_id . "'");

 

    $products_availability_info = tep_db_fetch_array($products_availability_info_query);

    $products_availability_name = $products_availability_info['products_availability_name'];

 

why is it not working????????

Share this post


Link to post
Share on other sites

For anybody (including myself!) who experienced the following little bug, please find a fix below:

 

I think it's all working now apart from the bizarre text insertion problem on the Localization -> Product availability page. I too get the text deleted apart from the 2nd character on the first insert.

 

jon

 

In admin/products_availability.php:

 

Replace (about line 29)

 

        $sql_data_array = array('products_availability_name' => tep_db_prepare_input($products_availability_array[$language_id]),
       'products_availability_id' => $products_availability_id,
                               'languages_id' => $language_id);

       if ($action == 'insert') {
         $insert_sql_data = array('date_added' => 'now()');

         $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

         tep_db_perform(TABLE_PRODUCTS_AVAILABILITY, $sql_data_array);
         $products_availability_id = tep_db_insert_id();
       } elseif ($action == 'save') {
         $update_sql_data = array('last_modified' => 'now()');

 

with

 

          $sql_data_array = array('languages_id' => $language_id);

       if ($action == 'insert') {
         $insert_sql_data = array('products_availability_name' => tep_db_prepare_input($HTTP_POST_VARS['products_availability_name']),
                                  'date_added' => 'now()');

         $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

         tep_db_perform(TABLE_PRODUCTS_AVAILABILITY, $sql_data_array);
         $products_availability_id = tep_db_insert_id();
       } elseif ($action == 'save') {
         $update_sql_data = array('products_availability_name' => tep_db_prepare_input($products_availability_array[$language_id]),
                                  'last_modified' => 'now()');

 

Not sure why this fix is necessary (for some), but it works for me!

 

Cheers, Rob

Share this post


Link to post
Share on other sites
? ? ? ? ?  <td class="main" align="right" valign="top"><?php echo TEXT_AVAILABILITY; ?> <?php echo ($products_availability_name . '+' . $product_info['products_availability_id'] . '+' . $products_availability_info['products_availability_name']); ?></td>

i dont know where that has come from...

 

It should be:

 

          <tr>
           <td class="main" align="right" valign="top"></td>
           <td class="main" align="right" valign="top"><b><?php echo TEXT_AVAILABILITY; ?></b>: <?php echo $products_availability_name; ?></td>
         </tr>

Share this post


Link to post
Share on other sites

Well I finally got this contrib working. took about 2 hours. Part of that is because I have a very custom store. I initially had problems with the pulldown box in the admin console when you add or edit a product but saw the update posted today.

 

From what I can tell, there seems to be missing a small piece of code in the /catalog/product_info.php file. I had to add the p.products_availability_id field to the $product_info_query statement. Not sure if this applies to others but looking at the code it almost seems necessarry. might be specific to my version though....

 

all in all its a great contrib.

 

Thanks to the author!

 

B)

Share this post


Link to post
Share on other sites
all in all its a great contrib.

 

Thanks to the author!

 

I agree - well done steve this is as great feature!

 

Mark


Regards

 

Mark A Reynolds

Share this post


Link to post
Share on other sites

this command is not the problem:

<td class="main" align="right" valign="top"><b><?php echo TEXT_AVAILABILITY; ?></b>: <?php echo $products_availability_name; ?></td>

 

even there is a small mistake in the command:

shouldn't it be   instead of   ?!?

 

my problem is that obviously $products_availability_name is EMPTY

 

and I don't understand how this can be.

 

at first products_availability_id was empty, too - because it was never read.

this mistake is reported above.

 

the change you see was done by me to proof the content of the variable,

to try to show where the problem is and where not.

 

i try to read $products_availabilty_name by:

$products_availability = $product_info['products_availability_id'];

 

    $products_availability_info_query = tep_db_query("select e.products_availability_name from " . TABLE_PRODUCTS_AVAILABILITY . " e where e.products_availability_id = '" . (int)$products_availability . "' and e.languages_id = '" . (int)$languages_id . "'");

 

    $products_availability_info = tep_db_fetch_array($products_availability_info_query);

    $products_availability_name = $products_availability_info['products_availability_name'];

which should be exactly the lines from the instruction...

 

can anybody explain???

Share this post


Link to post
Share on other sites

Double check with this code

 

In catalog/products_info.php

 

find the the following code:

 

 

<?php
 } else {
   $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, p.manufacturers_id " . 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 . "'");
   $product_info = tep_db_fetch_array($product_info_query);

 

and change to

 

<?php
 } else {
   $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, p.manufacturers_id,  p.products_availability_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 . "'");
   $product_info = tep_db_fetch_array($product_info_query);

 

 

then find the following code:

 

if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
   } else {
     $products_name = $product_info['products_name'];
   }

 

 

and add this immediately after it:

 

$products_availability = $product_info['products_availability_id'];

   $products_availability_info_query = tep_db_query("select e.products_availability_name from " . TABLE_PRODUCTS_AVAILABILITY . " e where e.products_availability_id = '" . (int)$products_availability . "' and e.languages_id = '" . (int)$languages_id . "'");

   $products_availability_info = tep_db_fetch_array($products_availability_info_query);
   $products_availability_name = $products_availability_info['products_availability_name'];

 

 

then find the the following code:

 

<tr>
           <td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
           <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
         </tr>

 

 

and add this immediately after it:

 

<?php
 if (tep_not_null($products_availability_info['products_availability_name'])) {
?>
         <tr>
           <td class="main" align="right" valign="top"></td>
           <td class="main" align="right" valign="top"><b><?php echo TEXT_AVAILABILITY; ?></b>: <?php echo $products_availability_name; ?></td>
         </tr>

Edited by Snowman

Share this post


Link to post
Share on other sites

oh and thro in the closing after that last bit

 

<?php
}
?>

Edited by Snowman

Share this post


Link to post
Share on other sites

if found the error now!

but i cannot correct it easily.

 

the problem was/is:

the contrib is in english.

we use english and german.

the file products_availability was just filled with the delivered english sql,

so of course no german-availability can show/can be read if it is not in the database... :-(

 

i tried to add the german info, but....

 

can it be that all you people run your shop in english only?

 

seems to me there is 'error in logic' in the construction of the file products_availability

  PRIMARY KEY  (`products_availability_id`),

 

how should i add the german info?

 

i cannot just change:

INSERT INTO `products_availability` VALUES (1, 1, 'Usually ships in 24 hours', now(), NULL);

INSERT INTO `products_availability` VALUES (4, 1, 'Usually ships in 1-2 business days', now(), NULL);

 

to:

INSERT INTO `products_availability` VALUES (1, 2, 'innerhalb von 24 Stunden', now(), NULL);

INSERT INTO `products_availability` VALUES (4, 2, 'innerhalb von 1-2 Arbeitstagen', now(), NULL);

 

because the key (1, 4, ...) is already existing...

 

i guess the key should either be an automatically increasing number,

or should consist of a combination of key+languages_id

 

what solution do you propose?

 

Thanks for your efforts!

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  

×