jhebert
Total Posts: 8
Joined: 2008-03-01
Is there a way to show customers an items qty in stock on either the product page or the product list page?
Jason
webdevology.com
Posted: March 3 2008
| top
Moshe
Total Posts: 1770
Joined: 2007-08-07
Los Angeles
try this:
<? = Mage :: getModel ( 'cataloginventory/stock_item' )-> loadByProduct ( $_product )-> getQty () ?>
Signature
- I would love to change the world, but they won’t give me the source code -
Posted: March 3 2008
| top
| # 1
jhebert
Total Posts: 8
Joined: 2008-03-01
Moshe, you are the man…
Thanks a ton.
Jason
webdevology.com
Posted: March 3 2008
| top
| # 2
chiaraweb
Total Posts: 721
Joined: 2008-03-21
Aviano ~ Italy
Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…
Thanks
Signature
Believe Yourself
My Magento Shop http://www.ecobaby.it
Posted: March 24 2008
| top
| # 3
gabrielk
Total Posts: 83
Joined: 2007-11-30
chiaraweb - 23 March 2008 11:26 PM
Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…
Thanks
./app/design/frontend/default/default/template/catalog/product/view.phtml
or
./app/design/frontend/default/default/template/catalog/product/view/*.phtml
Posted: March 25 2008
| top
| # 4
sherrie
Total Posts: 1652
Joined: 2007-12-14
Illinois, USA
Is there a way to display this for the configured options?
For example once someone decides they want it in Navy, size Small it would display how many Small Navy shirts were available.
You can see where I integrated the quantity into the availability here:
http://store.sherrierohde.com/index.php/guard-pullover-nylon-jacket.html
But it’s just tracking from the main configurable product rather than the simple product being “selected.”
It’s really really slow, I know, it’s on DreamHost temporarily.
Signature
UX Manager, Sweet Tooth
Creativity is falling in love with the world. – Dewitt Jones
I’m a very random person, catch me if you can: http://www.twitter.com/sherrierohde
Posted: April 11 2008
| top
| # 5
chiaraweb
Total Posts: 721
Joined: 2008-03-21
Aviano ~ Italy
gabrielk - 24 March 2008 05:49 PM
chiaraweb - 23 March 2008 11:26 PM
Hy
I’m searching to display the same thing… but I don’t understand what file to edit to put this code…
Thanks
./app/design/frontend/default/default/template/catalog/product/view.phtml
or
./app/design/frontend/default/default/template/catalog/product/view/*.phtml
Thank You
The mod works but I don’t know why I have quantity 5 in inventory but store front shows 5.000
http://98.130.130.250/public/shop/index.php/catalog/category/view/mode/grid/id/4/
Is there some code that I can add or anything I can mod to change 5.000 in 5 ?
Thanks a lot
Signature
Believe Yourself
My Magento Shop http://www.ecobaby.it
Posted: April 21 2008
| top
| # 6
preinheimer
Total Posts: 1
Joined: 2008-02-26
You can cast the value to an integer: <?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
You could look at round for rounding the values to a given precision http://docs.php.net/round
Posted: April 26 2008
| top
| # 7
chiaraweb
Total Posts: 721
Joined: 2008-03-21
Aviano ~ Italy
preinheimer - 26 April 2008 03:58 PM
You can cast the value to an integer: <?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?>
You could look at round for rounding the values to a given precision http://docs.php.net/round
Thank You
I resolved changing the attribute of the cell in database from decimals to integer, but I imagine that your way it is better
Signature
Believe Yourself
My Magento Shop http://www.ecobaby.it
Posted: April 27 2008
| top
| # 8
Thejosh13
Total Posts: 252
Joined: 2008-06-23
Is there a way to show the QTY select option as a drop down menu with default set to 1?
Posted: September 19 2008
| top
| # 9
craichead
Total Posts: 28
Joined: 2008-08-28
Greeley, CO
I would like to display the stock of each item listed on a grouped product page ( grouped.phtml ) . How would you do this? Thanks.
Edit: Figured it out:
<?php if( $_product -> isSaleable ()): ?> <? = (int) Mage :: getModel ( 'cataloginventory/stock_item' )-> loadByProduct ( $_item )-> getQty () ?> <?php else: ?><?php echo $this -> __ ( 'Out of Stock' ) ?><?php endif; ?>
Posted: November 11 2008
| top
| # 11
LarMan128
Total Posts: 14
Joined: 2008-09-14
sherrie - 11 April 2008 12:30 PM
Is there a way to display this for the configured options?
For example once someone decides they want it in Navy, size Small it would display how many Small Navy shirts were available.
You can see where I integrated the quantity into the availability here:
http://store.sherrierohde.com/index.php/guard-pullover-nylon-jacket.html
But it’s just tracking from the main configurable product rather than the simple product being “selected.”
It’s really really slow, I know, it’s on DreamHost temporarily.
does anyone know how to do this? i have this working on simple products by using the code posted above but the configurable products it shows the configurable products quantity. when the options are selected i need it to show how many of that product are in stock so it needs to get the quantity from the associated simple product.
Signature
Consumers Castle
Knives | Lighters | Flashlights | Outdoor & Camping Gear | Public Safety Gear | Tools
Posted: December 24 2008
| top
| # 12
SCY
Total Posts: 47
Joined: 2008-12-02
Thanks to the great posts and this is a more specific way of how to set it up quickly:
Simple product:
Open app\design\frontend\default\[your_theme]\template\catalog\product\view\type\simple.phtml
Find
< p class= "availability" > <?php echo $this -> __ ( 'Quantity in stock:' ) ?> </ p >
Change into
< p class= "availability" > <?php echo $this -> __ ( 'Quantity in stock:' ) ?><? =(int) Mage :: getModel ( 'cataloginventory/stock_item' )-> loadByProduct ( $_product )-> getQty () ?> </ p >
Save and done!
Grouped produt:
Open app\design\frontend\default\[your_theme]\template\catalog\product\view\type\grouped.phtml
Find
< td class= "a-center" > <?php if ( $_item -> isSaleable ()) : ?> < input name = "super_group[<?php echo $_item->getId() ?>]" value = "<?php echo $_item->getQty()*1 ?>" type = "text" class= "input-text qty" /> <?php else: ?> <?php echo $this -> __ ( 'Out of stock.' ) ?> <?php endif; ?> </ td >
Insert the following code above it,
< td class= "a-center" > <?php if( $_product -> isSaleable ()): ?> <? = (int) Mage :: getModel ( 'cataloginventory/stock_item' )-> loadByProduct ( $_item )-> getQty () ?> <?php else: ?><?php echo $this -> __ ( 'Out of Stock' ) ?><?php endif; ?> </ td >
Lastly, find:
< thead > < tr > < th > <?php echo $this -> __ ( 'Product Name' ) ?> </ th > < th class= "a-right" > <?php echo $this -> __ ( 'Price' ) ?> </ th > <?php if ( $_product -> isSaleable ()): ?> < th class= "a-center" > <?php echo $this -> __ ( 'Qty' ) ?> </ th > <?php endif; ?> </ tr > </ thead >
and change to:
< thead > < tr > < th > <?php echo $this -> __ ( 'Product Name' ) ?> </ th > < th class= "a-right" > <?php echo $this -> __ ( 'Price' ) ?> </ th > < th class= "a-right" > <?php echo $this -> __ ( 'Availability' ) ?> </ th > <?php if ( $_product -> isSaleable ()): ?> < th class= "a-center" > <?php echo $this -> __ ( 'Qty' ) ?> </ th > <?php endif; ?> </ tr > </ thead >
You may refer to the screen shot attached.
Image Attachments
Click thumbnail to see full-size image
Signature
I never advertise for other hosts before, but I decide to recommend AH to you if you are in the same situation: starting up, limited budget, but looking for a reliable host for magento. Signed up for over a year now and I have totally no complaint with them. Yeah its affiliate but why not let me share that 25 cents from your subscription? Come on, you will pay nothing more
PS. If u wanna use Alipay to subscribe i might help u
nasha
Total Posts: 134
Joined: 2009-04-15
Does any body know how to show quantity for configurable product in dropdownlist .help me out
Posted: September 16 2009
| top
| # 14
itchytrig
Total Posts: 162
Joined: 2008-10-03
UK
Scyllar,
Hi, your updates to allow stock QTY to show on product pages works a treat, however we would like to extend the displaying of stock to section/search results pages too?
Is this just as quick to apply at all? Is it a case of amending:
/catalog/product/list.phtml
With the correct code? If so what exactly should I do???
Many thanks!
Signature
VOTE for Magento Features:
1 - Magento is way too slow… Google wants to index quick sites these days!
2 - View More Now on the Magento Community Edition Roadmap!!!
Posted: October 5 2009
| top
| # 15