Thomas Will Posted Friday at 11:08 AM Share Posted Friday at 11:08 AM Hello, I would like to display the available quantity only in certain categories. I've tried the following (product.tpl / Presta 1.6.1.1) ... {if in_array($category.id, array(59)}{$product->quantity}{/if} unfortunately, without success. Does anyone have an idea for me? Thomas Link to comment Share on other sites More sharing options...
Knowband Plugins Posted Friday at 12:23 PM Share Posted Friday at 12:23 PM in array will not work in Smarty. Check the Smarty documentation for details. https://www.smarty.net/docs/en/ Try OR method. {if $category->id == 59 or $category->id == 60} {$product->quantity} {/if} OR try {if $category->id is in [59, 60, 61]} {$product->quantity} {/if} Link to comment Share on other sites More sharing options...
Thomas Will Posted Friday at 06:43 PM Author Share Posted Friday at 06:43 PM Thank you very much. It works. Unfortunately, even with variants, the total quantity of all items is now always displayed, not just the quantity of the respective variant (color or size, etc.). Link to comment Share on other sites More sharing options...
Thomas Will Posted Saturday at 09:40 AM Author Share Posted Saturday at 09:40 AM Now I've tried the following... This only displays the quantity if the article is in category 169, but unfortunately the total quantity is displayed and not the quantity for each attribute. {if ($display_qties == 1 && $pproperties.pp_qty_available_display != 2 && !$PS_CATALOG_MODE && $PS_STOCK_MANAGEMENT && $product->available_for_order && $category->id is in [169])} <!-- number of item in stock --> <p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}> <span id="quantityAvailable">{$product->quantity|intval}</span> <span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='Item'} verfügbar</span> <span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='Items'} verfügbar</span> </p> {/if} does anyone have an idea for me Link to comment Share on other sites More sharing options...
damon780 Posted Saturday at 09:51 AM Share Posted Saturday at 09:51 AM To display the quantity in a special category, you’ll likely need to customize the template file for that specific category. You can do this by editing the relevant .tpl file (usually product-list.tpl or category.tpl depending on your theme) and insert the following line where you want the quantity to appear: {$product.quantity} Make sure your product array includes the quantity data. You may also need to enable or adjust the displayProductQuantity in the product listing loop if it’s not already available. Don’t forget to clear the cache after making changes. Let me know if you need help locating the exact file in your theme. Link to comment Share on other sites More sharing options...
Thomas Will Posted Sunday at 10:19 AM Author Share Posted Sunday at 10:19 AM Thank you very much. The quantity is already displayed on the page (product.tpl) – see image/attachment. Unfortunately, the total quantity (above Quantity) of all items ("2 Artikel verfügbar") is displayed, not the quantity of the variant (as in the left column, "1 Artikel"). Link to comment Share on other sites More sharing options...
ps8modules Posted Sunday at 11:31 AM Share Posted Sunday at 11:31 AM (edited) Hi @Thomas Will If you want to display the available count for a selected combination or attribute, it's not that simple. What you see in the detail is not the same template. It can be done via js or a custom hook. Prestashop 1.6 find file: ./themes/default-bootstrap/js/product.js find function: updateDisplay() find query: $('#quantityAvailable').text(quantityAvailable); add your element: $('#quantityAvailableBeforeQuantitySelected').text(quantityAvailable); add to TPL: ./themes/default-bootstrap/product.tpl Edited Monday at 07:15 AM by ps8modules (see edit history) 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