Prestashop - out of stock list - prestashop

I have a prestashop shop, when I sell t-shirts. Every t-shirt have several sizes (combinations), i.e. M, L, XL etc.
In blocklayered filter there are two filters: "Available" and "Out of stock" products, but they behave weirdly: "out of stock" filter shows products, that have 0 quantity in one/several sizes.
How can I modify this to show on "out of stock" list only products, that have no items available in ALL available sizes.
What I mean is when a t-shirt have 3 items in size M, but 0 in size L, I do not want it to show on "Out of stock" list.
The second thing is - how can I hide products, that are truly "out of stock" (no items in all combinations) from default category list page? What I want to achieve is that on category pages we have "Archive" tab, which should show products that used to be available in shop, but they are not anymore.
I use PS 1.6.1.9

Open www/themes/yourtheme/product-list (Dont forget to backup)
Search for
{assign var='nbLi' value=$products|#count}
Right below add
{foreach from=$products item=product name=products}
{if ($product.quantity <= 0)}
{$nbLi=$nbLi-1}
{/if}
{/foreach}
Search for
{foreach from=$products item=product name=products}
Right below add
{if ($product.quantity > 0)}
Search for
{/foreach}
Right above add
{/if}
Replace all instances of
$smarty.foreach.products.total
and
$smarty.foreach.products.iteration
with
$nbLi
This question was anwsered by MEG Venture in the prestashop forum.
https://www.prestashop.com/forums/topic/537182-disable-out-of-stock-product-from-listing-only/

There is a function in StockAvailable.php core class of PrestaShop that can be used to find the actual quantity of any option of a product.
StockAvailable::getQuantityAvailableByProduct()
You can simply run through a loop for every option of a product and find the quantity for all options and mark the product out of stock only if any option is not available.

Related

Show Price with and without taxes into Product Page

I have a problem into a Prestashop 1.7 solution.
Into a Product page, i want to show 2 prices (include and exclude VAT)
<span itemprop="price" content="{$product.price_amount}">{$product.price}</span>
This example show price with VAT. I don't find how show price without VAT too.
Thanks
You can use {debug} in your .tpl and you will see all available variables that you can use.
Our you can use {$product|#var_dump} which will show you what sub-variables the $product variable contains
You can use {$product.price_tax_exc} variable to display price with tax excluded.
There is the displayPrice() method that you can use to format the price displayed.
But since version 1.7.6 you should use the formatPrice() method, since displayPrice is deprecated.
You can use it like this:
{block name='product_without_taxes'}
{if $priceDisplay != 1}
<p class="product-without-taxes">{l s='%price% tax excl.' d='Shop.Theme.Catalog' sprintf=['%price%' => Context::getContext()->currentLocale->formatPrice($product.price_tax_exc, $currency.iso_code)]}</p>
{/if}
{/block}
This way you'll have the price formatted with the current currency and the tax excl. text. For example in French it will display 10,00 € HT, 'HT' meaning 'tax excluded'

Add countries in form field Prestashop 1.7.x

I am trying to display a dropdown with all the countries that prestashop has in his database.
When a customer is adding a new address, a field ask for the country, but displays only United States.
How can I make to display all the countries?
Because when I edit the customer I can see all the countries.
What I have tried:
In the location: /public_html/Project/themes/myTemplate/templates/_partials/form-fields.tpl
I realized there is a Foreach to fill the dropdown, but load United States.
{elseif $field.type === 'countrySelect'}
{block name='form_field_item_country'}
<select
class="custom-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{$field.label}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}
I can see in console, actually, loads one value only.
Could anybody has the same error?
How can you help me to fix it?
Go in International > Locations , check Countries tab and make sure the other countries are active (they aren't in a standard US / UK Prestashop installation)

Can I add the custom fields to the product listing page in BigCommerce

Each product has the custom fields options. Can I output those custom fields on each product item in the product list page? If so, how? I have tried adding the ProductOtherDetails and the %%SNIPPET_ProductCustomFieldItem%% in the CategoryProductsItem.html, but got no output at all of any of the items I have tried. Any suggestions or pointers on how and if this is possible?
As of September 2015, you can now access %%GLOBAL_ProductCustomFields%% on any template file that renders a particular panel's individual items. For example:
-Snippets/CategoryProductsItem.html for category list pages
-Snippets/HomeFeaturedProductsItem.html for the featured products panel
I recommend adding the custom field name as a class to each field for easy hiding, and accessing of the value in case the custom fields ever change you won't be accessing them via :nth-child CSS which would break. You can do so by modify Snippets/ProductCustomFieldItem.html to add the custom field name to the CSS class or ID like this:
<div class="DetailRow %%GLOBAL_CustomFieldName%%">
<div class="Label">%%GLOBAL_CustomFieldName%%:</div>
<div class="Value">
%%GLOBAL_CustomFieldValue%%
</div>
</div>​
Doing so, will output like this in each item in the category list.
Above, I am using the custom fields to send through shipping time, as well as "Starting At" to prepend to the list page price if the item is a parent which has children of higher prices. In my opinion, these features greatly increase the user experience.
For Faceted Search (handlebars.js)
I recommend adding this to Panels/FacetedSearchProductGrid.html:
{{#each product.custom_fields}}
{{ id }} : {{ name }} : {{ value }}
{{/each}}
Those filters will be limited to the Product pages specifically. The only way around it is to hash together a solution using jQuery to go and fetch items in question from the product page. A pain, but do-able with unnecessary effort.

Prestashop custom link depending on product manufacturer

I want to make a button with a modal effect on product page with ex. size table. I want to show only this size table depending on acutal product manufacturer.
Ex. Nike shoes
On product page (product.tpl file) button named like "size table". After use the button the modal popup box will show only the Nike shoe size table.
Maybe something like this should work?
{if $manufacutrer_name !='Nike'}
Size table
{/if}
Use the manufacturer id, you can do:
{if $product->id_manufacturer == 23}
Size table
{/if}

prestashop free shipping issue

I just upgraded firstly manually but later on by 1-click Upgradev1.0.13 to 1.5.4 version. I got a big problem on shopping cart with the shipping fees.
The cart located on homepage top left was solve not to show "FREE SHIPPING" from the previous code in this forum.
But once I checked on the shopping cart inside after I select and press "Update Carrier List" button and
press "Update Cart" button, the shipping fees is not updated but show as "FREE SHIPPING".
Could anyone suggest me solution about this? Thank you very much. I very much appreciate it.
My demo website is http://store.relishthai.com/.
You can try to add item by selecting the "TEA" tag and add one item to the cart and see the "FREE SHIPPING" problem.
I have had a very similar issue. The problem is that there is a Javascript file that updates the value to "FREE SHIPPING" if the value(shipping price) is equal to 0.00. I am using a different version, so I can't exactly point you to the file, but you can definitely solve this in three minutes. (Check order-opc.js in your theme/js folder)
View source of the web page and see what .js files are included. Search "FREE SHIPPING" in Javascript files (such as cart.js) and see which one is the culprit. Then go on FTP and change it to 0.00. I prefer "Free!" by the way ;)
EDIT: It seems like I misread your Q.
I tried pressing "Update carrier list" and then "Update cart", but I do not see the shipping fees as "Free shipping." Instead, I see 8 dollars.
Thanks again. Previously before your answer the $0.00 appeared in the top left cart on the page but later on after your comments I double checked things and deleted unused zone (no fees in there). And I tried to put the real shipping fees for all weight ranges. Now, the old problems has been solved but the shipping fees with weight ranges (in small ranges) still exits. I'll try to figure things out.
Many Thanks!!
Open the file /themes/xxx/modules/blockcart/blockcart.tpl
and remove this block of code (or comment):
<div class="layer_cart_row">
<strong class="dark">
{l s='Total shipping' mod='blockcart'} {if $display_tax_label}{if $priceDisplay == 1}{l s='(tax excl.)' mod='blockcart'}{else}{l s='(tax incl.)' mod='blockcart'}{/if}{/if}
</strong>
<span class="ajax_cart_shipping_cost">
{if $shipping_cost_float == 0}
{l s='Free shipping!' mod='blockcart'}
{else}
{$shipping_cost}
{/if}
</span>
</div>