Using ajax in prestashop custom module, retrieve data from an input field date to a module's FrontController for exploitation and SQL query afterwards - prestashop-1.7

I need your help to understand how to retrieve the data from the product page form (product.tpl) sent by the 'add to cart' button (product-add-to-cart.tpl include).
Indeed, I would like to retrieve the value of a datepicker field, added under the entry dedicated to the quantity of the product page,
in order to save it in the ps_cart_product table.
Despite my research in the cart class and its controller, I can't do it. How to retrieve the value of an entry in the home page of a product?
A null date (0000-00-00) is however well recorded in our new columns date_retrait in ps_cart_product, we manage to recover it as you can see on a screen, but not to record it correctly.
Where can I call $_POST or REQUEST from the input datepicker name = date_retrait
(here it is 2022-07-24 but this is only a test, modified directly in the DB, normally it displays 0000-00-00)
I understood that I had to use Ajax (mymodule\/controller\/front\/ajax.php)
But I don't understand all the steps, what should I add/modify and especially: where (which files with path)?
[product_tpl][1]
[cart_popup][2]
[add to cart][3]
[ps_shoppingcart_js][4]
[1]: https://i.stack.imgur.com/MwLPS.png
[2]: https://i.stack.imgur.com/LjpMe.png
[3]: https://i.stack.imgur.com/3P4Y2.png
[4]: https://i.stack.imgur.com/z0eb4.png

Related

How to expose product data to Policy List on SPCRM

On SPCRM I'm trying to expose Product Name on the Policy List page, inside the column called: Insurance Type.
Using inspect and console tool I could not locate the missing data
I am logged in as this user:
https://spinsurance.admin.kademi.com.au/manageUsers/116783806/#summary-tab
Policy List page:
https://crm.spinsurance.co.nz/leads/?query=&leadType=active&from=0&size=100
The product data is only exposed once you click a policy (under Insurance Type section):
example: https://crm.spinsurance.co.nz/leads/148615383/
I would like to know where / how I can update the lead/policy query to also include product data (Insurance Type) within the Policy list page.
OK, so assuming you have a custom field on your journey to hold the insurance type, similar to this example which has a field called "claim_recordId"
Then the JSON response on the leads page will include that in the fields object, eg:
You can then customise the JS for the leads page to show that field in a column

Magento Custom Form in create order page

I want to add custom form in create order page in magento admin side.As per my client request i was trying to create measurements form and wanna store data.I am new to magento.Please help me.Attached image for ref.
Already posted same question in Magento Stack Exchange My Question
I created block in layout/sales.xml file and created customform.phtml.Now i'm able to display custom form.Now i want to store data along with other data in this page.
You should add a table (with order id as foreign key) or a new text field to order sales_flat_order table.
After that, you are able to catch this event: sales_order_save_after
Inside this function, you can save data to the custom table or custom field you added.
good luck.

How to add image field in dynamic input group for magento admin configuration setting?

I have created a module which add dynamic input group to magento admin configuration.
I have added image field but it can't save in database. Means if I select image than only image store in database in core_config_data — the encrypted value of row (just image field value)
If I remove image field than the data saved properly in database along with other inputs.
So here I can't save image type data with other data of dynamic input.
I've found reason + solution, maybe this is helpful for someone. Magento is using the wrong backend model. For saving images the backend model must be system_config_backend_image. But as you've added the fields dynamically (and not inside the system.xml) the fields have no assigned backend model, so magento will use the default for text values etc..
The solution is, to use the clone_fields functionality. Please find my explanation how to use it on my blog post http://www.mellority-report.com/magento-dynamic-config-fields-with-custom-backend-models/

How VirtueMart sends the data when you save the custom fields in a product

first of all, sorry for my english, but I'll try to explain myself best I can.
My question is little tricky, because I made some important changes in the core code of VirtueMart.
For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.
TIP: The admin site is in Spanish. Disponibilidad = Availability
So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.
The only field that I can change, is the field I created, the Availability (ironically).
So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?
I work with
Joomla v.2.5.11
VirtueMart 2
Thanks
The workflow is like follows,
When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.
if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');
VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);
It loading the custom model file from the same path and do the task inside saveModelCustomfields()
Hope it helps..

Joomla 2.5 - custom registration field not remembering values

Im using custom profile plugin found at http://library.logicsistemi.it/images/joomla/plg_user_testprofile.zip
I have created several fields, both, optional and required and they all work. But there is a tiny problem.
When I enter some value in that custom fields and submit the form it can happen that some fields dont pass validation (which is good). However values entered are cleared and I must fill all the fields from the beggining.
Demo: http://goo.gl/eH1G2
Enter some (not all) data under the 'legend' named User Registration
Enter some (not all) data under the 'legend' named Company
Informations
Press Register button
Error message will pop in. -
Data entered in the User Registration will be saved
Data entered in the Company Informations (which are custom fields)
will not be saved.
If all required fields are entered, form will submit data to database
(which is ok).
I want that data in the Company Informations are saved, so users dont have to type in all over again.
The problem in your demo is on the template you are using.
For some reason it gives Javascript errors. These errors blocks the Javascript client side validation and your form is submitted with invalid data.
If you want only server side validation you can modify the onContentPrepareData function in your plugin by loading posted information from the user state. To do this you have to permeform a different action when user_id is not set under "Merge the profile data." comment.
I think next week I will write a new tutorial on http://library.logicsistemi.it to explain this. For now try to fix your Javascript code.
Regards

Resources