buhoplace Posted November 21, 2015 Share Posted November 21, 2015 Hi, im developing a module, i need to create a new column in ps_cart_product and add my custom data on it, this is easy. The problem is how manage it, I cant have more of one product with same attribute_id in this table. how can i manage it? In my module, i only need put an id in this column, when a add again a product to cart, the same, it is not possible. How add custom fields to ps_cart_product when i have same product and id_product_attribute (2 quantities of product) in my table? Thanks Link to comment Share on other sites More sharing options...
jgamio Posted November 21, 2015 Share Posted November 21, 2015 I dont follow your question is your new field selected for the user or is for internal information ? but you can play with the cart on many ways 1) you can hook actionCartSave then check what is in the cart and change it , add data or change the data on the product 2) you can override the cart then add your code for example check if you dont want more than one just dont do the update 3) create a variable for the product dont allow change the quantity on the front end. 4) use the custom field hidding to save your information 5) change the jquery and the cart to add your information These changes are not to easy but you have many ways to do that Link to comment Share on other sites More sharing options...
buhoplace Posted November 21, 2015 Author Share Posted November 21, 2015 I dont follow your question is your new field selected for the user or is for internal information ? but you can play with the cart on many ways 1) you can hook actionCartSave then check what is in the cart and change it , add data or change the data on the product 2) you can override the cart then add your code for example check if you dont want more than one just dont do the update 3) create a variable for the product dont allow change the quantity on the front end. 4) use the custom field hidding to save your information 5) change the jquery and the cart to add your information These changes are not to easy but you have many ways to do that yeah, i only said what is the best and easy way for do that, i m avoiding override CartController, ajax-cart or cart class for do my module. the actual method of save ps_cart_product is complicated. My field is for both, customer and admin. I was seeing the module Atributte wizard pro, and him override many files, and change many things. i was trying not do that. I think that best form is doing a other table with relation 1-n with ps_cart_product and manage it with quantities for add custom field item, and when i remove a item on the cart, remove the last inserted in the new table. I dont know how prestashop not allow add custom fields on cart_product, i see few modules(1-2) that do that. Link to comment Share on other sites More sharing options...
jgamio Posted November 22, 2015 Share Posted November 22, 2015 Its not to complicate but is a lot job I will recommend you don't do another table if you use just is a field. You need to start to work with hooks. You cant avoid override for these kind of custom behaviour. In fact is easy if you get right function or hook. Prestashop have a lot code because try to use to many options you just need get where the process is done. For example you talking about remove your last record in your table when you remove from the cart ( I think is not the best way ) How do you think archive these ? You need to know when the cart add a item then you need or do an overrinding or use hooks Link to comment Share on other sites More sharing options...
buhoplace Posted November 22, 2015 Author Share Posted November 22, 2015 hablas español? podemos hablar en español? Link to comment Share on other sites More sharing options...
jgamio Posted November 22, 2015 Share Posted November 22, 2015 Si pero entonces deberías cambiar el tema al foro en español Link to comment Share on other sites More sharing options...
buhoplace Posted November 22, 2015 Author Share Posted November 22, 2015 Como lo muevo? no veo la opcion, o creo uno nuevo ahi? Link to comment Share on other sites More sharing options...
buhoplace Posted November 22, 2015 Author Share Posted November 22, 2015 "In updateQty in class cart, there are a hook that execute all i need"hookactionBeforeCartUpdateQty", this is not by default, and i have to create a new hook and associtate it with my module, i think that it is all i need" Thanks for your help 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