Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Availability


surfalot

Recommended Posts

Hi all, I have this installed on my test site, and it is working on the catalog side of things.

 

If anyone wants to see this contrib in action: http://www.gofuntoys.com/svns/test-shop/pr...ane-desk-2.html

 

I wanted to post some code from my admin/categories.php file. I am not completely sure if this fix will work well in osC 2.2, but I was having issues where my admin screen was out of whack.

 

availability_pic.png

 

The code for this section on my site is:

<tr>
		<td class="maincol"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
		<td class="maincol"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>
		<tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
		<?php
// BOF: Availability
		   $availability_query = tep_db_query("select * from availability where language_id = '" . $languages_id . "'");
		   $availability_array = array();
		   while ($availability_tmp = tep_db_fetch_array($availability_query)) {
			 $availability_array[] = array( 'id' => $availability_tmp['availability_id'], 'text' => $availability_tmp['availability_name']);
		   }?>
		   <td class="main"><?php echo TEXT_AVAIL1;?></td>
		   <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('availability_id_in_stock', $availability_array, (!empty($pInfo->availability_id_in_stock)?$pInfo->availability_id_in_stock:1)); ?></td>  
		   </tr>
		   <tr>
		   <td class="main"><?php echo TEXT_AVAIL2;?></td>
		   <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('availability_id_out_of_stock', $availability_array, (!empty($pInfo->availability_id_out_of_stock)?$pInfo->availability_id_out_of_stock:2)) . ' <a href="' . tep_href_link(FILENAME_AVAILABILITY_OPTIONS) . '">'.TEXT_MANAGE_AVAIL_OPTIONS.'</a>'; ?></td>
// EOF: Availability
		 </td>
	  </tr>

 

I added the TEXT_AVAIL defines to my product_info.php english file. Not sure if this is useful to anyone since I have not tried this on my osC 2 test site, just my ecjc site which is a modified osC 2.2 RC1 for Joomla.

 

Also to the original author, thanks for writing this bit of code. Do you think it would be hard to add images instead of text? I think I might try to go that route with this in the next few weeks. Also, I needed to install the sql manually, will I miss anything by not running the installer? Everything seems fine so I am sure it is, but I just wanted to touch base on it.

Link to comment
Share on other sites

  • Replies 127
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...
  • 1 month later...

Hi, great contribution......Thanks!

 

Would it be possible to show the product when it is marked out of stock by the admin and have the add to cart button grayed out and the availabillity option to say out of stock.

 

As it is, if I mark the item out of stock, it shows product not found on the catalog side.

 

Thank you.

DawnMarieGifts

Link to comment
Share on other sites

  • 4 weeks later...

I have a problem that was mentioned several times, but I still haven't found a fix for it.

The contribution works great in English:

 

English:

Availability: 1 in-stock

 

But in both German and French I only see this:

Availability:

 

No quantities appear.

 

Any ideas please?

K

 

 

works fine for me. have you inserted the other languages in the admin? show me a screen-shot of your Availability admin screen with all your languages added and a link to a misfunctioning product.
Link to comment
Share on other sites

  • 3 weeks later...

i am using 2.2 rc1.. if i have two options ,, like

 

%s in stock ..---- set to id 1

available for back order ...set to id 2

 

Now if i have a product with 10 items .. all i get is available for back order..Even though on the admin side i set it to use %s in stock for items in stock.

 

if 1 remove available for back order then it does use the first id.. ..Cant seem to figure out whats wrong with it,,

 

 

Kind regards

 

nafri

Link to comment
Share on other sites

  • 2 weeks later...

I'm having the same issue as the poster above me. I have this contrib installed and working nicely in my current store which is using the osCommerce version just prior to RC1. I'm redoing my store and I'm using RC2. That is the only difference besides a few less contributions in the new store. I have been over the install directions several times and everything seems in order.

 

