andries Posted May 23, 2010 Share Posted May 23, 2010 Hi,I have a customization field for a product. I would like to set this automatically with a generated reference, that I don't want to show to the customer. (this ID is actually generated by a Flash module, so I need to write it away when we add the product to the cart).I am able to hide it in the cart etc, but I don't know how I can set it automatically. I actually have even no clue where I have to start looking.I noticed that when I add it for a normal product the field indeed shows up in the product page, and there is a save button that triggers a javascript that saves this modification.Can someone give me a clue how I can automate the setting of a value? I know the product ID and I know the cart ID and the customizationfield ID, I just don't know how to put it all together. Link to comment Share on other sites More sharing options...
andries Posted May 24, 2010 Author Share Posted May 24, 2010 When I simply add a customization field to a normal product, PrestaShops add a form to save the customization. This is the HTML code: <form method="post" action="/product.php?id_product=1&group_1=16&group_2=14&group_1=16&group_2=14" enctype="multipart/form-data" id="customizationForm"> After saving your customized product, do not forget to add it to your cart. Texts TestField<input type="text" name="textField4" id="textField0" value="aaaa" class="customization_block_input" /> <input type="hidden" name="quantityBackup" id="quantityBackup" value="" /> <input type="hidden" name="submitCustomizedDatas" value="1" /> <input type="button" class="button" value="Save"> </form> * required fields So I assume that saving a customization is done by calling the script product.php, with sending some post and get variables: /product.php?id_product=1&group_1=16&group_2=14&group_1=16&group_2=14 So now is my question, I don't want to show this form, but I want to set automatically the value for textField4, and call the product.php script (the latter I can do :-) )Any help?I only show the code of the HTML to indicate what I want, I rather would like to stay in PHP... Link to comment Share on other sites More sharing options...
andries Posted May 25, 2010 Author Share Posted May 25, 2010 sorry for all the posts, but I try to clarify some things... To clarify a little more, see the image linked to this post. What we want to achieve is to automate the process of saving a customization field by filling in a unique code, created by Flash, and save it...At this moment we have the following process.The Flash File generates raw image data, and calls a php script. This script does the following steps:1. Saves the Image to the correct folder (with the unique code as filename)2. Creates an item for the cart3. Shows a small summary of the product addedProblem is that we need to know which cart item is linked to which image. I hoped to achieve this by adding a customization field, that I could populate and save during the php script ( so I guess between step 1 and 2 ).As I mentioned above, I think I will need to use the product.php script to do this, but I don't see how or which parameters I have to set, or which variables I have to declare... Link to comment Share on other sites More sharing options...
andries Posted June 1, 2010 Author Share Posted June 1, 2010 nobody...? I am really in pain finding a solution, and it is the last part i need to fix... Link to comment Share on other sites More sharing options...
andries Posted June 2, 2010 Author Share Posted June 2, 2010 HiI actually found the solution... and it was easy :-)I completely misunderstood how PrestaShop is working (or MVC in general :-)). I just needed to add this line of code into my php script and it does exactly what I want! $cart->addTextFieldToProduct($id_product, $index, $textValue); nice nice... Link to comment Share on other sites More sharing options...
babyewok Posted October 19, 2010 Share Posted October 19, 2010 Hi andries, I wonder if you can help. The save button for the customized text field is causing the product page to refresh and so cause problems with my colour choices reverting back to the default. I would like to keep the text field, but combine the save and add to cart buttons...I know your solution uses flash and is slightly different, but I wondered if you could offer a simple solution as to how to combine the save and add to cart functions? Link to comment Share on other sites More sharing options...
dna Posted December 6, 2010 Share Posted December 6, 2010 can you be specific which folder you put that code at..script php?? is unknown...thank you Link to comment Share on other sites More sharing options...
BozzY Posted November 3, 2011 Share Posted November 3, 2011 Hi I actually found the solution... and it was easy :-) I completely misunderstood how PrestaShop is working (or MVC in general :-)). I just needed to add this line of code into my php script and it does exactly what I want! $cart->addTextFieldToProduct($id_product, $index, $textValue); nice nice... Hi. In what file did you inserted the code? Thanks 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