Jump to content

How to remove save button for customized fields?


otzy

Recommended Posts

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

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 by otzy (see edit history)
  • Like 5
Link to comment
Share on other sites

  • 1 month later...
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

New recipe

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 + "=" + 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 space
classes/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;
   }

  • Like 1
Link to comment
Share on other sites

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 product
2.- 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 cart
5.- It redirects to Cart.php without having introduced the attributes
If I go back, the textfields are filled in, they behave as if they had been saved with the button, but they are not added
to 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

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

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 product
2.- 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 cart
5.- It redirects to Cart.php without having introduced the attributes
If I go back, the textfields are filled in, they behave as if they had been saved with the button, but they are not added
to 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 -> Configure

I have changed only ajax call in my solution so it will not work with ajax disabled
Link to comment
Share on other sites

example for space
classes/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
");

  • Like 1
Link to comment
Share on other sites

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.tpl

find 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

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

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

this isnt working for me...
i am using 1.3.5...
can anyone help
thanks


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

  • 3 months later...
  • 3 weeks later...
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

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

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

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

  • 3 weeks later...

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

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.js
But I am not sure as I did not touch your site.
Link to comment
Share on other sites

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

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

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

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

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: error

Now that it is live, I obviously need to get this sorted as quickly as possible.

Link to comment
Share on other sites

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

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

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

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.5

Kind Regards
Dan.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

¿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

  • 5 weeks later...

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

 

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

  • 2 weeks later...

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

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

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

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

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

  • 1 month later...