Saving Custom Fields on request - php

I am new to the forum and have little time for magento development , 'm a programmer in a company and a customer states that his shop has a selection of the delivery date on the product page, add to cart before him , and that this option follow further up the order, he put into the administrator needs to manage holidays, days in advance of the application all set for a csv with her ​​affiliated stores , I managed to create a module and do it however I ended up with a big problem , I can not save the two fields that need to save are in the product page ( zip code and date) in the order in theory would be fields that can be changed like the qty ( quantity) and would have to be transferred to the session / cookie yet saved, and this is the big problem , unable to somehow save these fields , in practice I would have to double the qty field changing its name and save it in the application ( creating a new field in db ) this was the only solution I found but still unable .
This is a link to a product in the store with two fields : "http://foxflores.com.br/inde.php/caixa-de-chocolates-ferrero-rocher-super-luxo"
someone would have a light for me to save these fields in order?

If I understand your problem correctly, then you added that two fields, to the template only yet. And you want to save those two fields, against the items, as I assume the customer could add to the cart multiple items also.
The easiest solution is, that you create for the products, two custom options in the backend (Magento), you hide those fields, in the template with css, and write the value of your custom fields into them.(You can do this with js). Let me know if you need a help with the js.
With this, your fields values will be saved against each orderitem, in magento.
EDIT on 12/02/2014
Yes, you can add the custom option in the Magento admin , Manage product section. See image.
After this is added: You can add something like this to the frontend to copy over the values, from your custom field, to this newly generated fields.
$('options_1_text').observe(
'change', function () {
var val = this.value;
$("yourcustomfieldid1").value=val;
});
Of course you need to edit the element ids to get it working. And you need to hide the newly created fields on the frontend.
Hope this helps!

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

Dynamically pass a Product ID as the main Product Field on a Gravity Form (Product Add On)

I've got a great form set up to allow the building of a complex product and then add it to the cart (using the GForms Product Add on). All lif this is perfect on the actual Woocommerce product page.
What I'd love to do is have this form embedded on a page and populate the Product ID dynamically, so that the form still picks up the product details and will add the new Item to the cart just as it does on a shop page. Having it on its own page (or on any page of the site) will allow us to offer a larger, focused experience to select all the options.
I've been looking into the code and the docs but I can't seem to make it work. The code references product_id everywhere, but the dynamic field option is name. So is this possible? Thanks!
If the data you are attempting to map is simple then the following snippet plus Gravity Forms default {embed_post} and {custom_field} merge tags can get you there:
https://gravitywiz.com/dynamic-products-via-post-meta/
If your data is more advanced (like mapping product attributes), check out Gravity Form Populate Anything:
https://gravitywiz.com/documentation/gravity-forms-populate-anything/

Brand and local products in single category magento

I am working on magento project where I need two tabs on category page named "brand","local" just like http://www.fashionara.com/men/tees-polos.html .Can someone please guide me how can I do that ? any help will be highly appreciated.
Thanks,
Irphan
To filter products and come with a collection using product attributes is the best way.
You create an attribute is_branded for product. While products data entry is done make sure you fill this value with Yes or No.
Now use this in your collection as filter.
make sure this attribute is configured to be filterable.As you need this in flat table.
Other option is that when flat table is being populated you populate an additional field(is_branded) so not data entry is needed.
Or when a product is being created then using some before save event observer make out whether its branded or local and populate this value so as to be saved when product is saved.

Creating a new product while creating a new order and also add that product in order

Is it possible, in Magento, to build a button to add a new simple product while creating an order in the backend?
It is not important that the product would be saved in the catalog: it should to be saved into the order. Only two of the product's attributes would be needed: name and tax rate (optionally others). Qty e price could be edited from the order cart.
Yes, it's posible, you need a controller in order to do that.
Remember that you need to provide us the code that you're working on, and don't expect that we program all for you.
Thanks
Thanks to Beto Castillo I went into the spirit to think more clearly about this. The project is yet under construction. Anyway starting steps could be:
Create the right inputs to add a new product in a ChildHtml of sales/order/create/data.phtml, and adjust the layout files. Along with the inputs there will be a button to trigger the creation of the product. In one of this inputs I have to load options for tax rates.
There is plenty of ways to create a new product, i.e. Magento: Adding new products programmatically. I just need to get the above inputs.
The product should be added to order quotes in the database (I could start with this: Create order programmatically in Magento)
Update the create order view, calling an ajax function to reload the item grid. Part of the code already exists in Magento. All this steps should be packed into the same ajax call: here comes the controller action named by Beto Castillo.
So the answer is yes, it is possible.

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