- Posts: 299
- Thank you received: 2
Displaying available products as less or more than
12 years 8 months ago #138880
by LAMF
Displaying available products as less or more than was created by LAMF
-- url of the page with the problem -- :
www.gobbe.se
-- HikaShop version -- : 2.2.3 Business
-- Joomla version -- : 2.5.17
-- PHP version -- : 5.3.3
-- Browser(s) name and version -- : Chrome 31.0.1650.63 m
-- Error-message(debug-mod must be tuned on) -- : Not necessary
Hi, Short question:
How can I set up HikaShop to display every products amount like below 5 left and more than 5 left instead of exact numbers of how many is left in stock?
I have seen plenty of shops displaying amount of products like this but how do I set it up?
Thanks
Micke
-- HikaShop version -- : 2.2.3 Business
-- Joomla version -- : 2.5.17
-- PHP version -- : 5.3.3
-- Browser(s) name and version -- : Chrome 31.0.1650.63 m
-- Error-message(debug-mod must be tuned on) -- : Not necessary
Hi, Short question:
How can I set up HikaShop to display every products amount like below 5 left and more than 5 left instead of exact numbers of how many is left in stock?
I have seen plenty of shops displaying amount of products like this but how do I set it up?
Thanks
Micke
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 8 months ago #138905
by Mohamed Thelji
Replied by Mohamed Thelji on topic Displaying available products as less or more than
Hi,
The solution will probably be to edit the code of your "quantity" file of the "product" view of your front-end template through "Hikashop->Display->Views" , and change these lines :
Hope this will help you a little.
The solution will probably be to edit the code of your "quantity" file of the "product" view of your front-end template through "Hikashop->Display->Views" , and change these lines :
Code:
<div class="hikashop_product_stock">
<?php
echo '<span class="hikashop_product_stock_count">'.JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity).'<br/></span>';
if($config->get('button_style','normal')=='css'){
echo '<br />';
}
if($max<=0 || $max>$this->row->product_quantity) $max = $this->row->product_quantity;
if($this->params->get('add_to_cart',1)){
echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
$btnType = 'wish';
}
if(hikashop_level(1) && $this->params->get('add_to_wishlist') && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
echo '<div id="hikashop_add_wishlist">';
echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),$btnType,$this->params,$url,$wishlistAjax,'',$max,$min,'',false);
echo '</div>';
}
}
Please Log in or Create an account to join the conversation.
12 years 8 months ago #138988
by LAMF
Replied by LAMF on topic Displaying available products as less or more than
Hi,
Ok but as I'm no programmer I have no idea what to put in in order to display what I want,,
I want for example the quantity to display lie this (in english to make you understand)*:
More than 5 pcs left (if the number left of this product is 5 or more than five items)
or
Less than 5 pcs left (if the number of that product is less than 5).
Maybe you can give me a hint how to do it?
Ok but as I'm no programmer I have no idea what to put in in order to display what I want,,
I want for example the quantity to display lie this (in english to make you understand)*:
More than 5 pcs left (if the number left of this product is 5 or more than five items)
or
Less than 5 pcs left (if the number of that product is less than 5).
Maybe you can give me a hint how to do it?
Please Log in or Create an account to join the conversation.
12 years 8 months ago #139180
by Xavier
Replied by Xavier on topic Displaying available products as less or more than
Hi,
You have to replace:
By:
And add translations like:
You have to replace:
Code:
echo '<span class="hikashop_product_stock_count">'.JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity).'<br/></span>';
Code:
$qtyMessSet = 5;
if($this->row->product_quantity >= $qtyMessSet || $this->row->product_quantity == '-1')
echo ' <span class="hikashop_product_stock_count">'.JText::sprintf('MORE_THAN_X_ITEMS',$qtyMessSet).'<br/></span>';
else
echo ' <span class="hikashop_product_stock_count">'.JText::sprintf('LESS_THAN_X_ITEMS',$qtyMessSet).'<br/></span>';
And add translations like:
in the language file.MORE_THAN_X_ITEMS="More than %s pcs left"
LESS_THAN_X_ITEMS="Less than %s pcs left"
The following user(s) said Thank You: LAMF
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
12 years 8 months ago - 12 years 8 months ago #139186
by Mohamed Thelji
Replied by Mohamed Thelji on topic Displaying available products as less or more than
Hi,
The solution will probably be to change this line :
By :
Edit
Note that the solution that Xavier gave you will probably be better
.
The solution will probably be to change this line :
Code:
echo '<span class="hikashop_product_stock_count">'.JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity).'<br/></span>';
Code:
if($this->row->product_quantity < 5)
echo '<span class="hikashop_product_stock_count">Less than 5 pcs left<br/></span>';
else
echo '<span class="hikashop_product_stock_count">More than 5 pcs left<br/></span>';
Edit
Note that the solution that Xavier gave you will probably be better
Last edit: 12 years 8 months ago by Mohamed Thelji.
The following user(s) said Thank You: LAMF
Please Log in or Create an account to join the conversation.
12 years 8 months ago #139252
by LAMF
Replied by LAMF on topic Displaying available products as less or more than
Ok thanks a lot guys! I ued Xaviers methd as I like to add the translation in the language file. 
I have another question.
Is it possible to add quantity to multiple products at one go?
Can a cronjob do this and if so how can you do that?
Maybe it's possible to add all products in a CSV/Excel exported from HikaShop and edit the file and the product_quantity field for each of these products and then re-import it via the product import?
I have another question.
Is it possible to add quantity to multiple products at one go?
Can a cronjob do this and if so how can you do that?
Maybe it's possible to add all products in a CSV/Excel exported from HikaShop and edit the file and the product_quantity field for each of these products and then re-import it via the product import?
Please Log in or Create an account to join the conversation.
12 years 8 months ago - 12 years 8 months ago #139263
by LAMF
Replied by LAMF on topic Displaying available products as less or more than
Just want to let you know it works and it saves a lot of work too 
Jut export a product category with all products and edit the fields you want to change value in and save and upload and voila!
Jut export a product category with all products and edit the fields you want to change value in and save and upload and voila!
Last edit: 12 years 8 months ago by LAMF. Reason: more info added
Please Log in or Create an account to join the conversation.
3 years 1 month ago #354124
by nico.van.leeuwen
Replied by nico.van.leeuwen on topic Displaying available products as less or more than
Hi, just wanted to ask if this solution is still OK with the new versions of HikaShop?
It's been more then 9 year
It's been more then 9 year
Please Log in or Create an account to join the conversation.
3 years 1 month ago #354128
by Philip
Replied by Philip on topic Displaying available products as less or more than
Bonjour,
Oui, ce code devrait marcher tel quel, le seul point potentiel à considérer serait peut être les classes qui ont potentiellement évolués.
Mais en partant de l'existant de votre HikaShop pour reprendre le principe de la modification ne devrait poser aucun souci.
Cordialement
Oui, ce code devrait marcher tel quel, le seul point potentiel à considérer serait peut être les classes qui ont potentiellement évolués.
Mais en partant de l'existant de votre HikaShop pour reprendre le principe de la modification ne devrait poser aucun souci.
Cordialement
Please Log in or Create an account to join the conversation.
Time to create page: 0.223 seconds