otzy Posted November 4, 2010 Share Posted November 4, 2010 Is it possible to save customized fields at the same time when Add to cart was clicked? 2 Link to comment Share on other sites More sharing options...
Patric Posted November 5, 2010 Share Posted November 5, 2010 Topic moved. Link to comment Share on other sites More sharing options...
tomerg3 Posted November 5, 2010 Share Posted November 5, 2010 Everything is possible I have not looked into what it would take, but it's probably a few hours of work.I offer a module on my shop which lets you use regular attributes at text box, file upload or text area, that also allows you to assign a price / weight impact to them.You can see a demo and more info at http://www.prestashop.com/forums/viewthread/47363/ Link to comment Share on other sites More sharing options...
otzy Posted November 7, 2010 Author Share Posted November 7, 2010 Tomer, your module is great but unfortunately not exactly that I need.I did it Some more than a few hours and few changes in /modules/blockcart/ajax-cart.js and /cart.php Link to comment Share on other sites More sharing options...
rocky Posted November 8, 2010 Share Posted November 8, 2010 Can you post exactly how you did it? It is a frequent request. Link to comment Share on other sites More sharing options...
otzy Posted November 8, 2010 Author Share Posted November 8, 2010 (edited) 1. /cart.php add function: function textRecord(Product $product, Cart $cart) { global $errors; if (!$fieldIds = $product->getCustomizationFieldIds()) return false; $authorizedTextFields = array(); foreach ($fieldIds AS $fieldId) if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_) $authorizedTextFields[intval($fieldId['id_customization_field'])] = 'textField'.intval($fieldId['id_customization_field']); $indexes = array_flip($authorizedTextFields); foreach (array_merge($_POST, $_GET) AS $fieldName => $value) if (in_array($fieldName, $authorizedTextFields) AND !empty($value)) { if (!Validate::isMessage($value)) $errors[] = Tools::displayError('Invalid message'); else $cart->addTextFieldToProduct(intval($product->id), $indexes[$fieldName], $value); } elseif (in_array($fieldName, $authorizedTextFields) AND empty($value)) $cart->deleteTextFieldFromProduct(intval($product->id), $indexes[$fieldName]); } it is taken from product.php and $_GET parameters are added to foreach cycle. 2. /cart.php insert lines: /* save text customization fields */ if (Tools::isSubmit('submitCustomizedDatas')) { textRecord($producToAdd, $cart); } after these lines: else { $producToAdd = new Product(intval($idProduct), false, intval($cookie->id_lang)); if ((!$producToAdd->id OR !$producToAdd->active) AND !$delete) $errors[] = Tools::displayError('product is no longer available'); else { 3. /modules/blockcart/ajax-cart.js in the add function insert lines before $.ajax: //add customized text fields var customizedData = "", re=/^textField\d+/; if ((CUSTOMIZE_TEXTFIELD == 1) && (document.getElementById("customizationForm") != null)){ var customizedForm=document.getElementById("customizationForm"); for (var i=0; i if (re.test(customizedForm.elements[i].name)){ customizedData += "&" + customizedForm.elements[i].name + "=" + customizedForm.elements[i].value; } } customizedData += "&submitCustomizedDatas=1"; } and change lines in $.ajax call: $.ajax({ type: 'POST', url: baseDir + 'cart.php?' + 'add&ajax=true&qty;=' + ( (quantity && quantity != null) ? quantity : '1') + '&id;_product=' + idProduct + '&token;=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa;=' + parseInt(idCombination): '') + customizedData , async: true, cache: false, dataType : "json", // data: , 4. It works only with text fields. You may also remove Save button in customizationForm. Tested in Firefox 3.5.15, IE 7, Opera 10.63 2012-11-12 - attached cart.zip which contains ajax-cart.js and cart.php ajax-cart.js cart.php cart.zip Edited November 12, 2012 by otzy (see edit history) 5 Link to comment Share on other sites More sharing options...
stefanosm Posted December 22, 2010 Share Posted December 22, 2010 it is working fine also with a textarea, except that the lines in the textarea are not reserved. any ideas how to solve this?i have dowloaded the above files + used the tricks from here: http://www.prestashop.com/forums/viewthread/20928/installing_prestashop/customization_field_enlarge_box_width/ to insert the textarea Link to comment Share on other sites More sharing options...
otzy Posted December 23, 2010 Author Share Posted December 23, 2010 it is working fine also with a textarea, except that the lines in the textarea are not reserved. any ideas how to solve this? what do you mean "the lines in the textarea are not reserved"?You get on the server only the first line of your textarea?try to use escape function in ajax-cart.js //add customized text fields var customizedData = "", re=/^textField\d+/; if ((CUSTOMIZE_TEXTFIELD == 1) && (document.getElementById("customizationForm") != null)){ var customizedForm=document.getElementById("customizationForm"); for (var i=0; i if (re.test(customizedForm.elements[i].name)){ customizedData += "&" + customizedForm.elements[i].name + "=" + escape(customizedForm.elements[i].value); } } customizedData += "&submitCustomizedDatas=1"; } Link to comment Share on other sites More sharing options...
stefanosm Posted December 23, 2010 Share Posted December 23, 2010 i meant that if i write in the textarea:test text row1test row2row3it will result (both on the cart and in the db) => "test text row1test row2row3"if i use your code from the previous post, it gives me a technical error. Link to comment Share on other sites More sharing options...
otzy Posted December 23, 2010 Author Share Posted December 23, 2010 New recipeajax-cart.js: //add customized text fields var customizedData = "", re=/^textField\d+/; if ((CUSTOMIZE_TEXTFIELD == 1) && (document.getElementById("customizationForm") != null)){ var customizedForm=document.getElementById("customizationForm"); for (var i=0; i if (re.test(customizedForm.elements[i].name)){ customizedData += "&" + customizedForm.elements[i].name + "=" + customizedForm.elements[i].value.replace("\n"," "); } } customizedData += "&submitCustomizedDatas=1"; } after this change there will be normal rows in database fields, but you will still have an error after "add to cart".To correct this replace CRLF with value with some characters suitable for your theme (br or \n or space)example for spaceclasses/Product.php: static public function getAllCustomizedDatas($id_cart, $id_lang = null) { global $cookie; if (!$id_lang AND $cookie->id_lang) $id_lang = $cookie->id_lang; else { $cart = new Cart(intval($id_cart)); $id_lang = intval($cart->id_lang); } if (!$result = Db::getInstance()->ExecuteS(' SELECT cd.`id_customization`, c.`id_product`, cfl.`id_customization_field`, c.`id_product_attribute`, cd.`type`, cd.`index`, replace(replace(cd.`value`,char(13)," "),char(10),"") as value, cfl.`name` FROM `'._DB_PREFIX_.'customized_data` cd NATURAL JOIN `'._DB_PREFIX_.'customization` c LEFT JOIN `'._DB_PREFIX_.'customization_field_lang` cfl ON (cfl.id_customization_field = cd.`index` AND id_lang = '.intval($id_lang).') WHERE c.`id_cart` = '.intval($id_cart).' ORDER BY `id_product`, `id_product_attribute`, `type`, `index`')) return false; $customizedDatas = array(); foreach ($result AS $row) $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['datas'][intval($row['type'])][] = $row; if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.intval($id_cart))) return false; foreach ($result AS $row) { $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity'] = intval($row['quantity']); $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity_refunded'] = intval($row['quantity_refunded']); $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity_returned'] = intval($row['quantity_returned']); } return $customizedDatas; } 1 Link to comment Share on other sites More sharing options...
cinziadm Posted December 23, 2010 Share Posted December 23, 2010 Hi,in order to calculate area and perimeter, i need to save customized field BEFORE adding product to the cart, but i'd like to remove save button.. How can i resolve my problem???Pleaseeeee help meeeeee Link to comment Share on other sites More sharing options...
otzy Posted December 24, 2010 Author Share Posted December 24, 2010 Possibly you should write some javascript that will make calculation before posting data to the server Link to comment Share on other sites More sharing options...
cinziadm Posted December 28, 2010 Share Posted December 28, 2010 Thank you Otzy,i will prove this solution Link to comment Share on other sites More sharing options...
cinziadm Posted December 28, 2010 Share Posted December 28, 2010 Otzy, i've proved your solution in order to remove save button, but i've had some problem with ajax cart: it's showed without total price.. can you tell me why?? Link to comment Share on other sites More sharing options...
juanmaminage Posted December 28, 2010 Share Posted December 28, 2010 It doesn't work for me in presta 1.3.1 and IE 8, nor FF 3.6.13 nor Opera 10.61.Behaviour:1.- Load the product2.- Select that I want a printed card (attribute Printed and Unprinted for a card)3.- In the attributes section, I write the text and the color of letters (2 text fields)4.- I dont click the Save button, I just click Add to cart5.- It redirects to Cart.php without having introduced the attributesIf I go back, the textfields are filled in, they behave as if they had been saved with the button, but they are not addedto the cart.How could I solve it? Has anybody had the same result with this change?Thanks in advance. Link to comment Share on other sites More sharing options...
otzy Posted December 28, 2010 Author Share Posted December 28, 2010 Otzy, i've proved your solution in order to remove save button, but i've had some problem with ajax cart: it's showed without total price.. can you tell me why?? It is unlikely that this solution caused the total price error. Could you send firebug console output (request and response parameters and bodies) occured after click to Add to cart button. Link to comment Share on other sites More sharing options...
otzy Posted December 28, 2010 Author Share Posted December 28, 2010 It doesn't work for me in presta 1.3.1 and IE 8, nor FF 3.6.13 nor Opera 10.61.Behaviour:1.- Load the product2.- Select that I want a printed card (attribute Printed and Unprinted for a card)3.- In the attributes section, I write the text and the color of letters (2 text fields)4.- I dont click the Save button, I just click Add to cart5.- It redirects to Cart.php without having introduced the attributesIf I go back, the textfields are filled in, they behave as if they had been saved with the button, but they are not addedto the cart.How could I solve it? Has anybody had the same result with this change?Thanks in advance. I had no dealings with PS 1.3.1 but it looks like you did not enable ajax cart.Back Office -> Modules -> Blocks -> Cart block -> ConfigureI have changed only ajax call in my solution so it will not work with ajax disabled Link to comment Share on other sites More sharing options...
stefanosm Posted December 29, 2010 Share Posted December 29, 2010 example for spaceclasses/Product.php: otzy, would you please give me the example with the "br"? Sorry, but i'm not a programmer...+ unfortunately your example is working only for the first row. the other ones are written still continously.thanks! Link to comment Share on other sites More sharing options...
otzy Posted December 29, 2010 Author Share Posted December 29, 2010 example for spaceclasses/Product.php: otzy, would you please give me the example with the "br"? Sorry, but i'm not a programmer...+ unfortunately your example is working only for the first row. the other ones are written still continously.thanks! Example for br, but I'm not sure if it will work. It depends on how Prestashop processes html tags in your case.static public function getAllCustomizedDatas($id_cart, $id_lang = null) { global $cookie; if (!$id_lang AND $cookie->id_lang) $id_lang = $cookie->id_lang; else { $cart = new Cart(intval($id_cart)); $id_lang = intval($cart->id_lang); } if (!$result = Db::getInstance()->ExecuteS(' SELECT cd.`id_customization`, c.`id_product`, cfl.`id_customization_field`, c.`id_product_attribute`, cd.`type`, cd.`index`, replace(replace(cd.`value`,char(13)," "),char(10),"") as value, cfl.`name` FROM `'._DB_PREFIX_.'customized_data` cd NATURAL JOIN `'._DB_PREFIX_.'customization` c LEFT JOIN `'._DB_PREFIX_.'customization_field_lang` cfl ON (cfl.id_customization_field = cd.`index` AND id_lang = '.intval($id_lang).') WHERE c.`id_cart` = '.intval($id_cart).' ORDER BY `id_product`, `id_product_attribute`, `type`, `index`')) return false; $customizedDatas = array(); foreach ($result AS $row) $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['datas'][intval($row['type'])][] = $row; if (!$result = Db::getInstance()->ExecuteS('SELECT `id_product`, `id_product_attribute`, `id_customization`, `quantity`, `quantity_refunded`, `quantity_returned` FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.intval($id_cart))) return false; foreach ($result AS $row) { $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity'] = intval($row['quantity']); $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity_refunded'] = intval($row['quantity_refunded']); $customizedDatas[intval($row['id_product'])][intval($row['id_product_attribute'])][intval($row['id_customization'])]['quantity_returned'] = intval($row['quantity_returned']); } return $customizedDatas; } Correction for all occurences of the new line: //add customized text fields var customizedData = "", re=/^textField\d+/; if ((CUSTOMIZE_TEXTFIELD == 1) && (document.getElementById("customizationForm") != null)){ var customizedForm=document.getElementById("customizationForm"); for (var i=0; i if (re.test(customizedForm.elements[i].name)){ customizedData += "&" + customizedForm.elements[i].name + "=" + customizedForm.elements[i].value.replace(/\n/g," "); } } customizedData += "&submitCustomizedDatas=1"; } I noticed that code inclusion replaced quoted characters.You have to type function as follow but delete space after %: customizedData += "&" + customizedForm.elements[i].name + "=" + customizedForm.elements[i].value.replace(/\n/g,"% 0D% 0A "); 1 Link to comment Share on other sites More sharing options...
stefanosm Posted December 30, 2010 Share Posted December 30, 2010 leaving the Product.php as it is by default and making the above fixes in the ajax-cart.js resulted in a fully functional customization TEXTAREA WITHOUT any SAVE BUTTON.thank you otzy, you are great! Link to comment Share on other sites More sharing options...
mimb Posted December 30, 2010 Share Posted December 30, 2010 I did this and it works! Thank you soo much!!!Can you help me find the right place to get rid of the actual save button and related instructions now? (see attachment)Mimib Link to comment Share on other sites More sharing options...
otzy Posted December 30, 2010 Author Share Posted December 30, 2010 I did this and it works! Thank you soo much!!!Can you help me find the right place to get rid of the actual save button and related instructions now? (see attachment)Mimib /themes/YourTheme/product.tplfind and delete line 436(if YourTheme=prestashop). It begins with:[pre]<input type="button" class="button" value="{l s='Save'}"[/pre]and this button has onclick saveCustomization()(I can not show here the full line as this forum detruncate javascript in html tags) Link to comment Share on other sites More sharing options...
mimb Posted January 4, 2011 Share Posted January 4, 2011 Otzy,You're brilliant! It works perfectly. I moved it up into the add-to-cart area too and so now the customer will make their customization selection along with their attribute selections (see it here... http://princewatch.com/prestashop/calfskin-watch-band/10-fluco-record-black-long.html ) I'm still building the site, but this was a big step forward.I tried to do one more thing to it, but was unsuccessful. Do you think it's possible to make the customization input type be a checkbox instead of a text box? I tried just changing this line it in the product.tpl, but it stopped working. <input type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" value="{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}" class="customization_block_input" /> That way, they can just check a box if they want the buckle changed instead of typing the color they want. (I secretly REALLY like radio buttons for this, but I'm pretty sure that's asking too much)Thanks again -mimi Link to comment Share on other sites More sharing options...
jaimeweb Posted January 5, 2011 Share Posted January 5, 2011 this isnt working for me...i am using 1.3.5...can anyone helpthanks Link to comment Share on other sites More sharing options...
otzy Posted January 6, 2011 Author Share Posted January 6, 2011 Otzy,You're brilliant! It works perfectly. I moved it up into the add-to-cart area too and so now the customer will make their customization selection along with their attribute selections (see it here... http://princewatch.com/prestashop/calfskin-watch-band/10-fluco-record-black-long.html ) I'm still building the site, but this was a big step forward.I tried to do one more thing to it, but was unsuccessful. Do you think it's possible to make the customization input type be a checkbox instead of a text box? I tried just changing this line it in the product.tpl, but it stopped working. <input type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" value="{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}" class="customization_block_input" /> That way, they can just check a box if they want the buckle changed instead of typing the color they want. (I secretly REALLY like radio buttons for this, but I'm pretty sure that's asking too much)Thanks again -mimi Unfortunately I have no enough time now but if you familiar with Javascript you may try the following solution.Change the type of text field from input type="text" to input type="hidden"Then add your checkboxes or radiobuttons and add listener on click event to these elements. In event hadler you change the values of hidden fields according to clicked radiobutton.You may design different sets of radiobuttons for differrent products Link to comment Share on other sites More sharing options...
otzy Posted January 6, 2011 Author Share Posted January 6, 2011 this isnt working for me...i am using 1.3.5...can anyone helpthanks I have updated my Prestashop to 1.3.5 and this works.Actually there were not changes of customized fields handling in this version.It may well be that you did not apply some guidelines Link to comment Share on other sites More sharing options...
jaimeweb Posted January 7, 2011 Share Posted January 7, 2011 Ah ok.Maybe im doing something wrong. What steps/posts am i meant to follow? And in which order? Link to comment Share on other sites More sharing options...
otzy Posted January 8, 2011 Author Share Posted January 8, 2011 the necessary steps are in the post 5 If you use textarea make changes from the post 18 of this thread.Do not use files attached to post 5, they are from version 1.3.2. You have to modify your 1.3.5 files. Link to comment Share on other sites More sharing options...
Dimitris27 Posted April 22, 2011 Share Posted April 22, 2011 I have the same problem (with version 1.3.7). I have modified the upon files (otzy-files) and as a result when i press the "Save to Cart" button i have the following message "product not found" . Anybody...help?? Link to comment Share on other sites More sharing options...
jaimeweb Posted May 13, 2011 Share Posted May 13, 2011 Can we get this working for 1.4.1??? Link to comment Share on other sites More sharing options...
jaimeweb Posted May 13, 2011 Share Posted May 13, 2011 Anyone???????? Please???? Link to comment Share on other sites More sharing options...
jaimeweb Posted May 16, 2011 Share Posted May 16, 2011 Can nobody do this?????????????? Please help Link to comment Share on other sites More sharing options...
otzy Posted May 17, 2011 Author Share Posted May 17, 2011 Can nobody do this?????????????? Please help I did not check how it works in 1.4Have you tried to apply 1.3.5 solution for 1.4? Link to comment Share on other sites More sharing options...
jaimeweb Posted May 17, 2011 Share Posted May 17, 2011 Some codes that are listed have completely changed in 1.4 and not sure what to change etc... Link to comment Share on other sites More sharing options...
jaimeweb Posted May 18, 2011 Share Posted May 18, 2011 Can no one help me out here!?!?!?!?! Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted May 18, 2011 Share Posted May 18, 2011 Can no one help me out here!?!?!?!?! I will definitely give it a try. Actually, I need this for a new store I am designing for an auto body shop. They will have two text input boxes and I want to remove the 'Save' button. I've also moved the customizations to just above the quanity and 'Add to Cart' button. It looks much better up there. I hate the other way of putting it in the tabs below. Hopefully Prestashop will change this in future editions. It will be a few days but I will have it working in 1.4 if you can wait. Once I get it working I'll be glad to tell you what I did. Marty Shue Link to comment Share on other sites More sharing options...
jaimeweb Posted May 18, 2011 Share Posted May 18, 2011 Hi Marty,I have also done the same, i agree, they are totally out the way at the bottom of the page. And why the save button isn't intergrated in the first place I don't know.That would be great if you can let me know.Thanks a lot! Link to comment Share on other sites More sharing options...
dokoss Posted May 22, 2011 Share Posted May 22, 2011 I need a code to delete the "save" button (for text fields)..... My customers NEVER clic on it............ So i have to contact them manually to know their customisations ! You don't imagine how it grows my work.... Please developpers and/or prestashop fans..... Please give us a good code to delete this save button! ..... (for version 1.4.1) Link to comment Share on other sites More sharing options...
nathanielleee Posted May 27, 2011 Share Posted May 27, 2011 ive added the changes to my product.tplbut for some reason it is not showing any changes in my store?ive even deleted it for a good while and replaced it with the new one but still no change??totally confusing. im using 1.4 Link to comment Share on other sites More sharing options...
dokoss Posted May 27, 2011 Share Posted May 27, 2011 Yeah.. Go to Back office (admin) -> Preferences -> Performances -> force compilation: yescache: nofor a development environment. Don't forget to switch for production.Changes will work now Link to comment Share on other sites More sharing options...
nathanielleee Posted May 27, 2011 Share Posted May 27, 2011 thanks that worked. I thought that would fix my problem but still am having issues with my customization fields. Only if the product has one custom field, my customers can save by pressing Enter (not by pressing save)but if there are more than 2 fields, enter does work. Its really limiting my sales. Anybody have this issue? Link to comment Share on other sites More sharing options...
babyewok Posted June 16, 2011 Share Posted June 16, 2011 Hi has anyone got this working on version 1.4 yet? Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 I have a couple of problems with this on ve 1.3.1.Firstly, if I add a product with a customized field to the cart and then try and add the product again, but with a different customized field (say someone is buy the same tshirt for two different peopel and therefore wants two different names printed on them), the previous cutomised field is saved, not the latest one. This happens even if you navigate away from the page and then back again to add the second product.How can I stop this from happening? I think it must have something to do with cookies since even if I navigate away from the page and then back again, the customized field is preopulated with the first name added. Removing the save button is something I have been trying to do for ages and now I am so tantelisingly close, I am desperate to sort out this one last issue! Link to comment Share on other sites More sharing options...
otzy Posted June 20, 2011 Author Share Posted June 20, 2011 could you give me a link to your site Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 I haven't set any of my changes live yet - I am working on my test server on my local computer until I get it working correctly. Link to comment Share on other sites More sharing options...
otzy Posted June 20, 2011 Author Share Posted June 20, 2011 I haven't set any of my changes live yet - I am working on my test server on my local computer until I get it working correctly. Customizations are sent not in cookies but as GET parameters in the ajax request. I think there is some wrong in ajax-cart.jsBut I am not sure as I did not touch your site. Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 OK, well there are two sections in the ajax-cart.js that refer to $.ajax I edited the firs as per your instruction but not the second - could this be the issue? // save the expand statut in the user cookie $.ajax({ type: 'POST', url: baseDir + 'cart.php?' + 'add&ajax=true&qty;=' + ( (quantity && quantity != null) ? quantity : '1') + '&id;_product=' + idProduct + '&token;=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa;=' + parseInt(idCombination): '') + customizedData , async: true, cache: false, dataType : "json", // data: , }); } }, // cart to fix display when using back and previous browsers buttons refresh : function(){ //send the ajax request to the server $.ajax({ type: 'GET', url: baseDir + 'cart.php', async: true, cache: false, dataType : "json", data: 'ajax=true&token;=' + static_token, success: function(jsonData) { ajaxCart.updateCart(jsonData) }, error: function(XMLHttpRequest, textStatus, errorThrown) { //alert("TECHNICAL ERROR: unable to refresh the cart.\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); } }); Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 Actually, there are a number of points where $.ajax is mentioned - which do I need to change?The commented sections for each $.ajax read:// save the expand statut in the user cookie (line 91)//send the ajax request to the server (line 107)// save the expand statut in the user cookie (line 140)//send the ajax request to the server (line 167)//send the ajax request to the server (line 215) Link to comment Share on other sites More sharing options...
otzy Posted June 20, 2011 Author Share Posted June 20, 2011 Unfortunately I have no original ajax-cart.js of your version. So I do not know the right line number.You have to add code and change $.ajax in the add function. Find something like this: // add a product in the cart via ajax add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist){ and add code there Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 Hmm, well I tried chagning that bit and reverting the bit I had done before by mistake and now it doesn't work at all! I have attached the original ajax-cart.js file - if you wouldn't mind having a quick look for me to let me know which bits I should be editing?EDIT - don't worry - sorted now! Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 Aha! Scrap that as I have now done a bit of detective work looking at the file you attached to post 5 (don't know why I didn't look at that first!) and have now got it working nicely. Thank you! Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 So sorry, me again!OK, the changes have gone live (http://www.pitterpatterproducts.co.uk) now on my client's site and I have noticed problems I hadn't seen before:On IE7, the animation is not shown on add to cart and sometimes the item is not added at all.On Firefox, the item is added but then instantly removed.In Safari for windows, I get this error: TECHNICAL ERROR: unable to add the product. Details: Error thrown: [object XMLHttpRequest] Text status: errorNow that it is live, I obviously need to get this sorted as quickly as possible. Link to comment Share on other sites More sharing options...
babyewok Posted June 20, 2011 Share Posted June 20, 2011 Phew! I found the problem - so sorry to be a pain... I panicked what with it being live now! At some point in the thread someone said you needed to add an onclick to the add to cart button. I have now removed this and it is working nicely in each of the browsers I mentioned.Panic over! Link to comment Share on other sites More sharing options...
otzy Posted June 20, 2011 Author Share Posted June 20, 2011 Phew! I found the problem - so sorry to be a pain... I panicked what with it being live now! At some point in the thread someone said you needed to add an onclick to the add to cart button. I have now removed this and it is working nicely in each of the browsers I mentioned.Panic over! while I was mining your site it got fine. Good luck Link to comment Share on other sites More sharing options...
otzy Posted June 20, 2011 Author Share Posted June 20, 2011 probably it's a bug of jQuery unbind() - I don't know why but it did not unbind onclick assigned in html. Link to comment Share on other sites More sharing options...
cunni Posted June 28, 2011 Share Posted June 28, 2011 babyewok What version of Prestashop are you using as I've followed this thread perfectly serveral times and its not working at all in the way your site does. I really dont understand what I've got wrong for it not to work... Thanks in Advance Dan. Link to comment Share on other sites More sharing options...
babyewok Posted June 28, 2011 Share Posted June 28, 2011 That particular site uses v. 1.3.1.1 Link to comment Share on other sites More sharing options...
cunni Posted June 28, 2011 Share Posted June 28, 2011 Thanks babyewok, I've just got it working on a clean install of 1.3.1 but i think my site uses 1.3.6 or 1.3.7 Im going to take a look at the differnces now. Link to comment Share on other sites More sharing options...
cunni Posted June 28, 2011 Share Posted June 28, 2011 Definately doesnt work on a clean 1.3.7 install. Link to comment Share on other sites More sharing options...
quinnsoft Posted June 29, 2011 Share Posted June 29, 2011 Does anybody figure out how to use in prestashop 1.4? Link to comment Share on other sites More sharing options...
cunni Posted June 29, 2011 Share Posted June 29, 2011 Has anyone got issues with this hack and the "AJAX Dropdown Categories v1.5.5" When I enable that mod this hack stops working. It looks like its messing with the way that the Ajax cart works. If anyone can enlighten me on this or help in any way it would be appreciated.Prestashop Version: 1.3.0 (With this auto save hack manually added as in Post #5)AJAX Dropdown Categories v1.5.5Kind RegardsDan. Link to comment Share on other sites More sharing options...
cunni Posted June 29, 2011 Share Posted June 29, 2011 From digging deeper, It would seem that the module is turning off the Ajax Cart... Is there anyway I can get this hack to work with the Ajax cart disabled?CheersDan. Link to comment Share on other sites More sharing options...
stefanosm Posted August 25, 2011 Share Posted August 25, 2011 Has anybody a solution for Presta v. 1.4.4.0? Steve Link to comment Share on other sites More sharing options...
cronotempo Posted September 14, 2011 Share Posted September 14, 2011 ¿podrías subir los ficheros modificados para probar lo que habéis hecho? es que estoy intentando adaptarlo para que me recoja campos customizables con otro valores y me da demasiados errores. Gracias -------------------------- Could you upload the files modified to test what you have done? I'm trying to adapt it to pick me up customizable fields with other values and gives me too many errors. thanks Link to comment Share on other sites More sharing options...
BozzY Posted October 14, 2011 Share Posted October 14, 2011 Hello, Sorry to bother you, but i modified cart.php and ajax-cart.js like you said but i get an error: missing ; after for-loop condition for (var i=0; i ...st(customizedForm.elements.name)){ can you help me? Link to comment Share on other sites More sharing options...
otzy Posted October 15, 2011 Author Share Posted October 15, 2011 Hello, Sorry to bother you, but i modified cart.php and ajax-cart.js like you said but i get an error: missing ; after for-loop condition for (var i=0; i ...st(customizedForm.elements.name)){ can you help me? looks like opening or closing bracket is missing. Check the hole script for errors Link to comment Share on other sites More sharing options...
BozzY Posted October 17, 2011 Share Posted October 17, 2011 looks like opening or closing bracket is missing. Check the hole script for errors The thing is that before i add this piece of code everything is ok. The error appears after i add the code. I'll try to find that bracket that is missing. Thanks Link to comment Share on other sites More sharing options...
w3bsolutions Posted October 27, 2011 Share Posted October 27, 2011 Hi there, Has anyone figured this out on PS 1.4? I did all the changes mentioned on post 5, adding the function instead of cart.php in controllers/CartController.php and applied the changes to ajax-cart.js but it does not work. The customized fields are not sent to the cart... and the sliding effect into the cart module stopped working. Any idea? I need to get this fixed a.s.a.p because if not the page reloads everytime i click on the Save button and the attributes revert to the default ones. So I need to make it work without the Save button, unless there is a way to ajax the save button but accordint to the PS support team this is not possible. I am willing to pay for this fix in PS 1.4. Get in touch with me. Looking forward to a reply soon! Link to comment Share on other sites More sharing options...
w3bsolutions Posted October 27, 2011 Share Posted October 27, 2011 One thing I figured out that could work too is this. The reason PS 1.4 reloads with the default attributes is because the form action="product.php?id_product=4387" just reloads with the id_product=id but in earlier versions of PS, not sure which one now because I am checking on another website built in PS that works fine, it reloads like this action="product.php?id_product=11&group_4=73&group_5=80&group_6=83&group_4=73&group_5=80&group_6=83" with each &group_id=attribute_id being the attribute groups. So it reloads with the attributes the user previously selected. Does anyone know how to implement this in PS 1.4? Where is the function that controls it? Thanx Link to comment Share on other sites More sharing options...
BozzY Posted November 1, 2011 Share Posted November 1, 2011 I don't know if this how it's supposed to be, but i think that the code inclusion deleted a part of the the code because the for expression is incomplete. Could you please re-upload the ajax-cart.js or only a txt file with the lines that have to be inserted before $.ajax in the add function? Link to comment Share on other sites More sharing options...
w3bsolutions Posted November 1, 2011 Share Posted November 1, 2011 These were the changed I did but weren't working. Instead of cart.php I modified controllers/CartController.php and the ajax-cart.js is the same file. I don't know if the problem could be that my template uses <textarea> instead of <input> for the customization form. However I need a fix for this a.s.a.p. It would be awesome to get rid of the Save Button but i haven't managed to make it work. Any help is appreciated. 1. /cart.php add function: function textRecord(Product $product, Cart $cart) { global $errors; if (!$fieldIds = $product->getCustomizationFieldIds()) return false; $authorizedTextFields = array(); foreach ($fieldIds AS $fieldId) if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_) $authorizedTextFields[intval($fieldId['id_customization_field'])] = 'textField'.intval($fieldId['id_customization_field']); $indexes = array_flip($authorizedTextFields); foreach (array_merge($_POST, $_GET) AS $fieldName => $value) if (in_array($fieldName, $authorizedTextFields) AND !empty($value)) { if (!Validate::isMessage($value)) $errors[] = Tools::displayError('Invalid message'); else $cart->addTextFieldToProduct(intval($product->id), $indexes[$fieldName], $value); } elseif (in_array($fieldName, $authorizedTextFields) AND empty($value)) $cart->deleteTextFieldFromProduct(intval($product->id), $indexes[$fieldName]); } it is taken from product.php and $_GET parameters are added to foreach cycle. 2. /cart.php insert lines: /* save text customization fields */ if (Tools::isSubmit('submitCustomizedDatas')) { textRecord($producToAdd, $cart); } after these lines: else { $producToAdd = new Product(intval($idProduct), false, intval($cookie->id_lang)); if ((!$producToAdd->id OR !$producToAdd->active) AND !$delete) $errors[] = Tools::displayError('product is no longer available'); else { 3. /modules/blockcart/ajax-cart.js in the add function insert lines before $.ajax: //add customized text fields var customizedData = "", re=/^textField\d+/; if ((CUSTOMIZE_TEXTFIELD == 1) && (document.getElementById("customizationForm") != null)){ var customizedForm=document.getElementById("customizationForm"); for (var i=0; i if (re.test(customizedForm.elements[i].name)){ customizedData += "&" + customizedForm.elements[i].name + "=" + customizedForm.elements[i].value; } } customizedData += "&submitCustomizedDatas=1"; } and change lines in $.ajax call: $.ajax({ type: 'POST', url: baseDir + 'cart.php?' + 'add&ajax=true&qty;=' + ( (quantity && quantity != null) ? quantity : '1') + '&id;_product=' + idProduct + '&token;=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa;=' + parseInt(idCombination): '') + customizedData , async: true, cache: false, dataType : "json", // data: , 4. It works only with text fields. You may also remove Save button in customizationForm. Tested in Firefox 3.5.15, IE 7, Opera 10.63 Link to comment Share on other sites More sharing options...
w3bsolutions Posted November 2, 2011 Share Posted November 2, 2011 Hi there, Has anyone figured this out on PS 1.4? I did all the changes mentioned on post 5, adding the function instead of cart.php in controllers/CartController.php and applied the changes to ajax-cart.js but it does not work. The customized fields are not sent to the cart... and the sliding effect into the cart module stopped working. Any idea? I need to get this fixed a.s.a.p because if not the page reloads everytime i click on the Save button and the attributes revert to the default ones. So I need to make it work without the Save button, unless there is a way to ajax the save button but accordint to the PS support team this is not possible. I am willing to pay for this fix in PS 1.4. Get in touch with me. Looking forward to a reply soon! Bump. I really need to get this working on PS 1.4. Whoever can do it and is sure it will work please send me a quote if not willing to support for free. Is it that hard to update this fix to PS 1.4 if it was working on PS 1.3?? I am not a programmer but I really need this working. My boss told me I need to have it fixed before the weekend :-( Pleaseeeee help. Thanx. Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted November 2, 2011 Share Posted November 2, 2011 I sent you a PM. If interested let me know asap. Marty Shue Link to comment Share on other sites More sharing options...
w3bsolutions Posted November 2, 2011 Share Posted November 2, 2011 I sent you a PM. If interested let me know asap. Marty Shue PM answered. Link to comment Share on other sites More sharing options...
Kungpin Posted November 4, 2011 Share Posted November 4, 2011 I got one textfield on every product and would like to skip the save button. I need to get this working on PS 1.4.4.1 and willing to pay for the solution. Send me a PM if you know how to solve this! Link to comment Share on other sites More sharing options...
drifter Posted January 2, 2012 Share Posted January 2, 2012 More testing needs to be done, but I think I got this to work in 1.4.6.2 CartController.php Added: /* save text customization fields - added 1/1/2012*/ if (Tools::isSubmit('submitCustomizedDatas')) { $this->textRecord($producToAdd); } Just before (where otzy says to): /* Check the quantity availability */ if ($idProductAttribute AND is_numeric($idProductAttribute)) And I modified otzy's function a bit and added it to the bottom of my CartController.php file: private function textRecord(Product $product) { global $errors; if (!$fieldIds = $product->getCustomizationFieldIds()) return false; $authorizedTextFields = array(); foreach ($fieldIds AS $fieldId) if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_) $authorizedTextFields[intval($fieldId['id_customization_field'])] = 'textField'.intval($fieldId['id_customization_field']); $indexes = array_flip($authorizedTextFields); foreach (array_merge($_POST, $_GET) AS $fieldName => $value) if (in_array($fieldName, $authorizedTextFields) AND !empty($value)) { if (!Validate::isMessage($value)) $errors[] = Tools::displayError('Invalid message'); else self::$cart->addTextFieldToProduct(intval($product->id), $indexes[$fieldName], $value); } elseif (in_array($fieldName, $authorizedTextFields) AND empty($value)) self::$cart->deleteTextFieldFromProduct(intval($product->id), $indexes[$fieldName]); } In ajax-cart.js I added otzy's code, but modifed the data: line in the $.ajax call: data: 'add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): '') + customizedData, Lastly, in my product.tpl file, I moved the whole customizable products block into the buy_block form, and took it out of the form it was in. Without moving the customization data into this form, the process won't work. The key thing that drives it all "submitCustomizedDatas" wasn't getting passed otherwise. Link to comment Share on other sites More sharing options...
otzy Posted January 3, 2012 Author Share Posted January 3, 2012 More testing needs to be done, but I think I got this to work in 1.4.6.2 fine, but one remark - it is better not to change core controller file. Copy attached file to /override/controllers/ and you will be happy with future Prestashop updates. CartController.php 1 Link to comment Share on other sites More sharing options...
drifter Posted January 3, 2012 Share Posted January 3, 2012 Yes, after I got it working I did move the updated function to the override/contollers folder. Thanks for your help otzy Link to comment Share on other sites More sharing options...
quinnsoft Posted January 4, 2012 Share Posted January 4, 2012 Thanks for all your help. Link to comment Share on other sites More sharing options...
quinnsoft Posted January 4, 2012 Share Posted January 4, 2012 Can you post your code and give us an example for your ajax-cart.js and your product.tpl? I tried to follow your way but no luck. Thanks. Link to comment Share on other sites More sharing options...
drifter Posted January 4, 2012 Share Posted January 4, 2012 Here is my CartController override and my ajax-cart. However I will say, I don't think I use the ajax calls. When ever you add an item in my shop, it takes you directly to the cart. The ajax method didn't fit my needs. In looking at the ajax-cart, it would probably need to be modified to remove the references to "customizationForm" and replace with "buy_block". I didn't attach my product.tpl file because it is now heavily customized. While I wanted the flexability of having text fields on my form, I still wanted the values they could be to be database driven. This now happens with a jquery popup and custom tables much like ps_attribute, ps_product_attribute and ps_product_attribute_combination. The CartController.php file is placed in override\controllers The whole blockcart module has been copied over to my theme\modules folder If you are trying to debug, I highly recommend the combination of eclipse/xdebug and FireFox. Without them, I wouldn't have been able to figure out what was or wasn't really working. CartController.php ajax-cart_js.txt 1 Link to comment Share on other sites More sharing options...
quinnsoft Posted January 4, 2012 Share Posted January 4, 2012 Thanks a lot for your shar and help. I pasted your CartController.php and ajax-cart_js.txt to my cart. Still did not work. I think the problem is in the product.tpl. Here is my product.tpl. I tried to follow your suggestion to put the text field in the buy block. Could you take a look for my code. Sorry I am not a programmer. Thank again. {if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)} <!-- add to cart form--> <form id="buy_block" {if $PS_CATALOG_MODE AND !isset($groups) AND $product->quantity > 0}class="hidden"{/if} action="{$link->getPageLink('cart.php')}" method="post"> <!-- hidden datas --> <p class="hidden"> <input type="hidden" name="token" value="{$static_token}" /> <input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="id_product_attribute" id="idCombination" value="" /> </p> <div class="product_attributes"> {if isset($groups)} <!-- attributes --> <div id="attributes"> {foreach from=$groups key=id_attribute_group item=group} {if $group.attributes|@count} <p> <label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label> {assign var="groupName" value="group_$id_attribute_group"} <select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};"> {foreach from=$group.attributes key=id_attribute item=group_attribute} <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option> {/foreach} </select> </p> {/if} {/foreach} </div> {/if} <p id="product_reference" {if isset($groups) OR !$product->reference}style="display: none;"{/if}><label for="product_reference">{l s='Reference :'} </label><span class="editable">{$product->reference|escape:'htmlall':'UTF-8'}</span></p> <!-- quantity wanted --> <p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> <label>{l s='Quantity :'}</label> <input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" size="2" maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} /> </p> <!-- minimal quantity wanted --> <p id="minimal_quantity_wanted_p"{if $product->minimal_quantity <= 1 OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>{l s='You must add '}<b id="minimal_quantity_label">{$product->minimal_quantity}</b>{l s=' as a minimum quantity to buy this product.'}</p> {if $product->minimal_quantity > 1} <script type="text/javascript"> checkMinimalQuantity(); </script> {/if} <!-- availability --> <p id="availability_statut"{if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> <span id="availability_label">{l s='Availability:'}</span> <span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}> {if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if} </span> </p> <!-- number of item in stock --> {if ($display_qties == 1 && !$PS_CATALOG_MODE && $product->available_for_order)} <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 in stock'}</span> <span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}</span> </p> {/if} <!-- Out of stock hook --> <p id="oosHook"{if $product->quantity > 0} style="display: none;"{/if}> {$HOOK_PRODUCT_OOS} </p> <p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}</p> {if $product->online_only} <p>{l s='Online only'}</p> {/if} </div> <div class="content_prices clearfix"> <!-- prices --> {if $product->show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <div class="price"> {if !$priceDisplay || $priceDisplay == 2} {assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL)} {assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)} {elseif $priceDisplay == 1} {assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL)} {assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(true, $smarty.const.NULL)} {/if} <p class="our_price_display"> {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> <!--{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if}--> {/if} </p> {if $product->on_sale} <img src="{$img_dir}onsale_{$lang_iso}.gif" alt="{l s='On sale'}" class="on_sale_img"/> <span class="on_sale">{l s='On sale!'}</span> {elseif $product->specificPrice AND $product->specificPrice.reduction AND $productPriceWithoutRedution > $productPrice} <span class="discount">{l s='Reduced price!'}</span> {/if} {if $priceDisplay == 2} <br /> <span id="pretaxe_price"><span id="pretaxe_price_display">{convertPrice price=$product->getPrice(false, $smarty.const.NULL)}</span> {l s='tax excl.'}</span> {/if} </div> {if $product->specificPrice AND $product->specificPrice.reduction_type == 'percentage'} <p id="reduction_percent"><span id="reduction_percent_display">-{$product->specificPrice.reduction*100}%</span></p> {/if} {if $product->specificPrice AND $product->specificPrice.reduction} <p id="old_price"><span class="bold"> {if $priceDisplay >= 0 && $priceDisplay <= 2} {if $productPriceWithoutRedution > $productPrice} <span id="old_price_display">{convertPrice price=$productPriceWithoutRedution}</span> <!-- {if $tax_enabled && $display_tax_label == 1} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if} --> {/if} {/if} </span> </p> {/if} {if $packItems|@count} <p class="pack_price">{l s='instead of'} <span style="text-decoration: line-through;">{convertPrice price=$product->getNoPackPrice()}</span></p> <br class="clear" /> {/if} {if $product->ecotax != 0} <p class="price-ecotax">{l s='include'} <span id="ecotax_price_display">{if $priceDisplay == 2}{$ecotax_tax_exc|convertAndFormatPrice}{else}{$ecotax_tax_inc|convertAndFormatPrice}{/if}</span> {l s='for green tax'} {if $product->specificPrice AND $product->specificPrice.reduction} <br />{l s='(not impacted by the discount)'} {/if} </p> {/if} {if !empty($product->unity) && $product->unit_price_ratio > 0.000000} {math equation="pprice / punit_price" pprice=$productPrice punit_price=$product->unit_price_ratio assign=unit_price} <p class="unit-price"><span id="unit_price_display">{convertPrice price=$unit_price}</span> {l s='per'} {$product->unity|escape:'htmlall':'UTF-8'}</p> {/if} {*close if for show price*} {/if} /////////////////////////////////////////////// Here is the customizable products code I moved into <!-- Customizable products --> {if $product->customizable} <ul class="idTabs clearfix"> <li><a style="cursor: pointer">{l s='Product customization'}</a></li> </ul> <div class="customization_block"> <img src="{$img_dir}icon/infos.gif" alt="Informations" /> {l s='After saving your customized product, remember to add it to your cart.'} {if $product->uploadable_files}<br />{l s='Allowed file formats are: GIF, JPG, PNG'}{/if} </p> {if $product->uploadable_files|intval} <h2>{l s='Pictures'}</h2> <ul id="uploadable_files"> {counter start=0 assign='customizationField'} {foreach from=$customizationFields item='field' name='customizationFields'} {if $field.type == 0} <li class="customizationUploadLine{if $field.required} required{/if}">{assign var='key' value='pictures_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field} {if isset($pictures.$key)}<div class="customizationUploadBrowse"> <img src="{$pic_dir}{$pictures.$key}_small" alt="" /> <a href="{* $link->getProductDeletePictureLink($product,{$field.id_customization_field})*}" title="{l s='Delete'}" > <img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" /> </a> </div>{/if} <div class="customizationUploadBrowse"><input type="file" name="file{$field.id_customization_field}" id="img{$customizationField}" class="customization_block_input {if isset($pictures.$key)}filled{/if}" />{if $field.required}<sup>*</sup>{/if} <div class="customizationUploadBrowseDescription">{if !empty($field.name)}{$field.name}{else}{l s='Please select an image file from your hard drive'}{/if}</div></div> </li> {counter} {/if} {/foreach} </ul> {/if} <div class="clear"></div> {if $product->text_fields|intval} <h2>{l s='Texts'}</h2> <ul id="text_fields"> {counter start=0 assign='customizationField'} {foreach from=$customizationFields item='field' name='customizationFields'} {if $field.type == 1} <li class="customizationUploadLine{if $field.required} required{/if}">{assign var='key' value='textFields_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field} {if !empty($field.name)}{$field.name}{/if}{if $field.required}<sup>*</sup>{/if}<textarea type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" rows="1" cols="40" class="customization_block_input" />{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}</textarea> </li> {counter} {/if} {/foreach} </ul> {/if} <p class="clear required"><sup>*</sup> {l s='required fields'}</p> </div> {/if} /////////////////////////////////////////////////////////////////////////////////////// <p{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} style="display: none;"{/if} id="add_to_cart" class="buttons_bottom_block"><span></span><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p> {if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if} <div class="clear"></div> </div> </form> {/if} Here is my CartController override and my ajax-cart. However I will say, I don't think I use the ajax calls. When ever you add an item in my shop, it takes you directly to the cart. The ajax method didn't fit my needs. In looking at the ajax-cart, it would probably need to be modified to remove the references to "customizationForm" and replace with "buy_block". I didn't attach my product.tpl file because it is now heavily customized. While I wanted the flexability of having text fields on my form, I still wanted the values they could be to be database driven. This now happens with a jquery popup and custom tables much like ps_attribute, ps_product_attribute and ps_product_attribute_combination. The CartController.php file is placed in override\controllers The whole blockcart module has been copied over to my theme\modules folder If you are trying to debug, I highly recommend the combination of eclipse/xdebug and FireFox. Without them, I wouldn't have been able to figure out what was or wasn't really working. Link to comment Share on other sites More sharing options...
quinnsoft Posted January 4, 2012 Share Posted January 4, 2012 Also. Can you give us your website link if possible? Then we can see your wonderful work. Here is my CartController override and my ajax-cart. However I will say, I don't think I use the ajax calls. When ever you add an item in my shop, it takes you directly to the cart. The ajax method didn't fit my needs. In looking at the ajax-cart, it would probably need to be modified to remove the references to "customizationForm" and replace with "buy_block". I didn't attach my product.tpl file because it is now heavily customized. While I wanted the flexability of having text fields on my form, I still wanted the values they could be to be database driven. This now happens with a jquery popup and custom tables much like ps_attribute, ps_product_attribute and ps_product_attribute_combination. The CartController.php file is placed in override\controllers The whole blockcart module has been copied over to my theme\modules folder If you are trying to debug, I highly recommend the combination of eclipse/xdebug and FireFox. Without them, I wouldn't have been able to figure out what was or wasn't really working. Link to comment Share on other sites More sharing options...
drifter Posted January 4, 2012 Share Posted January 4, 2012 There should be a hidden input field, submitcustomizeddatas, that needs to be moved to the buy_block as well. I didn't see it in your example. Look for it in the bottom of your product.tpl file. One my site is online, I'll post a link. Right now I'm testing on my local machine. Link to comment Share on other sites More sharing options...
quinnsoft Posted January 5, 2012 Share Posted January 5, 2012 There should be a hidden input field, submitcustomizeddatas, that needs to be moved to the buy_block as well. I didn't see it in your example. Look for it in the bottom of your product.tpl file. One my site is online, I'll post a link. Right now I'm testing on my local machine. Thanks a lot. It worked. Link to comment Share on other sites More sharing options...
Carisma Posted January 9, 2012 Share Posted January 9, 2012 Is It ok that every ajax movements does not working any more..? Link to comment Share on other sites More sharing options...
ericktoti Posted January 10, 2012 Share Posted January 10, 2012 Thank you! drifter, work fine your code Link to comment Share on other sites More sharing options...
lazmuds Posted January 11, 2012 Share Posted January 11, 2012 Thank you! drifter, work fine your code Hi. is it possible for you to post your code for the files that you changed. I have been trying for the past 3 days to get this working but I am failing. Please if you can also include the product.tpl and the other files that you modified. Thank you in advance Link to comment Share on other sites More sharing options...
drifter Posted January 24, 2012 Share Posted January 24, 2012 quinnsoft, you asked for the link to my site once it was up and running. Here it is http://www.lovablestitches.com You can see how I use a blend of PrestaShop's combinations and custom tables/jquery to give it addtional functinoality. Link to comment Share on other sites More sharing options...
A-Z Hosting Posted February 2, 2012 Share Posted February 2, 2012 Has anybody been able to use this with a single click Add to Cart that isn't located in the product.tpl file? I need to create one and would like to also pass a customize text field with it. Sounds like this thread is as close as anyone has ever gotten. Link to comment Share on other sites More sharing options...
reiben Posted February 14, 2012 Share Posted February 14, 2012 Is there any solution to save customized text with "Add to cart" and stay on product page? I used drifter's code change,but it goes right to order-opc.php and i cant find way to solve this thanks Link to comment Share on other sites More sharing options...
bellini13 Posted April 26, 2012 Share Posted April 26, 2012 thanks for this modification Drifter, it works well on v1.4.6.2 with ajax cart disabled. If I find time, I will try to get it working with ajax enabled for those who want it. Link to comment Share on other sites More sharing options...
yesiam Posted June 4, 2012 Share Posted June 4, 2012 Hi, there is someone who has been able to operate correctly in prestashop 1.4?, Please if anyone can share the changes you need to do to work properly, it would be a great help. I tried all ways and means, and does not even work with ajax enabled or without activating the ajax does not work anything, can you help ?, My version is 1.4 thanks prestashop. Hola, existe alguien que lo haya podido hacer funcionar correctamente en prestashop 1.4 ?, por favor si alguien puede compartir las modificaciones que hay que hacer para que funcione correctamente, sería una gran ayuda. He intentado de todas las formas y maneras, y no funciona ni con ajax activado o sin activar el ajax, no me funciona nada, pueden ayudarme ?, mi version de prestashop es 1.4 gracias. Link to comment Share on other sites More sharing options...
yesiam Posted June 5, 2012 Share Posted June 5, 2012 Solved Link to comment Share on other sites More sharing options...
Ben23 Posted June 11, 2012 Share Posted June 11, 2012 Thankyou drifter... your code in post #81 worked great for me on 1.4.8.2. I don't use the Ajax cart on this site so I only needed the CartController.php dropped into override/controllers/. Anyway, as that worked so well I thought I'd see if I could extend it to work for image upload fields as well as text fields. And it was surprisingly straightforward. Job done - no more "Save" button for customisations! Here's how I did it. NB I only use the non-AJAX cart on this site; if you use the AJAX cart there's probably more that needs to be done to get it working, but perhaps this will nudge you in the right direction... Pull a copy of the pictureUpload() function out of ProductController.php (same place that textRecord() came from), add it to drifter's CartController.php in your /override/controllers directory, and modify it in the same way that textRecord() had been modified from its original version - ie: remove the second parameter from the function prototype, replace $cart with self::$cart , replace $this->product with $product. [There were some other changes in drifter's code, notably replacing some (int) casts with intval(), and using the global $errors[] instead of $this->errors[] - I didn't understand the reasoning for these, and the rest of CartController seems to use the former constructs, so I left them unchanged. Errors, such as uploading an invalid file type, still get reported back to the browser just fine. ] Add require_once('images.inc.php'); near the top of the file; this provides the checkImage() function needed by pictureUpload(). Add a call to pictureUpload() just before the call to textRecord(). (I suspect before/after doesn't matter, but for consistency I stuck to the same order that ProductController calls them). Sort your form out. Make sure your product.tpl (or whatever is generating the product page) only creates one <form> instead of two. The <form> tag must have enctype="multipart/form-data" in order to upload files, and include the hidden fields that Presta generates alongside customisation fields, such as submitCustomizedDatas. And, of course, delete the horrid Save button forever! Now, there is one disadvantage to doing it this way... you get no whirly clock to keep the user entertained during the upload by presenting an (entirely fictional) impression of Something Happening. If a user uploads a humongous file as part of a general form submission, the browser will appear to do nothing. Notwithstanding my considered opinion that it's about time browsers did something about this instead of leaving us poor web devs to have to cover for the browser's lack of useful feedback all the time, at some point I'll probably try to integrate a decent AJAX file-uploader with progress bar.... In the meantime, here's my version of the CartController.php override. CartController.php Link to comment Share on other sites More sharing options...
TWRB Posted July 12, 2012 Share Posted July 12, 2012 Hi Pro's, I am also looking for someone to get this to work on my shop 1.4.7, will pay for someone to fix it by paypal. Got ftp and admin account setup for the job, anybody? PM me! thx, Thomas Link to comment Share on other sites More sharing options...
manuelv Posted July 19, 2012 Share Posted July 19, 2012 same issue with prestashop 1.5 ? Link to comment Share on other sites More sharing options...
TWRB Posted July 19, 2012 Share Posted July 19, 2012 (edited) just to let all people know, I am on prestashop 1.4.7.0 and I had this issue that when I pressed the save button all attributes got reset to the default combination. And now for the solution... TADAAAAAA: Dont press the save button! Just add to cart, it works without any modification. Then go into css and just hide the button, or remove it from your product.tpl and yes, I did (happily) pay someone to find this out for me. greetings, T Edited July 19, 2012 by TWRB (see edit history) Link to comment Share on other sites More sharing options...
Rhapsody Posted September 20, 2012 Share Posted September 20, 2012 (edited) I tried playing with this on 1.4.9.0 with no success. Just to be sure it wasn't my customized theme, I used the stock Prestashop theme. I've attached the files used (ProductController.php in override/controller, ajax-cart.js in modules/blockcart and product.tpl in the prestashop theme directory) in the zip file below. It works normal if there are no customized fields. It displays the following when I have a customization filed that has a required input: There is 1 error : Please fill in all required fields, then save the customization. Does anyone have any tips to make this work on 1.4.9.0 remove-save-button.zip Edited September 20, 2012 by Rhapsody (see edit history) Link to comment Share on other sites More sharing options...
Rhapsody Posted September 20, 2012 Share Posted September 20, 2012 (edited) Oops - see my edit below A follow-up to my post #99 above. It works on 1.4.9.0 if I don't check "required field" in the BO for text fields in the customization tab for a product. So what needs to be done is figure out where the logic is that checks for required text field input, and move it to the appropriate section in the code. If anyone has an idea, please post here. Once I get this working, I'll post all the files to share with others. Edit: Darn.. it isn't working. I had a cached screen in my browser. Edited September 20, 2012 by Rhapsody (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