Jump to content

How to show product availability in cart


Recommended Posts

Hi,

I try to get product availability to show in cart like it show's at productlist.

I edit cart-detailed-product-line.tpl

If I for example try to take code from product.tpl and put in to cart-detailed-product-line.tpl the status always show 'In stock'

 <article data-id-product="{$product.id_product}" data-id-product-attribute="{$product.id_product_attribute}">
<div class="availability">
                {block name='product_availability'}
                  <span class="pl-availability">
                    {if $product.show_availability && $product.availability_message}
                      {if $product.availability == 'available'}
                        <i class="material-icons product-available">&#xE5CA;</i>
                      {elseif $product.availability == 'last_remaining_items'}
                        <i class="material-icons product-last-items">&#xE002;</i>
                      {else}
                        <i class="material-icons product-unavailable">&#xE14B;</i>
                      {/if}
                      {$product.availability_message}
                    {else}
                        {if $product.allow_oosp == 0}
                            <i class="material-icons product-available">&#xE5CA;</i> {l s='In stock' d='Shop.Theme.Catalog'}
                        {/if}
                        
                        {if $product.allow_oosp == 1}
                            {* <i class="material-icons product-unavailable">&#xE14B;</i> {l s='Out of stock' d='Shop.Theme.Catalog'} *}
                            <i class="material-icons product-available">&#xE5CA;</i> {l s='In stock' d='Shop.Theme.Catalog'}
                        {/if}
                    {/if}
                  </span>
                {/block}
                </div>
</article>

{$product.availability} always = available even if product in stock or not.

Can anyone guide me how to do this?

Thanks.

Link to comment
Share on other sites

  • 9 months later...

Can you at least read before you reply, please?

 

PS1.6.x - when you add something to the cart, there is a summary, which shows Availability for each product. Nothing like that is in PS17, this feature was removed. Any idea, how to add this feature to PS17? Screenshots attached.

 

Thanks

2141998385_Screenshot2020-01-20at16_50_42.thumb.png.6246064e28fff537f20fcdb328a2c3b6.png2038084672_Screenshot2020-01-20at16_47_48.thumb.png.36421c039435a8bc3c82c3f49ea8be0e.png

 

 

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

  • 5 months later...
On 1/20/2020 at 4:49 PM, JanHavlicek said:

Can you at least read before you reply, please?

 

PS1.6.x - when you add something to the cart, there is a summary, which shows Availability for each product. Nothing like that is in PS17, this feature was removed. Any idea, how to add this feature to PS17? Screenshots attached.

 

Thanks

2141998385_Screenshot2020-01-20at16_50_42.thumb.png.6246064e28fff537f20fcdb328a2c3b6.png2038084672_Screenshot2020-01-20at16_47_48.thumb.png.36421c039435a8bc3c82c3f49ea8be0e.png

 

 

Hello 

 

did you solve it?

 

Thanks

Angela

 

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 2 months later...
  • 2 months later...

Here's the solution to show product availability on cart (tested on PS1.7.7.3):

File to be modified:
themes/classic/templates/catalog/_partials/product-add-to-cart.tpl

    {if $product.stock_quantity<=0}
      <span style="font-weight:700;color:red;">Out of stock</span>
    {elseif $product.stock_quantity < $product.quantity}
      <span style="font-weight:700;color:orange;">Non available in the desidered quantity</span>
    {else}
      <span style="font-weight:700;color:green;">Available</span>
    {/if}

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

/templates/checkout/_partials/cart-detailed-product-line.tpl

    <!-- availability -->
    <div class="cart-product-availability">
      {if $product.stock_quantity<=0}
	<span class="product-not-available"><i class="icon-times"></i> Out of stock</span>
      {elseif $product.stock_quantity < $product.quantity}
	<span class="product-insufficient-stock"><i class="icon-exclamation"></i> Only {$product.stock_quantity} available</span>
      {else}
	<span class="product-available"><i class="icon-check"></i> Available</span>
      {/if}
    </div>

 

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

Hello Dark,

thx for your answer. But are you sure, that this works in the BASKET?

I would think this code is for the product-page?! If I try this, nothing changes at the basket, but I have an error at my product page?

 

 

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Hello Darkf3d3,

you saved my day! It works perfect!

I`ve had some problems, that the icons did not appear. But it is no problem to solve it with some lines of css.

For those, who are not sure, where they should place the code - here is my code without icons and the place in the code:

original code in /templates/checkout/_partials/cart-detailed-product-line.tpl :

      <div class="current-price">
        <span class="price">{$product.price}</span>
        {if $product.unit_price_full}
          <div class="unit-price-cart">{$product.unit_price_full}</div>
        {/if}
      </div>
    </div>

New code after this (with german text):

    <!-- availability -->
    <div class="cart-product-availability">
      {if $product.stock_quantity<=0}
    <span class="product-not-available">Zur Zeit nicht verf&uuml;gbar</span><br><span class="product-not-available-2">Bitte aus dem Warenkorb entfernen.</span>
      {elseif $product.stock_quantity < $product.quantity}
    <span class="product-insufficient-stock">Nur {$product.stock_quantity} St&uuml;ck verf&uuml;gbar</span><br><span class="product-not-available-2">Bitte passen Sie den Warenkorb an.</span>
      {else}
    <span class="product-available">Verf&uuml;gbar</span>
      {/if}
    </div>


CSS:
 

.cart-product-availability .product-not-available, .cart-product-availability .product-insufficient-stock {
  color: white;
  background-color: darkred;
  padding: 5px 8px;
  border-radius: 5px;
}

.cart-product-availability .product-available {
  color: white;
  background-color: green;
  padding: 5px 8px;
  border-radius: 5px;
}

.product-not-available-2 {
  padding-top: 5px;
  line-height: 30px;
  font-weight: bold;
}

 

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