Jump to content

Show product availability in shopping cart


aligulbay
 Share

Recommended Posts

Hello

 

Sometimes my customers add their products to shopping cart and check out later. some of products may go out of stock after adding it to cart. So prestashop shows an error message about it, but does not tell you which product/s out of stock in order page

 

is there any way to show availability of the product in shopping cart page ?  order.tpl

 

Regards

 

 

Ali

 

 

 

Share this post


Link to post
Share on other sites

Hello,

 

In shopping-cart.tpl of your theme  around line 85  (in prestashop 1.5.4 ) inside the loop starting with "for each $products as $product{"  and before the comment  {* Display the product line *},    put the following:

{assign var='availability' value=$product.available_now}
                        

And after the comment   {* Display the product line *} where each product's line is formed, you can choose where to insert 

Availability:{$availability}
                       

The word Availability is not necessary, just the bracketed variable is enough.

This variable displays an availability-related text (eg. in stock).

You can enclose it in a suitable html tag and inject it in the .tpl according to your taste  (probably just before the loop ending  {/foreach} between <li></li> tags ).

 

Hope it helps

 

Regards.

Share this post


Link to post
Share on other sites

Hello,

 

In shopping-cart.tpl of your theme  around line 85  (in prestashop 1.5.4 ) inside the loop starting with "for each $products as $product{"  and before the comment  {* Display the product line *},    put the following:

{assign var='availability' value=$product.available_now}
                        

And after the comment   {* Display the product line *} where each product's line is formed, you can choose where to insert 

Availability:{$availability}
                       

The word Availability is not necessary, just the bracketed variable is enough.

This variable displays an availability-related text (eg. in stock).

You can enclose it in a suitable html tag and inject it in the .tpl according to your taste  (probably just before the loop ending  {/foreach} between <li></li> tags ).

 

Hope it helps

 

Regards.

 

 

Hello

I  have a custom theme

 

I have two files shopping-cart.tpl and shopping-cart-product-line.tpl

 

I aded {assign var='availability' value=$product.available_now} into shopping-cart.tpl and Availability:{$availability} into shopping-cart-product-line.tpl

but nothing changed

 

Regards

Share this post


Link to post
Share on other sites

Hello

I  have a custom theme

 

I have two files shopping-cart.tpl and shopping-cart-product-line.tpl

 

I aded {assign var='availability' value=$product.available_now} into shopping-cart.tpl and Availability:{$availability} into shopping-cart-product-line.tpl

but nothing changed

 

Regards

As long as you have added  the assign statement, add as follows in shopping-cart.tpl:(just add the  availabilty line inside that block, the rest of the code is for reference):

<thead>
			<tr>
				<th class="cart_product first_item">{l s='Product'}</th>
				<th class="cart_description item">{l s='Description'}</th>
				<th class="cart_ref item">{l s='Ref.'}</th>
                                <th class="cart_ref item">{l s='Avail.'}</th><!--add this line only-->
				<th class="cart_unit item">{l s='Unit price'}</th>
				<th class="cart_quantity item">{l s='Qty'}</th>
				<th class="cart_total item">{l s='Total'}</th>
				<th class="cart_delete last_item"> </th>
			</tr>
		</thead>

In shopping-cart-product-line add  (just the  availabilty line, the rest of the code is for reference):

<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>
        <td> {$availability}</td><!--add this line only -->
	<td class="cart_unit">

This should show  an availability column in product line.

Let me know

 

Regards.

Edited by netplayer (see edit history)

Share this post


Link to post
Share on other sites

As long as you have added  the assign statement, add as follows in shopping-cart.tpl:(just add the  availabilty line inside that block, the rest of the code is for reference):

<thead>
			<tr>
				<th class="cart_product first_item">{l s='Product'}</th>
				<th class="cart_description item">{l s='Description'}</th>
				<th class="cart_ref item">{l s='Ref.'}</th>
                                <th class="cart_ref item">{l s='Avail.'}</th><!--add this line only-->
				<th class="cart_unit item">{l s='Unit price'}</th>
				<th class="cart_quantity item">{l s='Qty'}</th>
				<th class="cart_total item">{l s='Total'}</th>
				<th class="cart_delete last_item"> </th>
			</tr>
		</thead>

In shopping-cart-product-line add  (just the  availabilty line, the rest of the code is for reference):

<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>
        <td> {$availability}</td><!--add this line only -->
	<td class="cart_unit">

This should show  an availability column in product line.

Let me know

 

Regards.

Hello again

thank you for your help

 

yes there is a Avail column now

 

but it does not show up the out of stock product on the column

 

Regards

Share this post


Link to post
Share on other sites

Just replace  

{assign var='availability' value=$product.available_now

 

with 

 

{assign var='availability' value=$product.quantity_available}

 

This shows the quantity in stock.

 

if you need to show just literaly stock availability you can use instead smthg like this:

 

{if $product.quantity_available==0}{assign var='availability' value='out of stock'} 
                           {else}
                               {assign var='availability' value=$product.quantity_available}
                            {/if}

 

 

Rgrds

Edited by netplayer (see edit history)

Share this post


Link to post
Share on other sites

Just replace  

{assign var='availability' value=$product.available_now

 

with 

 

{assign var='availability' value=$product.quantity_available}

 

This shows the quantity in stock.

 

if you need to show just literaly stock availability you can use instead smthg like this:

 

{if $product.quantity_available==0}{assign var='availability' value='out of stock'} 
                           {else}
                               {assign var='availability' value=$product.quantity_available}
                            {/if}

 

 

Rgrds

 

 

Hello Again

 

this works fine ;)

 

thanks alot for your help

Share this post


Link to post
Share on other sites

  • 1 year later...

Thanks for the fix. However, I would like to know how to make the availability refresh (show the updated message "out of stock" or "in stock") whenever the quantity is changed.

 

At the moment i am using this code:

 

{if $product.quantity_available<$product.quantity}{assign var='availability' value='Not Enough Stock'} {else}{assign var='availability' value=$product.available_now}{/if}

 

So if i amend the quantity to a correct quantity by using the minus sign, it doesn't change from Not Enough Stock to In Stock.

 

Thanks,

Samuel

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More