otzy Posted November 4, 2010 Posted November 4, 2010 Is it possible to save customized fields at the same time when Add to cart was clicked? 2 Share this post Link to post Share on other sites More sharing options...
Patric Posted November 5, 2010 Posted November 5, 2010 Topic moved. Share this post Link to post Share on other sites More sharing options...
tomerg3 Posted November 5, 2010 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/ Share this post Link to post Share on other sites More sharing options...
otzy Posted November 7, 2010 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 Share this post Link to post Share on other sites More sharing options...
rocky Posted November 8, 2010 Posted November 8, 2010 Can you post exactly how you did it? It is a frequent request. Share this post Link to post Share on other sites More sharing options...
otzy Posted November 8, 2010 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 Share this post Link to post Share on other sites More sharing options...
stefanosm Posted December 22, 2010 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 Share this post Link to post Share on other sites More sharing options...
otzy Posted December 23, 2010 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"; } Share this post Link to post Share on other sites More sharing options...
stefanosm Posted December 23, 2010 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. Share this post Link to post Share on other sites More sharing options...
otzy Posted December 23, 2010 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 Share this post Link to post Share on other sites More sharing options...
cinziadm Posted December 23, 2010 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 Share this post Link to post Share on other sites More sharing options...
otzy Posted December 24, 2010 Posted December 24, 2010 Possibly you should write some javascript that will make calculation before posting data to the server Share this post Link to post Share on other sites More sharing options...
cinziadm Posted December 28, 2010 Posted December 28, 2010 Thank you Otzy,i will prove this solution Share this post Link to post Share on other sites More sharing options...
cinziadm Posted December 28, 2010 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?? Share this post Link to post Share on other sites More sharing options...
juanmaminage Posted December 28, 2010 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. Share this post Link to post Share on other sites More sharing options...
otzy Posted December 28, 2010 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. Share this post Link to post Share on other sites More sharing options...
otzy Posted December 28, 2010 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 Share this post Link to post Share on other sites More sharing options...
stefanosm Posted December 29, 2010 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! Share this post Link to post Share on other sites More sharing options...
otzy Posted December 29, 2010 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 Share this post Link to post Share on other sites More sharing options...
stefanosm Posted December 30, 2010 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! Share this post Link to post Share on other sites More sharing options...
mimb Posted December 30, 2010 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 Share this post Link to post Share on other sites More sharing options...
otzy Posted December 30, 2010 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) Share this post Link to post Share on other sites More sharing options...
mimb Posted January 4, 2011 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 Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted January 5, 2011 Posted January 5, 2011 this isnt working for me...i am using 1.3.5...can anyone helpthanks Share this post Link to post Share on other sites More sharing options...
otzy Posted January 6, 2011 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 Share this post Link to post Share on other sites More sharing options...
otzy Posted January 6, 2011 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 Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted January 7, 2011 Posted January 7, 2011 Ah ok.Maybe im doing something wrong. What steps/posts am i meant to follow? And in which order? Share this post Link to post Share on other sites More sharing options...
otzy Posted January 8, 2011 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. Share this post Link to post Share on other sites More sharing options...
Dimitris27 Posted April 22, 2011 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?? Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 13, 2011 Posted May 13, 2011 Can we get this working for 1.4.1??? Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 13, 2011 Posted May 13, 2011 Anyone???????? Please???? Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 16, 2011 Posted May 16, 2011 Can nobody do this?????????????? Please help Share this post Link to post Share on other sites More sharing options...
otzy Posted May 17, 2011 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? Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 17, 2011 Posted May 17, 2011 Some codes that are listed have completely changed in 1.4 and not sure what to change etc... Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 18, 2011 Posted May 18, 2011 Can no one help me out here!?!?!?!?! Share this post Link to post Share on other sites More sharing options...
Carolina Custom Designs Posted May 18, 2011 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 Share this post Link to post Share on other sites More sharing options...
jaimeweb Posted May 18, 2011 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! Share this post Link to post Share on other sites More sharing options...
dokoss Posted May 22, 2011 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) Share this post Link to post Share on other sites More sharing options...
nathanielleee Posted May 27, 2011 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 Share this post Link to post Share on other sites More sharing options...
dokoss Posted May 27, 2011 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 Share this post Link to post Share on other sites More sharing options...
nathanielleee Posted May 27, 2011 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? Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 16, 2011 Posted June 16, 2011 Hi has anyone got this working on version 1.4 yet? Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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! Share this post Link to post Share on other sites More sharing options...
otzy Posted June 20, 2011 Posted June 20, 2011 could you give me a link to your site Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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. Share this post Link to post Share on other sites More sharing options...
otzy Posted June 20, 2011 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. Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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); } }); Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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) Share this post Link to post Share on other sites More sharing options...
otzy Posted June 20, 2011 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 Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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! Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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! Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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. Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 20, 2011 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! Share this post Link to post Share on other sites More sharing options...
otzy Posted June 20, 2011 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 Share this post Link to post Share on other sites More sharing options...
otzy Posted June 20, 2011 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. Share this post Link to post Share on other sites More sharing options...
cunni Posted June 28, 2011 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. Share this post Link to post Share on other sites More sharing options...
babyewok Posted June 28, 2011 Posted June 28, 2011 That particular site uses v. 1.3.1.1 Share this post Link to post Share on other sites More sharing options...
cunni Posted June 28, 2011 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. Share this post Link to post Share on other sites More sharing options...
cunni Posted June 28, 2011 Posted June 28, 2011 Definately doesnt work on a clean 1.3.7 install. Share this post Link to post Share on other sites More sharing options...
quinnsoft Posted June 29, 2011 Posted June 29, 2011 Does anybody figure out how to use in prestashop 1.4? Share this post Link to post Share on other sites More sharing options...
cunni Posted June 29, 2011 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. Share this post Link to post Share on other sites More sharing options...
cunni Posted June 29, 2011 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. Share this post Link to post Share on other sites More sharing options...
stefanosm Posted August 25, 2011 Posted August 25, 2011 Has anybody a solution for Presta v. 1.4.4.0? Steve Share this post Link to post Share on other sites More sharing options...
cronotempo Posted September 14, 2011 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 Share this post Link to post Share on other sites More sharing options...
BozzY Posted October 14, 2011 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? Share this post Link to post Share on other sites More sharing options...
otzy Posted October 15, 2011 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 Share this post Link to post Share on other sites More sharing options...
BozzY Posted October 17, 2011 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 Share this post Link to post Share on other sites More sharing options...
w3bsolutions Posted October 27, 2011 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! Share this post Link to post Share on other sites More sharing options...
w3bsolutions Posted October 27, 2011 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 Share this post Link to post Share on other sites More sharing options...
BozzY Posted November 1, 2011 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? Share this post Link to post Share on other sites More sharing options...
w3bsolutions Posted November 1, 2011 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 Share this post Link to post Share on other sites More sharing options...
w3bsolutions Posted November 2, 2011 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. Share this post Link to post Share on other sites More sharing options...
Carolina Custom Designs Posted November 2, 2011 Posted November 2, 2011 I sent you a PM. If interested let me know asap. Marty Shue Share this post Link to post Share on other sites More sharing options...
w3bsolutions Posted November 2, 2011 Posted November 2, 2011 I sent you a PM. If interested let me know asap. Marty Shue PM answered. Share this post Link to post Share on other sites More sharing options...
Kungpin Posted November 4, 2011 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! Share this post Link to post Share on other sites More sharing options...
Recommended Posts