On the product info page it displays the out of stock message no matter what. I'm no coder, but I'm guessing maybe something having to do with the later version of osC is messing things up.

 

Anyone have any suggestions?

Currently running 76 contibutions.

Link to comment
Share on other sites

  • 1 month later...
I want to add the availability to shopping_cart.php Is there any way to do this? The image is hard coded and not a working item. I need to do this so if someone uses the "Buy Now" button, they will see the availability before finding out later that it is not in-stock.

in catalog/shopping_cart.php find:

	  $products_name .= '	</td>' .
					 '  </tr>' .
					 '</table>';

Just before it add:

	// BOF: Availability: Added: , availability_id_in_stock, availability_id_out_of_stock
 $avail_product_info_query = tep_db_query("select availability_id_in_stock, availability_id_out_of_stock, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products[$i]['id'] . "'");
 $avail_product_info = tep_db_fetch_array($avail_product_info_query);

 $availability_query = tep_db_query("select * from ".TABLE_AVAILABILITY." where language_id = " . $languages_id . " order by availability_id");
 $availability_array = array();
 while ($availability_tmp = tep_db_fetch_array($availability_query)) {
   $availability_array[$availability_tmp['availability_id']] = $availability_tmp['availability_name'];
 }
 $prod_quantity = tep_get_products_stock($products_id);
 if ($prod_quantity < 1) {
   $products_name .= "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$avail_product_info['availability_id_out_of_stock']],$avail_product_info['products_quantity'])."</p>";
 } else {
   $products_name .= "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$avail_product_info['availability_id_in_stock']],$avail_product_info['products_quantity'])."</p>";
 }
 // EOF: Availability

 

in catalog/includes/languages/english/shopping_cart.php add:

// BOF: Availability
define('TABLE_HEADING_AVAILABILITY', 'Availability:');
// EOF: Availability

before the closing ?> php tag.

 

that will put it under the text. If you want it under the image you need to squeeze it in to this area as another row of this table, good luck!

	  $products_name .= '	</td>' .
					 '  </tr>' .
					 '</table>';

Edited by surfalot
Link to comment
Share on other sites

you missed an entry in the includes/database_tables.php file.

 

I'm getting the same error. It worked fine until I added the above code (putting the availability in the shopping cart). I'd love to get this section to work!

Thanks,

Karim

Link to comment
Share on other sites

you missed an entry in the includes/database_tables.php file.

add to includes/database_tables.php

 

// BOF: Availability
 define('TABLE_AVAILABILITY', 'availability');
// EOF: Availability

Link to comment
Share on other sites

  • 2 months later...

:angry:Hi Everyone... this contrib. is killing me!!!!

 

I successfully installed it on my store on a localhost (for testing) -- It works PERFECTLY..

 

I then went live with everything (and checked everything 10x over - its exactly as on my local host) but for all stock levels it keeps giving me the 'OUT OF STOCK' message even when a product has 25pcs in stock.. It is working on the localhost, but not when I go live..

 

I checked the product_info page.. I cant see anything wrong..

 

Every product displays as out of stock..

 

And this is a great contrib.. I DONT KNOW WHAT TO DO PLEASE HELP!!!!!!!!!! ANYONE????

Link to comment
Share on other sites

:angry:Hi Everyone... this contrib. is killing me!!!!

 

I successfully installed it on my store on a localhost (for testing) -- It works PERFECTLY..

 

I then went live with everything (and checked everything 10x over - its exactly as on my local host) but for all stock levels it keeps giving me the 'OUT OF STOCK' message even when a product has 25pcs in stock.. It is working on the localhost, but not when I go live..

 

I checked the product_info page.. I cant see anything wrong..

 

Every product displays as out of stock..

 

And this is a great contrib.. I DONT KNOW WHAT TO DO PLEASE HELP!!!!!!!!!! ANYONE????

osCommerce version?

PHP version?

MySQL version?

any additional contributions that may conflict with?

(for localhost and the production environments)

Link to comment
Share on other sites

osCommerce version?

PHP version?

MySQL version?

any additional contributions that may conflict with?

(for localhost and the production environments)

 

 

Hi Todd, thanks for the reply.. I got it sorted already.. I changed that line of code to a STOCK_CHECK etc. It works!!! Great contrib!!

Link to comment
Share on other sites

Hi Todd, thanks for the reply.. I got it sorted already.. I changed that line of code to a STOCK_CHECK etc. It works!!! Great contrib!!

 

so... was it a problem with the contribution or your implementation?

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hi all,

 

The contribution stopped working for me when I disabled REGISTER_GLOBALS in PHP. But here's the fix:

 

Find:

$prod_quantity = tep_get_products_stock($products_id);

 

Replace by:

$prod_quantity = tep_get_products_stock($product_info[products_id]);

 

It seems that $products_id was comming from somewhere else, but without register_globals it's an unkown variable, so changing for $product_info[products_id] does the trick.

 

Hope it helps...

Edited by pedro.antunes
Link to comment
Share on other sites

  • 2 weeks later...
Hi all,

 

The contribution stopped working for me when I disabled REGISTER_GLOBALS in PHP. But here's the fix:

 

Find:

$prod_quantity = tep_get_products_stock($products_id);

 

Replace by:

$prod_quantity = tep_get_products_stock($product_info[products_id]);

 

It seems that $products_id was comming from somewhere else, but without register_globals it's an unkown variable, so changing for $product_info[products_id] does the trick.

 

Hope it helps...

thanks for that. Turns out this is a problem on both product_info.php and shopping_cart.php. Don't know what I was thinking there. v1.0.1 has been uploaded with the correct changes.

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

 

Thanks the great contribution, but I experienced an error code as below:

 

1146 - Table 'xxxxx.availability' doesn't exist

select count(*) as total from availability

 

And I have already checked the entry as Todd Holforty mentioned in includes/database_tables.php and the admin/availability_configurer.php didn't worked when I clicked Run Configuration Utility button.

 

Could someone support the MySQL code to allow me to built "TABLE avavailability" and "Column availability_id_in_stock、availability_id_out_of_stock in Table products" manually?

 

Thanks in advance :)

