Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Show attribute stock levels on product page?

Show attribute stock levels on product page?

Views: 1,471

Results 1 to 14 of 14
11 Dec 2012, 6:55 PM
#1
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Show attribute stock levels on product page?

Is is possible to show stock levels of attributes on the product page to prevent customers from trying to order more products than actually exist? We have a 1.3.9h installation.

Thanks,

John

11 Dec 2012, 7:10 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Show attribute stock levels on product page?

Search the Plugins area for Stock By Attributes

11 Dec 2012, 7:17 PM
#3
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

We have that installed -- but it only shows stock levels in the admin side, not on the product page. Unless there's something I'm missing.

11 Dec 2012, 10:38 PM
#5
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

Ah, that looks like it might do it. I'll check tomorrow. Thanks!

13 Dec 2012, 4:59 PM
#6
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

Well, close, but no cigar, as my 2nd grade teacher used to say. (I have no idea why she said that).

It looks like the code should add a stock amount to the attribute, but it doesn't. Looking at the code with my very amateurish eye, I see it appears to address several different attribute styles, but not the dropdown menu (which my attribute uses). Might that be part of the problem?

John

13 Dec 2012, 5:24 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show attribute stock levels on product page?

Make a temporary attribute of another kind to see if it works for that on your site. If so, then you know the dropdown situation is what needs addressing.

13 Dec 2012, 7:33 PM
#8
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

With a different style of attribute it works... sort of.

I created a checkbox style attribute and added it to a product. When I display that product, I see my checkbox option followed by the number of pieces I have in inventory.

However, the modification breaks the attribute.php page by repeating the attribute numerous times down the page. You can see what I mean below:

http://quinceandco.com/backup/index.php?main_page=product_info&cPath=1&products_id=1

So, this modification would be great if:

  1. It worked with dropdown menus;
  2. It doesn't break the attribute function
13 Dec 2012, 8:32 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show attribute stock levels on product page?

If there is really a bug in the mod, you should report it in the mod's support thread. Otherwise, asking for help there is likely to be more productive than here. You might find out why the mod doesn't handle dropdowns, too, and maybe even get someone to improve it.

13 Dec 2012, 8:39 PM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show attribute stock levels on product page?

Okay, I see that the quantity display is not a formal mod, but a suggestion in a closed thread. So you first need to examine whether you followed the directions correctly, and whether the base file code is the same in your version of Zen Cart, if you are on v1.5.x.

13 Dec 2012, 8:46 PM
#11
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

I've double-checked, and as far as I can tell, I did follow the directions correctly. And I have checked the modifications on a clean (previously unmodified) version of the attributes.php file from 1.3.9h (which I think this modification is for).

So I guess I'd like to plead my case to the larger community, but I'm not sure about how/where to do it, since, as you noted, this thread is closed. I'd welcome any suggestions.

John

13 Dec 2012, 8:52 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Show attribute stock levels on product page?

Attributes.php changed for v1.5.x, but if you are really using v1.3.9h as the title says, that should be the right thing to do. Can you find the original thread that one refers to, to see what context or other info there might be?

16 Dec 2012, 9:45 AM
#14
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: Show attribute stock levels on product page?

thinking back i might have had problems with the link i sent you if an attribute didnt have any stock,

i actially use gjh42 stock icon module slightly altered for my attributes as i like that style

http://www.onyourbike.co.uk/index.php?main_page=product_info&cPath=1_413&products_id=1235

you could use the same idea to return the stock qty instead my version of sba is not the std so hopefully this might work for you

create a file called attribute_qty_functions.php

<?php
function attribute_qty_function($product_id,$attributes) {
  global $db;
  $get_sba_stock = $db->Execute('select quantity from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id = "' . $product_id . '" and stock_attributes = "' . $attributes . '"');
  //return $get_sba_stock->fields['quantity'];
  $attribute_qty = $get_sba_stock->fields['quantity'];
  if ($attribute_qty == '') {
  return '';
  } else {
  return ' [ Qty ' . $attribute_qty . ' ]';
}
}
//EOF

upload to includes/funtions/extrafunctions/

then in your includes/modules/attributes.php

in around line 104 in my version you should see something like

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

change this to

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

and directly before this add

$attribute_qty = attribute_qty_function($products_options->fields['products_id'],$products_options->fields['products_attributes_id']);

this should cover the drop downs

and look like this with stock

http://catchagrip.co.uk/index.php?main_page=product_info&cPath=1_478&products_id=1069

and without

http://catchagrip.co.uk/index.php?main_page=product_info&cPath=1_478&products_id=1068

then for radio buttons

at approx line 184

change

$products_options_details = $products_options->fields['products_options_values_name'];

to

$products_options_details = $products_options->fields['products_options_values_name'] . attribute_qty_function($products_options->fields['products_id'],$products_options->fields['products_attributes_id']);

and this will hopefully get you this

http://catchagrip.co.uk/index.php?main_page=product_info&cPath=1_413&products_id=1235

hopefully the professionals on here might let you know if this would cause any issues but this is similar to what i use and it seems fine, as i say i use the stock icons in my radio ones but if you download gjh42 stock icon module you will see how that works, not sure if the icons would work in dropdowns

hope this may be of help and backup

bn