wfreebird Posted February 26, 2011 Share Posted February 26, 2011 Hi guys,I am working on a shop for selling fabrics where customers need to be able to order a quantity in a decimal value.So the customer needs to be able to order for example 1,5 meters of a fabric.Can anyone tell me where i can find the code to do so?Change the database is no problem and i am good with php and html/css but i am new with prestashop and smarty.I hope anyone can help me.Thank you in advance.Greetings Werner Link to comment Share on other sites More sharing options...
otzy Posted February 26, 2011 Share Posted February 26, 2011 what if to use centimetres? Customers will order 150cm of fabric. Link to comment Share on other sites More sharing options...
wfreebird Posted February 26, 2011 Author Share Posted February 26, 2011 Dear Otzy,Unfortunately is changing it in to cm not an option because the prices in the shop have to be in metres.But thank you for your suggestion.Regards Werner Link to comment Share on other sites More sharing options...
Burhan BVK Posted February 26, 2011 Share Posted February 26, 2011 Why don't you enter the prices in cm? You can just modify the tpl files to display the price in metres. You will have to modify product-list.tpl and product.tpl and anywhere else you display products. Link to comment Share on other sites More sharing options...
wfreebird Posted March 5, 2011 Author Share Posted March 5, 2011 Hi Whitelighter,Thank you for your reply.This weak i tried your solution but i came upon an other problem. The shop does not sell only fabrics but also other stuff like studs and zippers witch need to be sell-ed in single pieces.Also all the online shops that sell fabrics have the functionality to order a decimal value.I hope there is somebody that can help me because i really need this.Greetings Werner Link to comment Share on other sites More sharing options...
otzy Posted March 5, 2011 Share Posted March 5, 2011 One more ideaadd field `measured` int default 0 to table ps_product,set it to 1 for fabrics and 0 for other goods,in tpl files check this field (it will be automatically the property of object $product): {if $product.measured>0} {assign var='productPrice' value=$product.price*100} {else} {assign var='productPrice' value=$product.price} {/if} then change the price output from $product.price to $productPrice, for instance: {displayWtPrice p=$productPrice} Link to comment Share on other sites More sharing options...
Fangor Posted March 5, 2011 Share Posted March 5, 2011 Hi guys! I found the solution. I realized it on my website. It is very very simple.First of all change INT to Decimal in database ps_product - quantity AND change intval to floatval near quantity or qty in the following files: 1. /order.php2. /cart.php3.classes/cart.php4.classes/product.php5.classes/order.php6.themes/prestashop/product.tpl 1 Link to comment Share on other sites More sharing options...
wfreebird Posted March 5, 2011 Author Share Posted March 5, 2011 Hi Fangor,Thank you very much.I will try this one and let you know if it works.With kind regards,Werner Link to comment Share on other sites More sharing options...
siomosp Posted April 6, 2011 Share Posted April 6, 2011 Hi Fangor,it seems that your solution is about 1.3 only.Have you any suggestions about 1.4Thank you,regards,Panagiotis Link to comment Share on other sites More sharing options...
coloboque Posted May 27, 2011 Share Posted May 27, 2011 I have same problem...but I use 1.4.0. Anybody who solved the problem please share thу solution :-) Link to comment Share on other sites More sharing options...
wfreebird Posted May 27, 2011 Author Share Posted May 27, 2011 Helo coloboque,I have solved the problem in 1.4. I will give you the solution tomorrow because it is a lang story and i don't have the time now.I wanted to post the solution much ealier but i didn't have the time for it. So tomorrow i post it here.With kind regards Werner Link to comment Share on other sites More sharing options...
coloboque Posted May 27, 2011 Share Posted May 27, 2011 Oh thank you!! i'm so happy) Link to comment Share on other sites More sharing options...
siomosp Posted May 27, 2011 Share Posted May 27, 2011 Very nice,thank you wfreebird! Link to comment Share on other sites More sharing options...
wfreebird Posted May 30, 2011 Author Share Posted May 30, 2011 Hi,So here is finally my answer, sorry promised Saturday but there was something between.It's a lot of work in 1.4.First I changed the database. I searched in all the tables with the fields quantity and changed the type to decimal(17,2).The tables are:- ps- ps- ps_discount- ps_orders (total_products and total_products_wt)- ps_order_detail (all the fields with quantity in the name)- ps_order_return_detail- ps_order_slip_detail- ps_pack- ps_product- ps_product_attribute- ps_product_sale- ps_specific_price- ps_stock_mvtAfter this you go to your prestashop folderNow you have to search for all the files where the quantity value is set.Open the files one by one and search for "intval($row['cart_quantity'])" for example. Every line with the word "intval" before the word "quantity" or "qty".Change the word "intval" to "floatval". Then repeat all but now you search for the word "int" an change this to "float".You need to do this for the files:- prestashop/classes/Attribute.php- prestashop/classes/Cart.php- prestashop/classes/Customization.php- prestashop/classes/Discount.php- prestashop/classes/Order.php- prestashop/classes/OrderDetail.php- prestashop/classes/OrderHistory.php- prestashop/classes/OrderReturn.php- prestashop/classes/Product.php- prestashop/classes/ProductSale.php- prestashop/classes/QuantityDiscount.php- prestashop/classes/StockMvt.php- prestashop/controllers/CartController.php- prestashop/controllers/OrderController.php- prestashop/order.php- prestashop/cart.php- prestashop/themes/prestashop/product.tpl (or if you have a other theme prestashop/themes/themename/product.tplPlease check yourself if the above files are all the files you need to change. Just open the other files as well and search.I did it with dreamweaver and used "find and replace" type by Find "int" and by Replace "float".I hope this was useful.It's a lot of work but in the end it works for the users of your shop.Good luckWith kind regards,Werner 1 Link to comment Share on other sites More sharing options...
Stanik Posted May 31, 2011 Share Posted May 31, 2011 Hi. This is what I was looking for. Does it really works with the newest version of Prestashop?Does it resolves the difference between a dot and a comma? Link to comment Share on other sites More sharing options...
wfreebird Posted May 31, 2011 Author Share Posted May 31, 2011 Dear Stanik,If you do it right it works with the new version of prestashop.I did this with prestashop 1.4.0.17.You can see the result at: www.lacouture.nlIt is a dutch site so all text is in dutch.Unfurtunetly you can only use a dot and not a comma.Hope this helps.With kind regards,Werner Link to comment Share on other sites More sharing options...
Jiri Kral Posted July 16, 2011 Share Posted July 16, 2011 First, my thanks belongs to wfreebird for his instructions about edit Prestashop database and source codes - it very helped me.I solved a problem with a dot and comma. You can add few lines to source code for an automatic changing comma for a dot.1. edit javascript in path: \themes\prestashop\js\cart-summary.jsa) In function "function updateQty(val)" make some changes (there are only in begin of function): function updateQty(val) { val = changeToDot(val); var id = $(this.el).attr('name'); var exp = new RegExp("^([0-9]*[.]?)?[0-9]+$"); $('input[name='+ id +']').val(val); ////...next code was not changed...//// if (exp.test(val) == true) { var hidden = $('input[name='+ id +'_hidden]').val(); var input = $('input[name='+ id +']').val(); var QtyToUp = parseFloat(input) - parseFloat(hidden); if (parseFloat(QtyToUp) > 0) upQuantity(id.replace('quantity_', ''),QtyToUp); else if(parseFloat(QtyToUp) < 0) downQuantity(id.replace('quantity_', ''),QtyToUp); } else $('input[name='+ id +']').val($('input[name='+ id +'_hidden]').val()); } Add this function before function "function updateQty(val)": function changeToDot(myFloatNumber){ for (var i=0;i var currentChar = myFloatNumber.charAt(i); if (currentChar == ","){ myFloatNumber = myFloatNumber.replace(/,/, '.'); break; } } return myFloatNumber; } 2. edit php file in path: \controllers\CartController.phpfind and comment a row with: $qty = (float)(abs(Tools::getValue('qty', 1))); and place instead this row: $qty = (float)(abs(str_replace(",",".",Tools::getValue('qty', 1)))); It´s all. I hope this helps you. Link to comment Share on other sites More sharing options...
sousmart Posted May 5, 2012 Share Posted May 5, 2012 Hi everybody, Can anyone inform if this solution runs with recent versions like 1.45 or 1.47??? Regards, Carlos Link to comment Share on other sites More sharing options...
noayak Posted May 9, 2012 Share Posted May 9, 2012 I'm trying to do the same in the last version of prestashop and there is no way that works. I am configuring a fabric store, and the minimum quantity I need is 0,20 cm. I change all the .php archives and database but still not work. Any advise? Link to comment Share on other sites More sharing options...
sousmart Posted May 9, 2012 Share Posted May 9, 2012 That`s the same I need, a store that sells fabrics and other products that must be sold in units. It seems that this solution doesn`t work with 1.45 and 1.47. We will try harder and if if we became to a solution I`ll let you know. I believe that the only person that will solve this issue will be someone that knows very well Prestasop`s core in order to make the needed changes. Any help???? Thanks!!!! Link to comment Share on other sites More sharing options...
jalle007 Posted May 10, 2012 Share Posted May 10, 2012 Guys this is a basic and a must for one webshop CMS to have quantity in decimals hope someone from presta will work on it 1 Link to comment Share on other sites More sharing options...
wfreebird Posted June 16, 2012 Author Share Posted June 16, 2012 Hi guys, Can we we ask a prestashop developer to make a module or to ad it in the next upgrade together? I have coded a previous version to have the quantities in a decimal value but my problem now is that i can't upload to the new version and i want to update the outdated design of the site. So if anyone know how to contact a developer i will be happy to contact him or her and ask. With kind regards, Werner Vrijvogel Link to comment Share on other sites More sharing options...
psandmore Posted June 20, 2012 Share Posted June 20, 2012 See the http://psandmore.com This module allows you to do exactly what you want. Have price in meters and order 12,3m. And it has much much more. Link to comment Share on other sites More sharing options...
Celil Posted March 12, 2013 Share Posted March 12, 2013 How it works for Ps 1.5.2 ? Link to comment Share on other sites More sharing options...
psandmore Posted March 12, 2013 Share Posted March 12, 2013 It works for many versions including 1.5.2 and 1.5.3. See our site for all versions. Link to comment Share on other sites More sharing options...
Celil Posted March 12, 2013 Share Posted March 12, 2013 I dont want to use module. I wanna fix with changing codes. 1 Link to comment Share on other sites More sharing options...
ricardoferreira.net Posted March 20, 2013 Share Posted March 20, 2013 @Ceil you do not need a module for this, the solution @wfreebird gave, worked quite well for me in v1.5.3, thank you all. Link to comment Share on other sites More sharing options...
AndreasAnemyr Posted March 28, 2013 Share Posted March 28, 2013 i've done all the canges (wfreebird gave) but... When i Add product... let´s say with value 10.25 from product.php, with a minium_quantity of 10.25 (the same valu) It seem likt that value is rounde (ceil...) to 10. So it´s not possible to add 10.25. But 11.... Maybe i forgot some changes. Plz Help.... Link to comment Share on other sites More sharing options...
Inform-All Posted May 14, 2013 Share Posted May 14, 2013 I've tried Wfreebird's solution, dident work out for me on 1.5.4.1. So currently working on a fix for newer versions. Link to comment Share on other sites More sharing options...
Inform-All Posted May 15, 2013 Share Posted May 15, 2013 (edited) So the following attachment has my notes how I fixed a decimal product quantity order. It says step by step what to do, It worked for me on Prestashop 1.5.4.1. decimal_input_notes.txt It might be done easier but these are my notes so why not share them Goodluck Edited May 15, 2013 by Bolinga (see edit history) Link to comment Share on other sites More sharing options...
diosimmy Posted May 19, 2013 Share Posted May 19, 2013 So the following attachment has my notes how I fixed a decimal product quantity order. It says step by step what to do, It worked for me on Prestashop 1.5.4.1. decimal_input_notes.txt It might be done easier but these are my notes so why not share them Goodluck Hi, I followed all the steps but there are some things I have not made correctly: - Show units with decimals in the confirmation email that is sent to the client (order_conf) - Subtract the stock in decimals Did you get it to work? PD: I'm working with 1.5.3.1 1 Link to comment Share on other sites More sharing options...
Inform-All Posted May 19, 2013 Share Posted May 19, 2013 Hi, I followed all the steps but there are some things I have not made correctly: - Show units with decimals in the confirmation email that is sent to the client (order_conf) - Subtract the stock in decimals Did you get it to work? PD: I'm working with 1.5.3.1 Yeah, I've found out my notes arent complete yet. Some error's still in here. I am still working on it. Hope to post an update tomorrow. Sorry for not posting a complete solution. 1 Link to comment Share on other sites More sharing options...
tabutnas Posted May 20, 2013 Share Posted May 20, 2013 (edited) Hello, thanks for this solution , I have the same errors that diosimmy and cant put 0.55 or 0.etc on minium quantity, anyway im searching what we need to change for works correctly Have an other fail: /module/cashondelivery/validation -> Cart cannot be loaded or an order has already been placed using this cart :/ maybe i need change validations quantity files? Thanks in advance Edited May 20, 2013 by tabutnas (see edit history) Link to comment Share on other sites More sharing options...
Inform-All Posted May 22, 2013 Share Posted May 22, 2013 Soo my own solution worked perfect for me locally. But no I've tried it on a host with a fresh prestashop install. And now my total price doesent caculate add a decimal quantity. I've been searching for a fix for 2 days now.. Cant seem to get it working. I can fix the pdf + email bug but, not his one. So any help is welcome. In this screenshot you see the wrong calculation. I keep thinking it's a database that need's some adaption.... But cant find it! Thank you in advance. 1 Link to comment Share on other sites More sharing options...
tabutnas Posted May 24, 2013 Share Posted May 24, 2013 (edited) Yes, for me is the same.. but crash on /module/cashondelivery/validation have 500 internal server error at do this change. Edit: I managed to fix this bug, my problems now are; Minimum quantity adapt to decimals Some feilds (backend-front-end) don't show decimals Edited May 24, 2013 by tabutnas (see edit history) Link to comment Share on other sites More sharing options...
tabutnas Posted May 25, 2013 Share Posted May 25, 2013 well now works 100% fine to me, now i understand china philosophy XD well this is my contribution; i change some files... basically just search and change to float or modify functions 2 show correct quantities as decimal. sql: equal than bolinga but add this changes ps_product -> out_of_stock ps_product_attribute -> minimal_quantity just search and change tables what have "out_of_stock or minimal_quantity" and change to decimal 17,2 and "default minimum" Some variables u need 2 search and change: quantity minimal_quantity minimum_quantity $qty $nbTotalProducts out_of_stock that's all, thank bolinga 2 Link to comment Share on other sites More sharing options...
Inform-All Posted June 6, 2013 Share Posted June 6, 2013 (edited) The ordering part works, customers can order a decimal quantity of products and the total price works fine! But in my backoffice & the invoice doesen't give a decimal quantity, although the price is correct. Help is needed.. Edited June 6, 2013 by Bolinga (see edit history) Link to comment Share on other sites More sharing options...
julcons Posted June 26, 2013 Share Posted June 26, 2013 Bolinga, did you finally solve your problem? Tabutnas, how exactly did you change the files? I don't understand exactly what "modify functions" is, or how do you make the search. I don't have much idea of web programming, and I have tried to change my prestashop to decimals but it keeps displaying a wrong total price. Do you have problems when adding new products to the catalog (error message: "Minimum quantity incorrect", I have to change it each time I edit a product, from 1.00 to 1). Thank you! Link to comment Share on other sites More sharing options...
Inform-All Posted July 2, 2013 Share Posted July 2, 2013 Bolinga, did you finally solve your problem? Tabutnas, how exactly did you change the files? I don't understand exactly what "modify functions" is, or how do you make the search. I don't have much idea of web programming, and I have tried to change my prestashop to decimals but it keeps displaying a wrong total price. Do you have problems when adding new products to the catalog (error message: "Minimum quantity incorrect", I have to change it each time I edit a product, from 1.00 to 1). Thank you! My problem is fixed now had to change invoice and pdf controllers for admin and front. If your total price is not calculated correctly, you missed a int at the controllers. Also make shure to change all the controllers for in the controllers/admin folder, since this is the place where you input the amount of products. Best thing might be open up all the controllers and search qty and change the int's to float and after that do the same for quant. I'm sorry that I stopped making notes of all the changes that I made.. Goodluck though Link to comment Share on other sites More sharing options...
Inform-All Posted August 9, 2013 Share Posted August 9, 2013 So I recently found out that if customers want to order <1 total quantity of products the checkout cart remains empty. I started a new topic for this, please have a look at: http://www.prestashop.com/forums/topic/266743-minimal-total-product-quantity-in-cart/ Link to comment Share on other sites More sharing options...
eporedieis Posted August 23, 2013 Share Posted August 23, 2013 I've changed all these things...but in the cart summary the total isn't correct In the suggested changes I don't understand these: -OwnName_cart -quantity -quantity_per_user -OwnName_cart_rule_product_group -quantity -OwnName_customization -quantity -OwnName_order_detail -quantity -product_quantity_in_stock -OwnName_order_return_detail -product_quantity -OwnName_pack -quantity -OwnName_product -minimal_quantity -quantity -OwnName_product_shop -minimal_quantity -OwnName_stock_avaible -quantity -OwnName_product_sale -quantity -OwnName_cart_product -quantity In the db there aren't table called "OwnName" (or with the ps site's name) Thank you!! Link to comment Share on other sites More sharing options...
Inform-All Posted October 9, 2013 Share Posted October 9, 2013 I've changed all these things...but in the cart summary the total isn't correct In the suggested changes I don't understand these: -OwnName_cart -quantity -quantity_per_user -OwnName_cart_rule_product_group -quantity -OwnName_customization -quantity -OwnName_order_detail -quantity -product_quantity_in_stock -OwnName_order_return_detail -product_quantity -OwnName_pack -quantity -OwnName_product -minimal_quantity -quantity -OwnName_product_shop -minimal_quantity -OwnName_stock_avaible -quantity -OwnName_product_sale -quantity -OwnName_cart_product -quantity In the db there aren't table called "OwnName" (or with the ps site's name) Thank you!! At the installation of Prestashop you can chose a unique name for these tables. People refer them as "OwnName" since it's different for every installation. Link to comment Share on other sites More sharing options...
Recommended Posts