Tuni-Soft Posted August 15, 2016 Share Posted August 15, 2016 Hello, As you might know, the customization system has been modified in PrestaShop 1.7 Now customizations can have a price and weight impact much like product combinations. This makes it easier for modules to include custom data in the client cart.Plus, each customization will be displayed on a row of its own. What has changed: The table structure of `ps_customization_field`A new column was added: `is_module` which means that the field belongs to a moduleWhen this column has a value of 1, the field won't be displayed on the frontMake sure to set the value to 1 if your module creates a custom field for the productYour module can set the value of the input `#product_customization_id` to include the customization in the cartIdeal scenario:- The client makes a customization and saves it via ajax- Your module returns an `id_customization` and puts it in `#product_customization_id`- Your module clicks the add to cart button The table structure of `ps_customized_data`New columns: `id_module`, `price`, `weight`When you save a customization, set the `id_module` to the value of your module IDSet the `price` and `weight` to the corresponding price & weight of the customizationSet the `value` to a row ID in your module's custom table where extra data about the customization is storedWhen PrestaShop system finds a customization that has an `id_module` it will trigger a hookThis hook will be only passed to the concerned module (having an ID equal to the value in `id_module`)More on the hook below.. Saving the customizationWhen saving the customization, set the quantity to 0. It will be updated by PrestaShop when the product is added to cart. In fact, the customization will always have the same quantity as the product row because each customization will be assigned to a separate product row in the cart. Using the new hookThis how to register the new hook $this->registerHook('displayCustomization') You can alter the displayed customization by returning some content related to the `value` (html allowed) public function hookDisplayCustomization($params) { $id_row = (int)$params['customization']['value']; return $this->functionToDisplayASummaryOf($id_row); } Changes on methodsHere are some method which were modified (Declaration And/Or Body) Product::getPriceStatic Product::getAllCustomizedDatas I hope this is helpful if you're developing a new module or adapting your module for PrestaShop 1.7. Feel free to ask if you encounter any difficulty. Your feedback will improve this guide. 8 Link to comment Share on other sites More sharing options...
phinq1910 Posted April 24, 2017 Share Posted April 24, 2017 Hi, I put the code but seems it is incorrect. Please help. Can you show the functionToDisplayASummaryOf function code? My code: public function hookDisplayCustomization($params) { //print_r($params); $id_row = (int)$params['customization']['value']; //print_r($id_row); //return $this->functionToDisplayASummaryOf($id_row); //echo 'text display here'; return 'text display here'; } Ofcourse, I have reg this hook $this->registerHook('displayCustomization') My question: Why the code in function hookDisplayCustomization can not run? (I try print or echo but nothing to display) Thanks Link to comment Share on other sites More sharing options...
phinq1910 Posted April 24, 2017 Share Posted April 24, 2017 I am sloved. Because I am not re-install module, so the hook can not execute. Thanks Link to comment Share on other sites More sharing options...
rever5e Posted August 7, 2018 Share Posted August 7, 2018 I'm not seeing any way here to associate a price with a customization as there are no hooks or methods in core classes to save the price. Link to comment Share on other sites More sharing options...
Tuni-Soft Posted August 10, 2018 Author Share Posted August 10, 2018 On 07/08/2018 at 3:14 PM, rever5e said: I'm not seeing any way here to associate a price with a customization as there are no hooks or methods in core classes to save the price. Hi, It can be done if you save the customization programmatically I didn't try hooking into the customization save process Best regards Link to comment Share on other sites More sharing options...
GuerreraStyle Posted September 14, 2018 Share Posted September 14, 2018 Can I add a required/obligatory customization (with file upload) just to certain combinations and not just to the whole product itself? If not, is there any module that can do it? Link to comment Share on other sites More sharing options...
cfr55 Posted January 19, 2019 Share Posted January 19, 2019 En 15/8/2016 a las 2:38 PM, Tuni-Soft dijo: Hello, As you might know, the customization system has been modified in PrestaShop 1.7 Now customizations can have a price and weight impact much like product combinations. This makes it easier for modules to include custom data in the client cart. Plus, each customization will be displayed on a row of its own. What has changed: The table structure of `ps_customization_field` A new column was added: `is_module` which means that the field belongs to a module When this column has a value of 1, the field won't be displayed on the front Make sure to set the value to 1 if your module creates a custom field for the product Your module can set the value of the input `#product_customization_id` to include the customization in the cart Ideal scenario: - The client makes a customization and saves it via ajax - Your module returns an `id_customization` and puts it in `#product_customization_id` - Your module clicks the add to cart button The table structure of `ps_customized_data` New columns: `id_module`, `price`, `weight` When you save a customization, set the `id_module` to the value of your module ID Set the `price` and `weight` to the corresponding price & weight of the customization Set the `value` to a row ID in your module's custom table where extra data about the customization is stored When PrestaShop system finds a customization that has an `id_module` it will trigger a hook This hook will be only passed to the concerned module (having an ID equal to the value in `id_module`) More on the hook below.. Saving the customization When saving the customization, set the quantity to 0. It will be updated by PrestaShop when the product is added to cart. In fact, the customization will always have the same quantity as the product row because each customization will be assigned to a separate product row in the cart. Using the new hook This how to register the new hook $this->registerHook('displayCustomization') You can alter the displayed customization by returning some content related to the `value` (html allowed) public function hookDisplayCustomization($params) { $id_row = (int)$params['customization']['value']; return $this->functionToDisplayASummaryOf($id_row); } Changes on methods Here are some method which were modified (Declaration And/Or Body) Product::getPriceStatic Product::getAllCustomizedDatas I hope this is helpful if you're developing a new module or adapting your module for PrestaShop 1.7. Feel free to ask if you encounter any difficulty. Your feedback will improve this guide. I am creating a module of customization and I don't understand de mechanic of this tables. For example where is the input #product_customization_id ? I don't know how integrate my customization on the chart. Now I make the customization for the product and in the product page I have de id of this customization but I don't know how to continue... Link to comment Share on other sites More sharing options...
vivianne Posted November 28, 2019 Share Posted November 28, 2019 I added some customization fields to my products. And now, if I add an order via the BO it always puts 2 items in the cart instead of 1. Does someone know why this is happening in the BO? Link to comment Share on other sites More sharing options...
phinq1910 Posted December 2, 2019 Share Posted December 2, 2019 The hook ActionCartSave will run 2 times :). That hook added for both action add new and update cart on prestashop core. You can try solution: - Try update again your cart - Remove old cart then add insert new by manual - override or make new controll for that Link to comment Share on other sites More sharing options...
num47 Posted April 8, 2021 Share Posted April 8, 2021 Anyone here have any idea how can i change the position of Customization field and put it below of the every combinations of that product. Link to comment Share on other sites More sharing options...
Tuni-Soft Posted April 8, 2021 Author Share Posted April 8, 2021 Hello, Your question is not directly related to this subject You can move the blocks in the theme template Look for blocks product_variants and product_customization in the file /themes/[theme]/templates/catalog/product.tpl Cheers 1 Link to comment Share on other sites More sharing options...
Alcino Posted June 28, 2023 Share Posted June 28, 2023 Hi there, Is html no longer allowed as customization data in PS 1.7.8.9 ? I am trying to return html, but it is being escaped somehow, see screenshot below: 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