Forums / Templates, Stylesheets, Page Layout / Adding Product Qty to a page

Adding Product Qty to a page

Locked

Views: 1,286

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
1 Feb 2007, 2:52 PM
#1
jayson_gurney avatar

jayson_gurney

Zen Follower

Join Date:
May 2006
Location:
UK
Posts:
101
Plugin Contributions:
0

Adding Product Qty to a page

Hi folks can some on please tell me how i can manually add the prouct quantity to a page.

I have changed the layout of how my wishlist is displayed and i want to be able to show on this if a product is in or out of stock but for the life of me i just cant get the right coding to allow this to happen.

For give my poor programming but i was thinking along the lines of this:

<?php if($products_quantity < 0) { echo 'In Stock'; } else { echo 'Out Off Stock';} ?>

its as if the page does not know the current value of $products_quanity as it always displays 'out off stock'

Can some kind sole please help me solve this small issue :)

1 Feb 2007, 3:26 PM
#2
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Adding Product Qty to a page

I assume you're trying to add this to the product_info page?
If the code sample you posted is what you're trying to use, you have a very basic error there: your if statement should read if $products_quantity is **greater than **zero, not is less than zero....

Neville
An assumption is what you arrive at when you get tired of thinking...

1 Feb 2007, 3:58 PM
#3
jayson_gurney avatar

jayson_gurney

Zen Follower

Join Date:
May 2006
Location:
UK
Posts:
101
Plugin Contributions:
0

Re: Adding Product Qty to a page

Hi i am trying to include this on my wishlist page. I have installed the wishlist module from here on the forum and want to display if products are in or out of stock.

The code just displays the 'Out of Stock' message regardless and I am convinced its because it does not know what $products_quanity is now, but now do i acheive this??

1 Feb 2007, 5:37 PM
#4
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Adding Product Qty to a page

I'm not familiar with the wishlist module, but I just found a copy and took a quick look at it.
Absolutely no guarantees on this code (make a good backup before you edit) but try changing your sql query to this:

<?php if(zen_get_products_stock($products->fields['products_id']) > 0) {
echo 'In Stock';
} else {
echo 'Out Of Stock';
}
?>

Possible improvement: it looks to me on my quick glance at the files that the wishlist mod includes how many of the product is desired: you could modify the query to see if there is at least that many in stock:

<?php if(zen_get_products_stock($products->fields['products_id']) >= $products->fields['products_quantity']) {
echo 'In Stock';
} else {
echo 'Out Of Stock';
}
?>

Neville
An assumption is what you arrive at when you get tired of thinking...

2 Feb 2007, 10:06 AM
#5
jayson_gurney avatar

jayson_gurney

Zen Follower

Join Date:
May 2006
Location:
UK
Posts:
101
Plugin Contributions:
0

Re: Adding Product Qty to a page

bunyip:

I'm not familiar with the wishlist module, but I just found a copy and took a quick look at it.
Absolutely no guarantees on this code (make a good backup before you edit) but try changing your sql query to this:

<?php if(zen_get_products_stock($products->fields['products_id']) > 0) { echo 'In Stock'; } else { echo 'Out Of Stock'; } ?>

I have tried this code and it works in a fashion.  Adding my first product to a wishlist workd great, it correctly displays the product title and whether its in or out of stock.  However the problem arises when another item is added.  The original entry is changed to match that of the new product, and thus does not give a correct representation of the wishlist. Can anyone help me resolve this problem?
2 Feb 2007, 10:17 AM
#6
jayson_gurney avatar

jayson_gurney

Zen Follower

Join Date:
May 2006
Location:
UK
Posts:
101
Plugin Contributions:
0

Re: Adding Product Qty to a page

Please ignore the last post - I have just noticed errors in my own wishlist code. Will resolve this then take a 2nd look at the instock again.:blush: