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 yesterday at 05:08 PM by MrWade Solved (see edit history) Link to comment Share on other sites More sharing options...
Prestashop Addict Posted Friday at 09:51 AM Share Posted Friday at 09:51 AM Hi, this is certainly depend of your theme, which one? Link to comment Share on other sites More sharing options...
MrWade Posted Friday at 01:58 PM Author Share Posted Friday at 01:58 PM It's the original default theme. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted Friday at 03:25 PM Share Posted Friday at 03:25 PM 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 Friday at 03:35 PM Author Share Posted Friday at 03:35 PM No, change. Still showing Last items in stock.... Link to comment Share on other sites More sharing options...
Prestashop Addict Posted Friday at 03:42 PM Share Posted Friday at 03:42 PM verify that you are configured on recomplie template if changed Link to comment Share on other sites More sharing options...
MrWade Posted Friday at 04:23 PM Author Share Posted Friday at 04:23 PM I have already done that still no change. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted Friday at 04:30 PM Share Posted Friday at 04:30 PM 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 Friday at 04:51 PM Author Share Posted Friday at 04:51 PM 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 Friday at 06:06 PM Share Posted Friday at 06:06 PM 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 Friday at 06:21 PM Author Share Posted Friday at 06:21 PM Where do I put that code? Link to comment Share on other sites More sharing options...
MrWade Posted Saturday at 04:14 AM Author Share Posted Saturday at 04:14 AM Anyone? Link to comment Share on other sites More sharing options...
bestgateservice Posted Saturday at 05:34 AM Share Posted Saturday at 05:34 AM 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 Saturday at 07:47 AM Share Posted Saturday at 07:47 AM 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 Saturday at 01:09 PM Author Share Posted Saturday at 01:09 PM What revelent string do I need to replace from x? Link to comment Share on other sites More sharing options...
MrWade Posted Saturday at 04:30 PM Author Share Posted Saturday at 04:30 PM 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 Saturday at 04:56 PM Share Posted Saturday at 04:56 PM (edited) Go to you product (category) and filter the one you wish to control. Edited Saturday at 07:14 PM by Nickz (see edit history) Link to comment Share on other sites More sharing options...
MrWade Posted Saturday at 04:58 PM Author Share Posted Saturday at 04:58 PM Ok, that doesn't help me. Link to comment Share on other sites More sharing options...
Nickz Posted Saturday at 07:15 PM Share Posted Saturday at 07:15 PM 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 Saturday at 07:35 PM Author Share Posted Saturday at 07:35 PM 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 Saturday at 09:48 PM Share Posted Saturday at 09:48 PM 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 Saturday at 10:35 PM Author Share Posted Saturday at 10:35 PM 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 Sunday at 07:49 AM Share Posted Sunday at 07:49 AM (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 Sunday at 02:40 PM by Andrei H (see edit history) 1 Link to comment Share on other sites More sharing options...
MrWade Posted Sunday at 02:23 PM Author Share Posted Sunday at 02:23 PM Thank You! That is what I wanted. 1 Link to comment Share on other sites More sharing options...
Divine Posted yesterday at 05:04 PM Share Posted yesterday at 05:04 PM 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