Jump to content

[SOLVED] Display "Sold Out" In Product-List.Tpl Got Errors


Recommended Posts

I'm having a trouble when put this code inside product-list.tpl:

 

{if $product.allow_oosp OR $product.quantity > 0}  
                   <p class="price">
                       {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
                   </p>

                   {else}
                   	<p class="price">SOLD OUT</p>
                 {/if}

 

This code showing 2 kinds of errors :

1. Many products showing "Sold Out" even it doesn't have any attributes and the quantity is still enough to order.

2. For the products with attributes, if the main attributes' qty is 0, then it shows "Sold Out" in product-list.tpl, so I have to select another attributes to be primary one, and the problem's solved for this part. But it doesn't have to be done manually, right?

 

The question is (probably gonna solve the problems)...

 

Is it possible to change the $product.quantity to SELECT data from product id in "product" table that still has a quantity > 0, because I think this code somehow selecting the quantity from "product_attribute" table.

 

Please help me solve this problem asap, or anybody has any advices?

 

Thank you!

Link to comment
Share on other sites

I think you are right, the quantity is from attribute table and it is from default attribute.

But this is correct because in list you can only show one attributte.

 

You can change to read quantity from product table, but it will cause problem, because when click add to cart, it will still add the product with default attribute and it is out of stock.

 

You are doing the correct way by chabging the default attribute to the one still in stock.

 

My advice:

You can create a module or hire some to create module that automatically chabge the default attribute when the default one is out of stock.

.

Link to comment
Share on other sites

I think you are right, the quantity is from attribute table and it is from default attribute.

But this is correct because in list you can only show one attributte.

 

You can change to read quantity from product table, but it will cause problem, because when click add to cart, it will still add the product with default attribute and it is out of stock.

 

You are doing the correct way by chabging the default attribute to the one still in stock.

 

My advice:

You can create a module or hire some to create module that automatically chabge the default attribute when the default one is out of stock.

.

 

Thanks for your kind reply

 

I think I will try to change the SELECT product's quantity from "product" table not "product attribute" table first. and also, I have removed the "add to cart" button in product-list.tpl so it's no problem because people will go to the product detail's page first to 'add to cart'.

 

Anyway, do you have any advice to make something like "$product_qty > 0" and SELECT the $product_qty data from 'quantity' field inside table product? I have tried your step by step guide in some post about how to make "products sold: $product_sold" or something like that, but it led me to a wrong one, because I didn't find "include once init.php" inside "classes/product.php".

 

btw, I'm using prestashop 1.4, if you think the code has to be adjusted to these new versions..

 

 

Thank you shokinro

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...