Link to comment
Share on other sites

did you get an error with the configurer?

 

CREATE TABLE availability (
availability_id int(11) NOT NULL default '1',
language_id int(11) NOT NULL default '1',
availability_name varchar(84) NOT NULL default '',
PRIMARY KEY  (availability_id,language_id)
);

INSERT INTO `availability` VALUES (1, 1, '%s in stock.');
INSERT INTO `availability` VALUES (2, 1, 'Temporarily out of stock.');
INSERT INTO `availability` VALUES (3, 1, 'In stock, usually ships within 1 to 3 days.');
INSERT INTO `availability` VALUES (4, 1, 'In stock, usually ships within 4 to 7 days.');
INSERT INTO `availability` VALUES (5, 1, 'Temporarily out of stock, restocking is expected shortly.');
INSERT INTO `availability` VALUES (6, 1, 'Special order, arrival dates may vary.');
INSERT INTO `availability` VALUES (7, 1, 'Made to order.');
INSERT INTO `availability` VALUES (8, 1, 'Made to order, usually ships within 3 to 7 days.');
INSERT INTO `availability` VALUES (9, 1, 'Made to order, usually ships within 7 to 14 days.');

ALTER TABLE products ADD availability_id_in_stock int(11) default '1' AFTER products_quantity;
ALTER TABLE products ADD availability_id_out_of_stock int(11) default '2' AFTER availability_id_in_stock;

Link to comment
Share on other sites

Thanks for the quick reply :P

 

When I clicked the "Run Configuration Utility" button and then the admin panel just showing the initial "Login" page. I guess the contribution "Admin Login" is not compatible with "Availability". Anyway it seemed working well after I added the codes to my database.

 

regards,

Link to comment
Share on other sites

Dear Todd Holforty,

 

Sorry for bothering you again. Referring to your source code stated below, would you please help me to modify the code only for the line marked in red to the status " if purchasing quantity > in stock quantity". I have tried all my best but failed. Appreciate your help and hope it would also benefit to others who have same need.

 

if ($avail_product_info['products_quantity'] < 1) {

$products_name .= "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$avail_product_info['availability_id_out_of_stock']],$avail_product_info['products_quantity'])."</p>";

} else {

$products_name .= "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$avail_product_info['availability_id_in_stock']],$avail_product_info['products_quantity'])."</p>";

}

Link to comment
Share on other sites

Hello,

I've installed the contrib, which is great, I've been waiting for it for some time.

Everything went well, the catalog/product_info.php works but in the admin side I have some problems.

Here are the images:

 

This is the admin/availability_options.php

 

options.jpg

 

This is what I get when I click the Edit button:

 

edit.jpg

 

The same I get when I click the Insert new options button

 

This is the configuration page, just in case...

 

configuration.jpg

 

From what I've read in this thread it's a language problem but I have no idea where to start. I use romanian language.

 

Thank you in advance

Best regards

Link to comment
Share on other sites

Hello,

I've installed the contrib, which is great, I've been waiting for it for some time.

Everything went well, the catalog/product_info.php works but in the admin side I have some problems.

 

That's interesting. Try this:

open the file /admin/availability_options.php, find the line:

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

replace with:

if ( (sizeof($heading) > 0) && (sizeof($contents) > 0) ) {

let me know if that fixes the "insert new option".

 

the included content is setup for english.

 

Run this in your host supplied database management tool (phpMyAdmin for most) to clear the English content:

 

TRUNCATE  TABLE  `availability`

 

Then, replace the number "1" in the second field for each line that follows, with the numeric value for your language and run the SQL in your database management tool to insert the content for your language. You can translate the language before or after inserting it in the database.

 

INSERT INTO `availability` VALUES (1, 1, '%s in stock.');
INSERT INTO `availability` VALUES (2, 1, 'Temporarily out of stock.');
INSERT INTO `availability` VALUES (3, 1, 'In stock, usually ships within 1 to 3 days.');
INSERT INTO `availability` VALUES (4, 1, 'In stock, usually ships within 4 to 7 days.');
INSERT INTO `availability` VALUES (5, 1, 'Temporarily out of stock, restocking is expected shortly.');
INSERT INTO `availability` VALUES (6, 1, 'Special order, arrival dates may vary.');
INSERT INTO `availability` VALUES (7, 1, 'Made to order.');
INSERT INTO `availability` VALUES (8, 1, 'Made to order, usually ships within 3 to 7 days.');
INSERT INTO `availability` VALUES (9, 1, 'Made to order, usually ships within 7 to 14 days.');

 

so if your language code is 4, then it will look like this:

 

INSERT INTO `availability` VALUES (1, 4, '%s in stock.');
INSERT INTO `availability` VALUES (2, 4, 'Temporarily out of stock.');
INSERT INTO `availability` VALUES (3, 4, 'In stock, usually ships within 1 to 3 days.');
INSERT INTO `availability` VALUES (4, 4, 'In stock, usually ships within 4 to 7 days.');
INSERT INTO `availability` VALUES (5, 4, 'Temporarily out of stock, restocking is expected shortly.');
INSERT INTO `availability` VALUES (6, 4, 'Special order, arrival dates may vary.');
INSERT INTO `availability` VALUES (7, 4, 'Made to order.');
INSERT INTO `availability` VALUES (8, 4, 'Made to order, usually ships within 3 to 7 days.');
INSERT INTO `availability` VALUES (9, 4, 'Made to order, usually ships within 7 to 14 days.');

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