Wordpress checkout, modify fields content before going into db - php

I've add an hidden field on my checkout process plugin. I would like to programmatically change the customer phone number after he submits the order. What would be the correct hook to use, and also where I get the fields as reference, or I need to change the customers information in a different way ?
Thanks

Related

WooCommerce: Run filter inside action hook

I'm working on a payment gateway plugin for WooCommerce and I need to edit the checkout form. When the user has selected 'Sweden' as their country, and they selected 'Klarna' as their payment method, an extra input field should appear for the user's social security number (this is totally normal in Sweden, really).
As far as I understand, the woocommerce_checkout_update_order_review action gets triggered when something changes in the checkout form. I believe I can use the woocommerce_get_country_locale filter to add the social security number field for Swedish customers. So, inside my woocommerce_checkout_update_order_review hook, I want to trigger the woocommerce_get_country_locale filter. How is this done?
Thanks in advance.

magento onepage checkout manage fields

I want to show FAX field at every checkout. Right now in magento 1.9.1 there is a functionality that if you are existing user and you are giving order two or more times then it doesn't ask you to enter address everytime but it will auto fill it from database. But I want that FAX fields should always be visible to user and if he enters value then store it otherwise it should store NULL value.
Thanks in advance.
You can add field in checkout look field add in checkout.
In this link you will find jobtitle added in checkout you need to replace "job title" with "FAX".
Magento should have a fax functionality under the customer address object.
https://www.mymagento.com/index.php/admin/customer_address_attribute/
Either enable it and toggle it to required or duplicate the phone field and set it to be fax. You may need to tweak it as desired in the frontend template used: ( vanilla: app\design\frontend\base\default\template\checkout\onepage\shipping.phtml )
If you're looking to force confirmation on an existing customer address entry (fax) there may be a more extensive customization you need to do.
I would explore your onepagecheckout controller that is currently used ( vanilla: app\code\core\Mage\Checkout\controllers\OnepageController.php ) to see if any other customizations/validation is needed.

Magento Address Field not available in One Page Checkout

I have created couple of custom fields in Magento's customer addresses using a tutorial available here.
When a customer edits his/her address the fields are shown, when he is checking out through the one page checkout being logged in, the addresses appear as a drop down. In this case the address is hidden from the client using a display:none; style.
The problem is that the custom address attributes are not available but the regular attributes are available.
What I think is that when the customer is editing the address, the controller is customer and when he is on onepage the controller is checkout. There is some error or I am missing something so that the onepage controller fails to pull custom address fields.
What I have done:
I have overridden the billing.phtml file in
/app/design/frontend/base/default/template/checkout/onepage
The fields show up in the onepage checkout billing section. But when the system is loading a default address the fields values are not loaded like other values get loaded. For example, the phone number is loaded by calling the function
$this->getAddress()->getTelephone();
but when i call my custom field whose name is address_mobile like
$this->getAddress()->getAddressMobile();
The system can not pull the value, like it pulls for telephone. Below is the source code of how the field appears in hidden section.
The one step checkout does not look for any custom fields.
If you look in app / design / frontend / base / default / template / persistent / checkout / onepage / Billing.phtml
In this instance were looking at the billing address that can be changed you can also do the same for shipping if required.
What you will need to do is update the template file above ( Ideally moving it to your package under app design frontend ). This will be showing the new form fields on the checkout but it wont actually persist to the database. In order to save these values to the database you are going to need to override the OnePageController.php and the saveBilling / saveShipping methods to store your data.
If you need any more help on this let me know and I will look to find an example that you can use.

How to add an input filed to single product page in woocommerce to store extra user comments in the order?

I am using latest wp and wc and I am trying to add a form field in the frontend single product page where the user will be able to add comments which when the order is done the data will be available under woocommerce -> orders. Have anybody done that or it's not even possible because woocommerce is pretty limited for stuff like this?

Magento Custom Address Attribute in Back-end

I have created a customer address attribute in Magento called 'addresstype' that is a varchar with radio options of 'Residential' and 'Business' on the front-end.
The attribute is saved during checkout and appears in the database. Customers can edit their profiles and I can actively pull the variables using $address->getAddresstype(); to check the appropriate radio button.
My only problem is that in the back-end on individual sales order pages, the variable is not coming through. I have edited /app/code/core/Mage/Customer/Block/Address/Renderer/Default.php (using $address->getAddresstype()) and can see the attribute in the array using print_r($attributes = Mage::helper('customer/address')->getAttributes());
It is marked as 'is_visible' in the database as well.
This is because the sales order / invoice pages pull the information back from different tables (sales_flat_order_address). Assuming you have it in the right place in the first time (which it seems you do), then you just need to make Magento copy the correct information over.
<fieldsets>
<sales_convert_quote_address>
<your_attribute>
<to_order>*</to_order>
</your_attribute>
</fieldsets>
You might also have to add another field set value in to copy the value from the address to the quote address, off the top of my head I can't remember. If you search Magento's code for fieldsets in *.xml you should find examples.

Categories