hugolin69 Posted March 18, 2018 Share Posted March 18, 2018 Hi, I would like to save the customization fields when I click to add a button, hidding the custom field saving button. I found this tutorial, but it is for the 1.6 version. I tried many ways, but I can not manage to make it cleanly, as the page need to refresh with the right id_customization. Any help ? Tx Link to comment Share on other sites More sharing options...
backus Posted August 23, 2018 Share Posted August 23, 2018 Hi, did you find a solution ? I'm have a same problem Tx Link to comment Share on other sites More sharing options...
pink fabb Posted May 4, 2020 Share Posted May 4, 2020 DID you find the solution for this one? Whenever customer saves his/her custom feild replies.I dont get to see that on my admin panel. IT dissappears after adding it to the CART. CUstomisation field value doesnt get saved. Please help Link to comment Share on other sites More sharing options...
hugolin69 Posted May 4, 2020 Author Share Posted May 4, 2020 Hi, Yes, I found the solution, and it is working well. It save without a save button. Here is a quick workaround for a field "Personal message" for example. But your problem seems something else. But here is a working example to have a custom field, without having to "save the textaerea manually. 1°/ You need to create for each product a customization field v"TEXT TYPE" that you name exaclty like this "{message_personnel}" 2°/ you override the Class Cart class CartController extends CartControllerCore { public function init() { parent::init(); // Send noindex to avoid ghost carts by bots header('X-Robots-Tag: noindex, nofollow', true); // Get page main parameters $this->id_product = (int)Tools::getValue('id_product', null); $this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa')); $this->customization_id = (int)Tools::getValue('id_customization'); $this->qty = abs(Tools::getValue('qty', 1)); $this->id_address_delivery = (int)Tools::getValue('id_address_delivery'); $this->preview = ('1' === Tools::getValue('preview')); $this->message_personnel = (string)Tools::getValue('message_personnel', null); if($this->message_personnel != ''){ $product = new Product((int)$this->id_product); if (!$field_ids = $product->getCustomizationFieldIds()) { }else{ // If cart has not been saved, we need to do it so that customization fields can have an id_cart // We check that the cookie exists first to avoid ghost carts if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) { $this->context->cart->add(); $this->context->cookie->id_cart = (int) $this->context->cart->id; } $authorized_text_fields = array(); foreach ($field_ids as $field_id) { if ($field_id['type'] == Product::CUSTOMIZE_TEXTFIELD) { $field_id_perso = (int) $field_id['id_customization_field']; break; } } $this->context->cart->addTextFieldToProduct($product->id, $field_id_perso, Product::CUSTOMIZE_TEXTFIELD, $this->message_personnel); $find_customization = Db::getInstance()->executeS( 'SELECT cu.`id_customization`, cd.`index`, cd.`value`, cd.`type` FROM `'._DB_PREFIX_.'customization` cu LEFT JOIN `'._DB_PREFIX_.'customized_data` cd ON cu.`id_customization` = cd.`id_customization` WHERE cu.id_cart = '.(int)$this->context->cookie->id_cart.' AND cu.id_product = '.(int)$product->id.' AND cd.type = \''.(string)Product::CUSTOMIZE_TEXTFIELD.'\' AND cd.value = \''.(string)pSQL($this->message_personnel).'\' AND cd.index = '.(int)$field_id_perso.' AND in_cart = 0' ); $this->customization_id = $find_customization[0]['id_customization']; } } } } 3°/ You add manually a field in product-add-to-cart.tpl with something like that {if $product.is_customizable && count($product.customizations.fields)} <section class="product-message-personnel"> <div class="card card-block"> <label>{l s='Personal message' d='Shop.Theme.Catalog'}</label> <textarea placeholder="{l s='Your message here' d='Shop.Forms.Help'}" class="message-personnel" maxlength="40000" name="message_personnel"></textarea> </div> </section> {/if} 4°/ In product-customization.tpl you do something like that (It is a quick dirty example) that you could use in order-confirmation-table.tpl and cart-detailed-product-line.tpl {if $field.label == '{personnel}'} <label>{l s='Personal message' d='Shop.Theme.Catalog'}</label> {else} <label>{$field.label}</label> {/if} 1 Link to comment Share on other sites More sharing options...
J.Sahu Posted July 3, 2020 Share Posted July 3, 2020 I think some more code needed to be inserted to send the message_personnel field data. Link to comment Share on other sites More sharing options...
hugolin69 Posted July 3, 2020 Author Share Posted July 3, 2020 I think that's all. When you add to cart, it sent the field "message_personnel" that is taken by $this->message_personnel = (string)Tools::getValue('message_personnel', null); Link to comment Share on other sites More sharing options...
JBW Posted July 3, 2020 Share Posted July 3, 2020 Hi, I'm currently developing a module for this. You can send me a personal message if you want to beta-test it. 1 Link to comment Share on other sites More sharing options...
J.Sahu Posted July 4, 2020 Share Posted July 4, 2020 I defined the question wrong way. How you are going to get the message_personnel field value in the cart controller if you are using ajax cart feature. I mean you are not sending that data while using ajax. Link to comment Share on other sites More sharing options...
hugolin69 Posted July 6, 2020 Author Share Posted July 6, 2020 On 7/4/2020 at 3:23 PM, J.Sahu said: I defined the question wrong way. How you are going to get the message_personnel field value in the cart controller if you are using ajax cart feature. I mean you are not sending that data while using ajax. The "message_personnel" field is near the "qty" field, that is natively sent by ajax when pushing add to cart. After that, I have the override of the Cart Class. Which point do you miss ? 1 Link to comment Share on other sites More sharing options...
J.Sahu Posted July 7, 2020 Share Posted July 7, 2020 Thank you Link to comment Share on other sites More sharing options...
JBW Posted August 6, 2020 Share Posted August 6, 2020 Hi, I finished the promised module and it is now officially released and available in the addon store: https://addons.prestashop.com/en/combinaisons-customization/49650-customization-directly-into-cart.html Link to comment Share on other sites More sharing options...
coelhoo Posted May 10, 2021 Share Posted May 10, 2021 @hugolin69Thanks a lot. It works perfectly! Thanks for giving me some hours of life back! Link to comment Share on other sites More sharing options...
hugolin69 Posted May 11, 2021 Author Share Posted May 11, 2021 Happy it has helped you. 😀 Link to comment Share on other sites More sharing options...
Kimosabe Posted December 23, 2021 Share Posted December 23, 2021 (edited) @hugolin69 Works really nice, awesome job friend! 😀 (Added some keywords below so if people google search this, it will perhaps be easier for them to find) Prestashop 1.7 save customization cart remove custom button direct without click add combination Edited December 23, 2021 by Kimosabe added some keywords so if people google search this, it will be easier for them to find (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