Forums / Setting Up Categories, Products, Attributes / Setting a max number with a + for items with large stock

Setting a max number with a + for items with large stock

Started by einarso on 17 Jul 2013, 11:42 AM · Views: 920

Results 1 to 6 of 6
17 Jul 2013, 11:42 AM
#1
einarso avatar

einarso

New Zenner

Join Date:
Nov 2011
Posts:
45
Plugin Contributions:
0

Setting a max number with a + for items with large stock

I cant find a function that I believe must be included in ZC, or can be solved by doing something simple. In my ZC store I show the stock status on each and every product. We have ordered some products in large quantities, and we really dont want to show the whole stock. Many stores have the simple solution of having a "max" value on stock so instead of "* 105 units in stock", it says "20+ units in stock" (if the max limit is set to 20).

Can anyone point me in the right direction here?

17 Jul 2013, 11:49 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Setting a max number with a + for items with large stock

That's normally in a group of <li> tags in the tpl_product_info_display.php template.
If your PHP skills are up to the task, you can write your customization right there.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jul 2013, 7:47 AM
#3
einarso avatar

einarso

New Zenner

Join Date:
Nov 2011
Posts:
45
Plugin Contributions:
0

Re: Setting a max number with a + for items with large stock

Ok - thought maybe this was a setting in the admin system as this is quite common presentation of stock.

I know how to read and search php (I understand programming), but sadly I am not able to write php code. I guess this is the code that needs to be changed:

  <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>

Can anyone rewrite this code for me so that if products_quantity > 20, it shows "20+" instead of the actual number?

18 Jul 2013, 1:14 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,120
Plugin Contributions:
56

Re: Setting a max number with a + for items with large stock

Sure ...

<?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . (($products_quantity > 20) ? '20+' : $products_quantity) . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>
18 Jul 2013, 6:48 PM
#5
einarso avatar

einarso

New Zenner

Join Date:
Nov 2011
Posts:
45
Plugin Contributions:
0

Re: Setting a max number with a + for items with large stock

Thanks!!

18 Jul 2013, 10:42 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Setting a max number with a + for items with large stock

@lat9, thanks for posting the code. I was away from my development code when I posted earlier so I couldn't post any examples!

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.