Jump to content

[SOLVED] Show a custom image for Stock Status on List and Detail


Recommended Posts

Hi friendly Presta Community,

 

i need to put an custom image based on the Stock Status showing up in product list and product detail page.

 

Image 1 should show up if stock status is "avialible for order".

Image 2 should show up if stock status is "out of Stock".

 

I use the default theme with several modifikations.

 

Think that could be done really simple but don`t know how :)

 

Guess it must be done in product.tpl and product-list.tpl

 

I add a screenshot of how it should look like.

post-715146-0-35893800-1389696333_thumb.png

 

So thanx a lot in advanced for any information about that.

 

Greetz

SM5K

Link to comment
Share on other sites

Hi Vekia,

 

thank you for the answer and your time :)

 

The Out Of Stock should be indicated by Product Quantity == 0

 

The Availible for order should be indicated by Product Quantity >=1

 

So i think this is what you mean with "based on Quantity Fields".

 

Thank YOU!

Link to comment
Share on other sites

image if product is available to order (in stock)

{if $product->quantity > 0}
  <img src="AVAILABLE TO ORDER IMAGE" />
{/if}

image when product is out of stock:

{if $product->quantity ==0}
  <img src="OUT OF STOCK IMAGE" />
{/if}
  • Like 1
Link to comment
Share on other sites

Hey Vekia (Milos)

 

Just for full information to the next that could needs this.

 

<!-- Sold out part -->
            {if $product.quantity == 0}
              <img width="129px" height="260px" src="http://yourshopdomain.com/img/p/yourimagename2.png" />
            {/if}
<!-- Ende Sold out part -->

<!-- On Stock part -->
            {if $product.quantity > 0}
              <img width="129px" height="260px" src="http://yourshopdomain.com/img/p/yourimagename2.png" />
            {/if}
<!-- End of On Stock part -->

 

So just use $product.quantity instead of $product->quantity

 

Enjoy the day.

Greetz

SM5K

 

PS: Thank you for marking as solved :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Good job there Vekia.

I wonder if this possible to view stock quantities in bootstrap style like here

{if $product->quantity > 40}
				<div class="progress">
				  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="99" aria-valuemin="0" aria-valuemax="99" style="width: 99%">
					<span class="sr-only">Stock is full</span>
				  </div>
				</div>
			{/if}
			
			{if $product->quantity > 30}
				<div class="progress">
				  <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="75" style="width: 75%">
					<span class="sr-only">Stock is quite large</span>
				  </div>
				</div>
			{/if}
			
			{if $product->quantity > 20}
				<div class="progress">
				  <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="50" style="width: 50%">
					<span class="sr-only">Stock is on half</span>
				  </div>
				</div>
			{/if}
			
			{if $product->quantity > 10}
				<div class="progress">
				  <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="25" style="width: 25%">
					<span class="sr-only">Stock is almost empty</span>
				  </div>
				</div>
			{/if}
			
			{if $product->quantity > }
				<div class="progress">
				  <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="1" aria-valuemin="0" aria-valuemax="1" style="width: 1%">
					<span class="sr-only">Out of stock!</span>
				  </div>
				</div>
			{/if}

Unfortunately its not working ;/

Link to comment
Share on other sites

  • 6 months later...

hi

 

where exactly do you apply this modif?  product_list.tpl ? so far the stock management code (version 1.6.9) is :

 

{if (!$PS_CATALOG_MODE && $PS_STOCK_MANAGEMENT && ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
                    
                    
                        {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}
                            <span itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="availability">
                                {if ($product.allow_oosp || $product.quantity > 0)}
                                    <span class="{if $product.quantity <= 0 && !$product.allow_oosp}out-of-stock{else}available-now{/if}">
                                        <link itemprop="availability" href="http://schema.org/InStock" />{if $product.quantity <= 0}{if $product.allow_oosp}{if isset($product.available_later) && $product.available_later}{$product.available_later}{else}{l s='In Stock'}{/if}{else}{l s='Out of stock'}{/if}{else}{if isset($product.available_now) && $product.available_now}{$product.available_now}{else}
                                        {l s='In Stock'}{/if}{/if}
                                    </span>
                                {elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}
                                    
                                {else}
                                    <span class="out-of-stock">
                                        <link itemprop="availability" href="http://schema.org/OutOfStock" />{l s='Out of stock'}
                                    </span>
                                {/if}

 

 

do you replace all the above with the codes provided?

 

thanks

 

pat

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

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...