Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution]Product Availability Options v1.0


Snowman

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

Link to comment
Share on other sites

  • Replies 76
  • Created
  • Last Reply

Top Posters In This Topic

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
Link to comment
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/

Link to comment
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);

Link to comment
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.

Link to comment
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..

Link to comment
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????????

Link to comment
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

Link to comment
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>

Link to comment
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)

Link to comment
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???

Link to comment
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
Link to comment
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!

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...