Jump to content

Show currently stock in Prestashop 1.7 cart


sukysa

Recommended Posts

Hello,

It is possible to show currently stock in Prestashop 1.7 cart?

Im trying to add {$product.quantity} in cart-detailed-product-line.tpl, but this variable shows same QTY that i added to cart (attaching screenshot)... In product.tpl and other pages this variable works fine!

Screenshot_2.png

Link to comment
Share on other sites

hello,
have you tried using {$product.stock_quantity}? it shows the total in stock, it will not change everytime you add product quantity because you didn't actually buy the product, but you if really want, you can do some thing like {$product.stock_quantity - $product.quantity}  and display it in cart-detailed-product-line.tpl anywhere. i hope it helps.

  • Like 1
Link to comment
Share on other sites

1 hour ago, ApoA said:

hello,
have you tried using {$product.stock_quantity}? it shows the total in stock, it will not change everytime you add product quantity because you didn't actually buy the product, but you if really want, you can do some thing like {$product.stock_quantity - $product.quantity}  and display it in cart-detailed-product-line.tpl anywhere. i hope it helps.

Hello,

Thanks for advice, just tried and got HTTP ERROR 500. :(

Link to comment
Share on other sites

hello, 
really? heres what i did, i edited cart-detailed-product-line.tpl,

  <!--  product left body: description -->
  <div class="product-line-grid-body col-md-4 col-xs-8">
    <div class="product-line-info">
      <a class="label" href="{$product.url}" data-id_customization="{$product.id_customization|intval}">{$product.name}</a>
    </div>

    {* I ADDED JUST THIS ONE *}
    <label>{$product.stock_quantity - $product.quantity}</label>
    {* I ADDED JUST THIS ONE *}

below that "product-line-info" class, that's what i added, just a label, and it works fine with me, you noticed the "299" from the picture?, that is the label with the amount of stock left, it changes everytime i add quantity for this product. it's just to show you how to get the stocks left for a product, if you get it right you can use that to anywhere you like in that tpl depending on your site. i hope my explanation is clear 😁

image.png.97cc6bd563938dd73759c37ecfda8208.png

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

1 minute ago, sukysa said:

I'm also added {$product.stock_quantity} and have same HTTP ERROR 500 :(

I'm using Prestashop 1.7.5.2, 

how did you guys did it? i did it before i replied my answer and it works just fine. are you sure you edited the right file?

Link to comment
Share on other sites

  • 5 months later...
On 8/29/2019 at 3:58 AM, ApoA said:

hello, 
really? heres what i did, i edited cart-detailed-product-line.tpl,


  <!--  product left body: description -->
  <div class="product-line-grid-body col-md-4 col-xs-8">
    <div class="product-line-info">
      <a class="label" href="{$product.url}" data-id_customization="{$product.id_customization|intval}">{$product.name}</a>
    </div>

    {* I ADDED JUST THIS ONE *}
    <label>{$product.stock_quantity - $product.quantity}</label>
    {* I ADDED JUST THIS ONE *}

below that "product-line-info" class, that's what i added, just a label, and it works fine with me, you noticed the "299" from the picture?, that is the label with the amount of stock left, it changes everytime i add quantity for this product. it's just to show you how to get the stocks left for a product, if you get it right you can use that to anywhere you like in that tpl depending on your site. i hope my explanation is clear 😁

image.png.97cc6bd563938dd73759c37ecfda8208.png

 This one worked for me...thanks a lot

Link to comment
Share on other sites

  • 5 months later...
On 8/28/2019 at 9:28 AM, ApoA said:

hello,
have you tried using {$product.stock_quantity}? it shows the total in stock, it will not change everytime you add product quantity because you didn't actually buy the product, but you if really want, you can do some thing like {$product.stock_quantity - $product.quantity}  and display it in cart-detailed-product-line.tpl anywhere. i hope it helps.

¡Thanks a lot!

$product.stock_quantity is perfect.

Link to comment
Share on other sites

  • 2 years later...

Hi Guys,


$product.stock_quantity is working fine for mee in on the cart page. 
This is exactly what i need on the product page. The product quantity that is not influenced by the amount in cart. I tried using this same variable on the product page but it does not work. Is there any variable or any way i can display the total quantity in stock on the product page?

Hope someone can help me.

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