MrWade Posted January 9 Share Posted January 9 (edited) Yes, I am using PS v 8.1.7 How can I change the "Last items in stock!" to "Only, X left in stock!" on the product page? I have the stock settings as Display remaining quantities when the quantity is lower than 5. Is there a code I need to change? Thank You! Wade Edited January 14 by MrWade Solved (see edit history) Link to comment Share on other sites More sharing options...
Prestashop Addict Posted January 10 Share Posted January 10 Hi, this is certainly depend of your theme, which one? Link to comment Share on other sites More sharing options...
MrWade Posted January 10 Author Share Posted January 10 It's the original default theme. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted January 10 Share Posted January 10 In template catalog/_partials/product-details.tpl change {block name='product_quantities'} {if $product.show_quantities} <div class="product-quantities"> <label class="label">{l s='In stock' d='Shop.Theme.Catalog'}</label> <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{$product.quantity} {$product.quantity_label}</span> </div> {/if} {/block} with {block name='product_quantities'} {if $product.show_quantities} <div class="product-quantities"> <span data-stock="{$product.quantity}" data-allow-oosp="{$product.allow_oosp}">{l s='Only, %stockvalue% left in stock!' d='Shop.Theme.Catalog' sprintf=['%stockvalue%' => $product.quantity]}</span> </div> {/if} {/block} Link to comment Share on other sites More sharing options...
MrWade Posted January 10 Author Share Posted January 10 No, change. Still showing Last items in stock.... Link to comment Share on other sites More sharing options...
Prestashop Addict Posted January 10 Share Posted January 10 verify that you are configured on recomplie template if changed Link to comment Share on other sites More sharing options...
MrWade Posted January 10 Author Share Posted January 10 I have already done that still no change. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted January 10 Share Posted January 10 I don't know what to say, I tested on a local 8.1.7, and 8.2 with classic theme and it works directly! Link to comment Share on other sites More sharing options...
MrWade Posted January 10 Author Share Posted January 10 Ok, the one that is circled. Is it possible to put "Only, X left in stock!"? Link to comment Share on other sites More sharing options...
Prestashop Addict Posted January 10 Share Posted January 10 Ok this is not the same place in the template. Move the sample code at the right place in the template. Link to comment Share on other sites More sharing options...
MrWade Posted January 10 Author Share Posted January 10 Where do I put that code? Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 Anyone? Link to comment Share on other sites More sharing options...
bestgateservice Posted January 11 Share Posted January 11 On 1/9/2025 at 10:53 AM, MrWade said: Yes, I am using PS v 8.1.7 How can I change the "Last items in stock!" to "Only, X left in stock!" on the product page? I have the stock settings as Display remaining quantities when the quantity is lower than 5. Is there a code I need to change? Thank You! Wade Hi Wade, To change "Last items in stock!" to "Only X left in stock!", go to International > Translations in the PrestaShop back office, edit Themes Translations, and replace the text in the relevant string. Save your changes and clear the cache. Let me know if you need more help! Link to comment Share on other sites More sharing options...
royaldeliverymu Posted January 11 Share Posted January 11 Hi Wade, To change "Last items in stock!" to "Only X left in stock!" in PrestaShop v8.1.7: Go to International > Translations in your admin panel. Select Front Office Translations, and your language. Search for "Last items in stock!" and change it to "Only X left in stock!". Save the changes. This should update the message on your product pages. Let me know if you need further help! Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 What revelent string do I need to replace from x? Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 I have it change to Only X left in stock! in the back office. But, how can I change the x to see the actual number of what I have left in stock? Thank You! Link to comment Share on other sites More sharing options...
Nickz Posted January 11 Share Posted January 11 (edited) Go to you product (category) and filter the one you wish to control. Edited January 11 by Nickz (see edit history) Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 Ok, that doesn't help me. Link to comment Share on other sites More sharing options...
Nickz Posted January 11 Share Posted January 11 2 hours ago, MrWade said: Ok, that doesn't help me. Not even here? product (category) Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 What does the product (category) do with the stock counts? What I am wanting to do is to show Only, 3(X) left in stock! When I have stock less than 5 its shows "Last items in Stock". Link to comment Share on other sites More sharing options...
Frevab Posted January 11 Share Posted January 11 You may try to delete your browser history to get ride of the old page and make it load it fresh from your webshop server. When I try to find something in the PS files I download the shop to my local drive and use notepad++ to search through the files for a specific text. Then you see in which file it is and can change it there with notepad++ and upload it back to the server or change it live at the server. Link to comment Share on other sites More sharing options...
MrWade Posted January 11 Author Share Posted January 11 Ok, I have change the text. The problem now is I can't get the low stock to show. So the X is suppose to be a number of low stock. What am I missing? Link to comment Share on other sites More sharing options...
Andrei H Posted January 12 Share Posted January 12 (edited) Hello, The translation system isn't randomly injecting variables into the texts, this is why you will always see X. The above comments about translations seem to be generated with AI and you should ignore them. You will need to edit the following file: src/Adapter/Presenter/Product/ProductLazyArray.php On ~ lines 981 - 985, you should see the following: $this->product['availability_message'] = $this->translator->trans( 'Last items in stock', [], 'Shop.Theme.Catalog' ); You need to replace it with: $this->product['availability_message'] = $this->translator->trans( 'Only %d left in stock!', ['%d' => $availableQuantity === 0 ? 0 : $availableQuantity + 1], 'Shop.Theme.Catalog' ); Now, in my case the quantity seems to always be less by one for some reason, this is why I added + 1 in there. If, after making the above changes you see an incorrect number, you can change the above code with: $this->product['availability_message'] = $this->translator->trans( 'Only %d left in stock!', ['%d' => $availableQuantity], 'Shop.Theme.Catalog' ); Once the changes are saved, you should be able to see the changes, as shown in my screenshot. Edited January 12 by Andrei H (see edit history) 1 Link to comment Share on other sites More sharing options...
MrWade Posted January 12 Author Share Posted January 12 Thank You! That is what I wanted. 1 Link to comment Share on other sites More sharing options...
Divine Posted January 14 Share Posted January 14 Don't forget to edit your first post and to add [Solved] in the title 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now