Jump to content

"Available" and "Out of stock" text in different colours in product list


Recommended Posts

Hi!

 

In 1.4.4.1 I've managed to separately colour availability text in product list: "Available" in green and "Out of stock" in red.

 

I modified product-list.tpl in line 44 from:

 

 {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}

 

to:

 

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{/if}</span>{/if}
			{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability" style="color:red; ">{if (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s=''}{else}{l s='Out of stock'}{/if}</span>{/if}

 

I know this isn't a complete solution, nor an elegant one, but it works, unless allowing orders when product is out of stock.

 

Can anyone please offer a better or maybe a complete way how to solve this?

 

Thanks in advance!

post-275314-0-25180500-1319488613_thumb.jpg

Link to comment
Share on other sites

Thank you very much, Marty.

 

Can you be so kind and paste the code? The thing is I've already tried that (named the class "availability1") and created it in product-list.css, but it hasn't seemed to work.

 

Thanx again.

Link to comment
Share on other sites

Ok,

 

I did what Marty suggested, added new class"outofstock" in row 45, product-list.tpl from lines 42-46 now looks like:

 

<div>
			{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
			{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{/if}</span>{/if}
			{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="outofstock">{if (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s=''}{else}{l s='Out of stock'}{/if}</span>{/if}
			</div>

 

Created additional 4 rows (67-70) in product-list.css:

 

ul#product_list li span.outofstock {
color: red;
font-size: 11px;
}

 

The problem stays the same: this doesn't work if product is allowed to be ordered when out of stock - "Available" and "Out of stock" notes are displayed in product list at the same time.

 

Any suggestions? Thanks.

post-275314-0-24640300-1319529171_thumb.png

Link to comment
Share on other sites

Ok,

 

the new code is:

 

<div>
			{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
			{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{/if}</span>{/if}
			{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="outofstock">{if (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{else}{l s='Out of stock'}{/if}</span>{/if}
			</div>

 

This eliminates "Available" and "Out of stock" notes being displayed in product list at the same time, that's ok now.

 

Problem with allowing products to be ordered when out of stock still exists, any help will be much appreciated.

 

Over & Out

Link to comment
Share on other sites

I mean: two possibilities in BO>Products>Allow ordering out-of-stock product: yes and no

 

and three possibilites for a product which is out of stock: BO>Catalog>Deny orders, Allow orders and Default: Deny orders (as set in Preferences)

 

make 6 combinations, and neither work.

 

Link is here. There's only few test products in at the moment.

 

Thank you ver much for taking your time.

Link to comment
Share on other sites

I'm sorry,

 

it looks like I was a little hasty. I overlooked that product-list problem still persists: "Available" and "Out of stock" notes are displayed in product list at the same time.

 

Obviously my code needs a final touch:

 

<div>
							{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
							{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{/if}</span>{/if}
							{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="outofstock">{if (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{else}{l s='Out of stock'}{/if}</span>{/if}
							</div>

 

 

Thanks for helping!

post-275314-0-09169800-1319559944_thumb.png

Link to comment
Share on other sites

You need to use this code

<div>
 {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
 {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}
   </div>

 

Marty Shue

Link to comment
Share on other sites

Hi!

 

Thank you Marty, but this puts me on beginning, since that is an original code ("Available" and "Out of stock" notes in same color).

 

This is my best shot, but problem with displaying "Available" and "Out of stock" notes in product list at the same time remains:

 

<div>
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span><br />{/if}
{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{/if}</span>{/if}
{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="outofstock">{if (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{else}{l s='Out of stock'}{/if}</span>{/if}
</div>

 

I can't do it better, any help will be much appreciated.

 

Thanks loads.

Link to comment
Share on other sites

  • 2 months later...

Hi,

this is what you need:

 

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}</span>
{else}<span class="outofstock">{l s='Out of stock'}{/if}{if isset($product.online_only) && $product.online_only} ({l s='Online only!'}){/if}</span>{/if}

Link to comment
Share on other sites

  • 11 months later...

Is there anyone that can help setting this up under product.tpl and product.css

I don't have availability under product_list, and I would like to have red or green background whether the product is out of stock or available on the product page.

I use PS 1.5.2.0

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Hi jkousholt,

 

I do have a solution for you which will work including with different colours.

 

In the product-list.tpl change this code:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}

 

to:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if $product.quantity > 0}{l s='Available'}</span>{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}<span class="outofstock">{l s='Out of stock'}{/if}</span>{/if}

 

Then in the product_list.css search for the following line:

#product_list li span.availability {
  color: #488C40
}

 

add thereafter:

#product_list li span.outofstock {
  color: #F22C2C
}

 

And then change the colour in everything you want. Now it will show different stock statusses on the product list!

 

Regards!

Edited by Martijnsb (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi jkousholt,

 

I do have a solution for you which will work including with different colours.

 

In the product-list.php change this code:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}

 

to:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if $product.quantity > 0}{l s='Available'}</span>{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}<span class="outofstock">{l s='Out of stock'}{/if}</span>{/if}

 

Then in the product_list.css search for the following line:

#product_list li span.availability {
  color: #488C40
}

 

add thereafter:

#product_list li span.outofstock {
  color: #F22C2C
}

 

And then change the colour in everything you want. Now it will show different stock statusses on the product list!

 

Regards!

 

I've tried it, but am I wrong if this is for the product list? (Yes I'm a rookie :) ) Because I couldn't get it to work.

I need the feature at the product page.

 

Hope you can help me again.

Link to comment
Share on other sites

If it is right the color of the product status on the product page is handled standard in prestashop. When you add a product go to the tab 'Quantities' and at the bottom you will find two fields where you can enter your text which you want to display when a product is in stock and when it is out of stock.

When you add these, you will find a red marked field with your text at the product page when your product is out of stock and a green one when your product is in stock. Hope this is what you mean

 

Regards!

Link to comment
Share on other sites

This is a tunic with color attribute grøn (green in danish) and size XXL

http://bettebiksen.dk/da/525-tunika-med-broderier.html#/farve-grøn/størrelse-xxl

 

The item is out of stock, but the customer can still order it. But i need to make it more visible that the item is a "BESTILLINGSVARE" (an out-of-stock item that can be ordered, but have a delivery of 3 weeks).

My customers often miss the text with blue background, and thinks the item is in stock. And when I tell them the items is not in stock, they often cancel the item.

 

With stock items I would like to keep the blue background.

 

Hope this makes sense to you

Link to comment
Share on other sites

I understand, you want to make the BESTILLINGSVARE (out of stock) in for example a red color and on stock still in blue.

What you can do is the following, open this file: themes/your theme/css/product.css

 

Search for:

#availability_value.warning_inline

 

There you will find a background-color. Behind change you color to, for example: #CE1017

This will change the color from out of stock items to red. You can change this parameter into any HTML color you want.

Let me know if this works for you, if you still have any problems please advise and I will try to help you out.

 

Kind Regards!

Link to comment
Share on other sites

  • 1 month later...

Hi jkousholt,

 

I do have a solution for you which will work including with different colours.

 

In the product-list.tpl change this code:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}

 

to:

{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if $product.quantity > 0}{l s='Available'}</span>{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}<span class="outofstock">{l s='Out of stock'}{/if}</span>{/if}

 

Then in the product_list.css search for the following line:

#product_list li span.availability {
  color: #488C40
}

 

add thereafter:

#product_list li span.outofstock {
  color: #F22C2C
}

 

And then change the colour in everything you want. Now it will show different stock statusses on the product list!

 

Regards!

 

Hello Mertijnsb, tanks for your precious help

that code worked for me, but how to change the color for this: "Product available with different options"

I want this to be Blue

I have tried add to the "product_list.css" this code:

 

#product_list li span.product available with different options {
  color: #0000FF
}

 

but this do not work... :(

 

EDIT:

Ok my code is now this:

 

#product_list li span.availability {
  color: #0000FF
}

#product_list li span.outofstock {
  color: #F22C2C
}


#product_list li span.available {
  color: #488C40
}

 

but as you can see this makes all available products blue

 

What i want is this: Available Out of stock Product available with different options

i only want add a different color for each product status,

is this to hard to accomplish?

 

 

tanks again for your help.

Edited by majority (see edit history)
Link to comment
Share on other sites

  • 5 months later...

Good afternoon.
In products-list is displayed when a product has attributes "in stock with other options." Is there a way to display on the product page when an attribute that has no stock no stock display.

 

thanks

 

sorry my english

Link to comment
Share on other sites

  • 1 month later...

Thanks guys, it has been really helpful. I use prestashop 1.5.6.1 and it works now. They should implement it in future updates though. Remember, to input proper words in shop pages translations, especially for non-english translations. Opionai, you may use just an empty word or space in your shop page translation - i think there are some more solutions to it.

Link to comment
Share on other sites

  • 1 month later...

How to translate it for other languages (multi language store)?

 

is there a way to call the product state from the "Displayed text when in-stock" and "Displayed text when back-ordereding is allowed" from Availability settings instead call it from Quantity?

 

it makes more sense to just display the same availability state as the product page availability state.

 

 

tanks.

Edited by majority (see edit history)
Link to comment
Share on other sites

  • 3 years later...
  • 4 months later...

*bump*

 

Any solutions yet?

 

tried above code, but all it does changes eveything to black, and i dont have such lines in my css.

 

want the same thing, so  in stick = green

sold out, but available for order =  orange

sold out =  red.

 

using ps 1.6.1.13.

 

thanx!

Link to comment
Share on other sites

×
×
  • Create New...