Magento Custom Address Attribute in Back-end - php

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.

Related

Wordpress checkout, modify fields content before going into db

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

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.

Magento Attribute Sort Order in Configurable Product

I need help with the following:
In Magento I have created a configurable product and assigned some simple products to it. They have an individual attribute set with individual, numeric attributes that I have created.
One attribute is for example "length". This attribute has the following values:
3,4,5,6,7,8,9,10,12,14,16,18,20
If I open the drop-down menu on the article details page, the values get displayed like that:
10,12,14,16,18,20,3,4,5,6,7,8,9
Thus, it seems that the attributes are saved as text (alphanumerical?) and not as numbers (numerical)?!
I need some advice on how I can change that. I have tried to work with "Input Validation for Store Owner" in "Manage Attributes", but that doesn't work. Is there f.e. any field in my database where I can simply switch the way my attributes are saved/displayed?
I have created many products and attributes, thus I don't want to re-create all of them again, if not necessary.
Thanks for any reply.
It has been a long time since you asked and might be you have already found a solution to it. I am just writing so that anyone coming on this page for the same problem does not have to go thru the same pain what i went thru.
When you create the attribute(length), you would have created the options (like 3/4/5.. etc) create the sort of that options in the attribute section and they will sort as per your requirement.

VirtueMart Custom Address Fields

I'm building a shipping module for Virtuemart 2 for a South African Courier Company, and I need to add a few extra fields to the addresses, and change some existing ones.
I have to add Location Type (Drop down), Building Details (Text) and pre-populate state and city with my own fields (Drop down).
I already managed to find a solution for State, as there is a database table called _virtuemart_states, and adding to that seems to work. However, that’s about as far as I get...
The extra fields should be read and saved by my shipping module for later use... And should also be saved to the address so that a client can check out later using the same address.
try this,
I think the VM2.x is already providing those option.
You can add as many as custom address fields from back end
Under configuration of VM - > Shopper Fields.
www.yousite.com/administrator/index.php?option=com_virtuemart&view=userfields
If you are planning for shipping plugin just check the code for creating custom address fields and try that in your plugin .
Hope its help you..

Magento 1.4.2.0 add custom attribute field to admin order creation page

I've recently upgraded to Magento 1.4.2.0. I have a simple custom module for keeping track of salesreps on customers and orders. Until the upgrade, it worked great, but magento 1.4.2.0 changed the way customer attributes are handled in the admin, The attribute needs to be in the customer_form_attribute table. I've run the code from this post to add the attribute to adminhtml_customer which restored the field on the customer account page, but when I added it to adminhtml_checkout it did not show up on the backend order creation page.
I can confirm the attribute IS being loaded into the $data array, and when creating an order for a customer with a salerep already assigned the salerep is copied to the quote, order, etc. but the dropdown just isn't showing up on the order creation page. And of course I checked that the fields are indeed in customer_form_attribute.
Do I need to add this to the customer forms in customer_form_attribute (customer_account_create, customer_account_edit, etc?), or should this be working as is?
Well, I've solved the problem. The answer to my last question is that yes, it should have been working as-is. My attribute didn't show up because the attribute had user_defined set to 0. Previously this didn't prevent the attribute from showing in admin, but apparently that changed between 1.4.1.1 and 1.4.2.0. I set it to 1, and the attribute showed right up where it was supposed to.

Categories