WordPress - Contact Form 7
I am trying to find out the filter to modify the cf7 field value when someone enter values in it.
when user type in textfield and submit data,
validate - I had done
should not goto thank you page if invalid entry - I had done
replace text field with new data - Not Done
Eg: 1
add_filter( 'wpcf7_validate_text*', 'your_validation_filter_func_tel', 100, 2 );
function your_validation_filter_func_tel( $result, $tag ) {
$Yourvalue = $_POST['your-number'];
if ( strlen( $Yourvalue ) == 2 ) {
$result->invalidate( 'your-number', "Please enter a valid number. " . );
// HERE I WANT TO REPLACE NEW DATA TO TEXT FIELD
$result->data( 'your-number', '1002' );
} else if ( strlen( $Yourvalue ) == 3 ) {
$result->invalidate( 'your-number', "Please enter a valid name." . );
// HERE I WANT TO REPLACE NEW DATA TO TEXT FIELD
$result->data( 'your-number', '1003' );
}
return $result;
}
Eg: 2
another working example
everything working except $result['tel'] = $tel_cleaned_final;
<?php
function custom_filter_wpcf7_is_tel( $result, $tel )
{
// Initialization and Clean Input
$tel_cleaned = strtr( $tel, array(' '=>'', '-'=>'', '.'=>''));
$tel_cleaned_trimmed = ltrim(strtr( $tel_cleaned, array('+'=>'')), '0');
/* Test Conditions.
I concluded 3 if conditions to 1 below bcaz the validation is working perfect
*/
if ('test conditions here')
$tel_cleaned_final = substr($tel_cleaned_trimmed, 2);
else
$tel_cleaned_final = $tel_cleaned_trimmed;
if (strlen($tel_cleaned_final) == 10)
{
$result = true;
//$result['tel'] = $tel_cleaned_final;
/*
Here i want to return new number to text box
for eg: +91 98989-89898 returns 9898989898
*/
}
else
{
$result = false;
}
return $result;
}
add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 );
?>
What you are trying to do cannot be done with only the validation filter. Because that just outputs true or false based on the validations performed. To do what you want, you have to use another filter ( 'wpcf7_posted_data' ) that has the value you want to filter. So we can break down our process into two steps.
Step 1: Do all the validation like you are currently doing.
Using your Example 2.
function custom_filter_wpcf7_is_tel( $result, $tel )
{
// Initialization and Clean Input
$tel_cleaned = strtr( $tel, array(' '=>'', '-'=>'', '.'=>''));
$tel_cleaned_trimmed = ltrim(strtr( $tel_cleaned, array('+'=>'')), '0');
/* Test Conditions.
I concluded 3 if conditions to 1 below bcaz the validation is working perfect
*/
if ('test conditions here')
$tel_cleaned_final = substr($tel_cleaned_trimmed, 2);
else
$tel_cleaned_final = $tel_cleaned_trimmed;
if (strlen($tel_cleaned_final) == 10)
{
$result = true;
} else
{
$result = false;
}
return $result;
}
add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 );
The above code will make sure that your points 1 and 2 are working.
Validate.
Stop submission if entry is invalid.
Step 2: Re-run your tests to get the desired value and update it.
function sr_change_updated_field_value( $posted_data )
{
// Initialization and Clean Input
$tel_cleaned = strtr( $tel, array(' '=>'', '-'=>'', '.'=>''));
$tel_cleaned_trimmed = ltrim(strtr( $tel_cleaned, array('+'=>'')), '0');
/* Test Conditions.
I concluded 3 if conditions to 1 below bcaz the validation is working perfect
*/
if ('test conditions here')
$tel_cleaned_final = substr($tel_cleaned_trimmed, 2);
else
$tel_cleaned_final = $tel_cleaned_trimmed;
// Use the name of your field in place of "tel"
$posted_data['tel'] = $tel_cleaned_final;
return $posted_data;
};
add_filter( 'wpcf7_posted_data', 'sr_change_updated_field_value', 10, 1 );
P.S. This will update the values sent in the email, or in the submissions if you store them. It will show the validation message, but it will not show the updated value in text field because that cannot be done with php in this scenario.
P.S. 2 This is all tested code. Happy Coding.
maybe this can help:
add_action( 'wpcf7_before_send_mail', 'some_function_name', 1 );
function some_function_name( $contact_form ) {
$wpcf7 = WPCF7_ContactForm::get_current();
$submission = WPCF7_Submission::get_instance();
if ($submission) {
$data = array();
$data['posted_data'] = $submission->get_posted_data();
$firstName = $data['posted_data']['first-name']; // just enter the field name here
$mail = $wpcf7->prop('mail');
if($firstName =''){
$mail['body'] = str_replace('[first-name]', $firstName . '-blah blah', $mail['body']);
}
$wpcf7->set_properties(array(
"mail" => $mail
));
return $wpcf7;
}
}
Hope it helps!
P.S. This is not tested, please let me know if it works :)
Related
I am trying to implement the Paypal payment gateway once the contact form is submitted.
For that I am storing the form data in db and retrieving data from the saved id once payment is completed. Saving that db id in hidden field for sending to paypal url.
I have tried and values are returned. But when I getting form data in wpcf7mailsent it is empty.
function action_wpcf7_submit( $array ) {
global $wpdb;
$wpcf7 = WPCF7_ContactForm::get_current();
$form_id = $wpcf7->id;
$submission = WPCF7_Submission::get_instance();
$invalid_fields = $submission->get_invalid_fields();
$posted_data = $submission->get_posted_data();
if ($form_id ==123 && empty($invalid_fields))
{
$first_name = $posted_data['first-name'];
$last_name = $posted_data['last-name'];
$parent_email = $posted_data['parent-email'];
$parent_phone = $posted_data['parent-phone'];
$duration = $posted_data['Duration'][0];
$total_price = $posted_data['total_price'];
$notes_requests = $posted_data['notes-requests'];
$studentcount = $posted_data['studentcount'];
$table_name = "store_subscription";
$result_check = $wpdb->insert($table_name, array('parent_guardian_firstname' => $first_name, 'parent_guardian_lastname' => $last_name, 'parent_guardian_email' => $parent_email,'parent_guardian_phone' => $parent_phone, 'subscription_duration' => $duration, 'total_price' => $total_price, 'notes_special_request' => $notes_requests) );
$lastid = $wpdb->insert_id;
if($result_check){
for($i=1;$i<=$studentcount;$i++){
$add_student_name = $posted_data['student_name_'.$i];
$add_current_grade_level = $posted_data['current_grade_level_'.$i];
$additional_student_table = "store_subscription_student";
if(!empty($add_student_name)){
$wpdb->insert($additional_student_table, array('store_subscription_id'=> $lastid, 'student_name' => $add_student_name, 'grade_level' => $add_current_grade_level));
}
}
//setting the store_subscriptin_id to retrieve the data from the paypal.
$posted_data['store_subscription_id'] = $lastid;
$posted_data['paypal_pg_redirect_url'] = "https://www.example.com/redirect-paypal/?id=$lastid&amt=$total_price";
return $posted_data;
}
}
}
add_filter( 'wpcf7_submit', 'action_wpcf7_submit');
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( e ) {
console.log(e.detail);
if ( '123' == e.detail.contactFormId ) {
var paypal_pg_redirect_url = document.getElementById('paypal_pg_redirect_url').value;
console.log(paypal_pg_redirect_url);
///window.location.href = paypal_pg_redirect_url;
}
}, false );
</script>
<?php
}
The hidden field value is not set. Can someone help me to set the hidden field value and retrieve in wpcf7mailsent
Note: I have tried hook before_send_mail, later came to know that we cant change the value in before_send_mail. So then I tried posted_data hook also the value not set to hidden field. store_subscription_id is the hidden field I am trying to set value. Pls help.
Maybe try adding if(isset()) before setting the value:
if(isset($lastid)){
$posted_data['store_subscription_id'] = $lastid;
}
I need to send a full array of custom field to a mail (dynamicaly populate) with contact Form 7 to work it here before sending :
// define the wpcf7_posted_data callback
function action_wpcf7_posted_data($array)
{
$a = get_field('date')
//WORK HERE
$array['Nom & Prénom'] = $array['name'];
unset($array['name']);
$array['E-mail'] = $array['email'];
unset($array['email']);
$array['Téléphone'] = $array['tel'];
unset($array['tel']);
$array['Profession'] = $array['job'];
unset($array['job']);
$array['Session'] = $array['upcoming-gigs'];
unset($array['upcoming-gigs']);
unset($array['privacy']);
return $array;
}
add_filter('wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1);
Because it's before sending a mail I can't call anything to compare before sending.
So I want to send all the data in a hidden input next to compare it.
This the two input in contact Form 7 :
[select upcoming-gigs data:gigs id:date] [hidden select upcoming-gigs2 data:gigs2]
My goal here is to send all the data of the hidden select.
I don't find a way to send all input in the mail.
Is it possible ? There is a better way ?
Thx
EDIT :
My question mark2 :
The goal is to send a mail with the date of the session and the id of it.
I use ACF and I have :
And after a dynamic dropdown, it's look like this for the user :
The problem is I don't have the id of the session, only the date.
To know the id I need to compar to the array of all the custom field, I can't import it during wpcf7_posted_data.
I think if I send all the data of the array in a hidden field, I could remake the array and find the id of the session my user choose.
I hope I'm clearer.
(I can't make a request in php during wpcf7_posted_data. Can I make an ajax request ?)
EDIT2 :
This my hidden select with session and text
This is the html of contact form 7 the rest is div for CSS
[select upcoming-date data:date id:date] [hidden select upcoming-date2 data:date2]
EDIT3 :
Okay get it.
The custom fields I use to make the dropdown are in two part id and text. I have the text part I need the id.
If I send every text and id in the mail I can compare to the answer of the user et add to the mail the right id.
Here the generated html : http://www.sharemycode.fr/5ax
EDIT 4 :
That where I write the id and text of the dropdown :
That where I create the select :
add_filter('wpcf7_form_tag_data_option', function ($n, $options, $args) {
$ses = (array)get_field('date_new');
$sesCount = count($ses);
$gigs = [];
$gigs2 = [];
if (in_array('gigs', $options)) {
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'] ." | bla";
array_push($gigs, $a);
}
}
return $gigs;
}
}
It looks like this is supported by Contact Form 7 natively, it's just not very obvious on how to make it happen.
Here's a documentation page explaining the functionality: http://contactform7.com/selectable-recipient-with-pipes/
Basically all you have to do is put the values like so:
Visible Value|actual-form-value
What comes before the pipe "|" character will be shown in the form, and what comes after will be the actual value filled in for the form.
EDIT kanarpp :
I add my code here to separate the answer of HowardE.
This is how I dynamicaly create my select :
add_filter('wpcf7_form_tag_data_option', function ($n, $options, $args) {
$ses = (array)get_field('date');
$sesCount = count($ses);
$date= [];
if (in_array('date', $options)) {
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'] ." | bla";
array_push($date, $a);
}
}
return $date;
}
It's not working, I use Smart Grid-Layout Design for Contact Form 7 to create dynmicaly my select
I would create a custom form tag for the select. The following code will create a custom form tag called [gigs] which would be used like this:
[gigs upcoming-gigs]
I've also included ability to add the * and make it required.
My assumptions are how you're actually getting the ACF fields, which I can't actually do, since I don't have them, and you haven't completely shared how it's stored. You would add this to your functions.php.
add_action('wpcf7_init', function (){
wpcf7_add_form_tag( array('gigs', 'gigs*'), 'dd_cf7_upcoming_gigs' , array('name-attr' => true) );
});
function dd_cf7_upcoming_gigs($tag) {
if ( empty( $tag->name ) ) {
return '';
}
$validation_error = wpcf7_get_validation_error( $tag->name );
$class = wpcf7_form_controls_class( $tag->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option( $class );
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
if ( $tag->is_required() ) {
$atts['aria-required'] = 'true';
}
if ( $validation_error ) {
$atts['aria-invalid'] = 'true';
$atts['aria-describedby'] = wpcf7_get_validation_error_reference(
$tag->name
);
} else {
$atts['aria-invalid'] = 'false';
}
// Make first option unselected and please choose
$html = '<option value="">- - '. __('Please Choose', 'text-domain'). ' - -</option>';
// This part you may have to update with your custom fields
$ses = (array)get_field('date_new');
$sesCount = count($ses);
for ($i = 0; $i < $sesCount; $i++) {
if ($ses[$i]['date_start'] > date('d-m-Y', time())) {
$a = "A réaliser entre le " . $ses[$i]['date_start'] . " et le " . $ses[$i]['date_end'];
// if session ID is in fact $ses[$i]['session']
$html .= sprintf( '<option %1$s>%2$s</option>',
$ses[$i]['session'], $a );
}
}
foreach ($gigs as $key => $value){
$html .= sprintf( '<option %1$s>%2$s</option>',
$key, $value );
}
$atts['name'] = $tag->name;
$atts = wpcf7_format_atts( $atts );
$html = sprintf(
'<span class="wpcf7-form-control-wrap %1$s"><select %2$s>%3$s</select>%4$s</span>',
sanitize_html_class( $tag->name ), $atts, $html, $validation_error
);
return $html;
}
add_filter( 'wpcf7_validate_gigs', 'dd_validate_gigs_filter', 10, 2 );
add_filter( 'wpcf7_validate_gigs*', 'dd_validate_gigs_filter', 10, 2 );
function dd_validate_gigs_filter( $result, $tag ) {
$name = $tag->name;
$has_value = isset( $_POST[$name] ) && '' !== $_POST[$name];
if ( $has_value and $tag->has_option( 'multiple' ) ) {
$vals = array_filter( (array) $_POST[$name], function( $val ) {
return '' !== $val;
} );
$has_value = ! empty( $vals );
}
if ( $tag->is_required() and ! $has_value ) {
$result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
}
return $result;
}
I am using contact form 7 plugin for form submission and storing data by using contact-form-7-to-database-extension. by using below code it is checking whether the email exist previously or not but I want to check with only previous 6 months of data, not complete data
function is_already_submitted($formName, $fieldName, $fieldValue) {
require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
$exp = new CFDBFormIterator();
$atts = array();
$atts['show'] = $fieldName;
$atts['filter'] = "$fieldName=$fieldValue";
$atts['unbuffered'] = 'true';
$exp->export($formName, $atts);
$found = false;
while ($row = $exp->nextRow()) {
$found = true;
}
return $found;
}
/**
* #param $result WPCF7_Validation
* #param $tag array
* #return WPCF7_Validation
*/
function my_validate_email($result, $tag) {
$formName = 'Career Form'; // Change to name of the form containing this field
$fieldName = 'email'; // Change to your form's unique field name
$errorMessage = 'Email has already been submitted'; // Change to your error message
$name = $tag['name'];
if ($name == $fieldName) {
if (is_already_submitted($formName, $fieldName, $_POST[$name])) {
$result->invalidate($tag, $errorMessage);
}
}
return $result;
}
// use the next line if your field is a **required email** field on your form
add_filter('wpcf7_validate_email*', 'my_validate_email', 10, 2);
// use the next line if your field is an **email** field not required on your form
add_filter('wpcf7_validate_email', 'my_validate_email', 10, 2);
// use the next line if your field is a **required text** field
add_filter('wpcf7_validate_text*', 'my_validate_email', 10, 2);
// use the next line if your field is a **text** field field not required on your form
add_filter('wpcf7_validate_text', 'my_validate_email', 10, 2);
please help me how to get previous 6 months mail and check
We have a gravity form in 4 parts.
1. Input an Australian postcode
2. Select swimming pool dimensions
3. Select accessories
4. Show quotation, prompt for contact details.
In functions.php we have defined a few global symbols. $PostCode is set to the value of the postcode value that is entered on page 1. Once $PostCode is > 0 we include a php file. This file contains a large array of freight charges indexed by the postcode. The postcode-specific charges are transferred to hidden fields on page 2 of the form and are used for later calculations.
Along with the freight charges is a formula. This formula is evaluated using data from the hidden fields on page 2 and also from a number field on page 2 that calculates the pool area from entry fields of length and width.
The result of the evaluation of the formula should be entered into a field on page 3 for use in other calculations. It is at this point that a problem is encountered, namely that the receiving hidden field is not updated.
Code:
// global symbols
$Formula1 = '';
$TNTFreightPrices = array();
$FieldNumberContent = array();
$PostCode = '';
$Formula1Result = 0;
add_filter('gform_field_input_11', 'update_hidden', 10, 5);
function update_hidden($input, $field, $value, $lead_id, $form_id)
{
global $TNTFreightPrices, $FieldNumberContent, $Formula1, $PostCode, $Formula1Result;
$pgno = $field['pageNumber'];
$PostCode = rgpost("input_3");
if (!empty($PostCode)) {
$path = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/uploads/tntfreightprices/TNTFreightPrices.php';
$tmp = include_once $path;
if (gettype($tmp) == "array") {
$TNTFreightPrices = $tmp['postcodes'];
$Formula1 = $tmp['Formula1'];
$f = $form_id;
$BasicChrg = $TNTFreightPrices[$PostCode]['BasicChrg'];
$KgChrg = $TNTFreightPrices[$PostCode]['KgChrg'];
$MinChrg = $TNTFreightPrices[$PostCode]['MinChrg'];
$RemotAreaChrg = $TNTFreightPrices[$PostCode]['RemotAreaChrg'];
$ResidChrg = $TNTFreightPrices[$PostCode]['ResidChrg'];
$_0to15Chrg = $TNTFreightPrices[$PostCode]['0to15Chrg'];
$_15to199Chrg = $TNTFreightPrices[$PostCode]['15to199Chrg'];
$_200to299Chrg = $TNTFreightPrices[$PostCode]['200to299Chrg'];
$_300to399Chrg = $TNTFreightPrices[$PostCode]['300to399Chrg'];
$_400to499Chrg = $TNTFreightPrices[$PostCode]['400to499Chrg'];
$_500to599Chrg = $TNTFreightPrices[$PostCode]['500to599Chrg'];
$_600plusChrg = $TNTFreightPrices[$PostCode]['600plusChrg'];
$FuelSurchrg = $TNTFreightPrices[$PostCode]['FuelSurchrg'];
$FieldNumberContent = array(
'85' => Content_tag(
"input", "",
array(
"id" => "input_{$f}_85",
"class" => "gform_hidden",
"name" => "input_85",
"aria-invalid" => "false",
"value" => "$BasicChrg",
"type" => "hidden")
),
// ...
The Content_tag function is not shown. It generates HTML to set the value of the hidden fields on page 2. An example of its output is
input id="input_11_85" class="gform_hidden" name="input_85" aria-invalid="false" value="9.33" type="hidden">
These values are stored in the $FieldNumberContent array and are returned to the caller depending on the field_id, viz
$fid = $field['id'];
if (array_key_exists($fid, $FieldNumberContent)) {
$input = $FieldNumberContent[$fid];
}
The update_hidden function ends with
return $input;
}
The next block of code takes the values of the hidden fields on page 2 and the result of the area calculation, also on page 2 and replaces the matching values in the formula stored in $Formula1, finally eval'ing the string and storing its result in the global $Formula1Result.
add_filter('gform_field_value', 'populate_fields_into_formula1', 10, 3);
function populate_fields_into_formula1( $value, $field, $name )
{
global $Formula1, $PostCode, $TNTFreightPrices, $Formula1Result;
if (array_key_exists($PostCode, $TNTFreightPrices) ) {
$fid = $field['id'];
if (strpos($Formula1, "[") !== false) {
$sym = "[{$field['label']}]";
$val = rgpost("input_{$fid}");
$Formula1 = str_replace($sym, $val, $Formula1);
} else {
$f1 = "return {$Formula1};";
$f1 = str_replace(",", "", $f1);
$Formula1Result = eval($f1);
}
}
return $value;
}
An example formula is
[AreaCalculator]/2 * [KgChrg] >= [MinChrg] ? [AreaCalculator]/2 * [KgChrg] : [MinChrg]
Finally here's the code that is supposed to updating the field hidden field on page 3. We clicked the checkbox allowing the field to be updated dynamically and gave the parameter name as formula1result.
add_filter('gform_field_value_formula1result', 'populate_formula1result', 10, 3);
function populate_formula1result($value, $field, $name)
{
global $Formula1Result;
if ($Formula1Result > 0) {
$value = $Formula1Result;
}
return $value;
}
Now I confess up front that I am not a particularly adept PHP programmer. Perhaps there is a better way of doing all this, and believe me I am all ears.
But I've been metaphorically hitting my head against this for a day or more. Everything else appears to be working. It's only this that's not Why?
I'm working with woocommerce to build a webshop. I've customized the order of the billing address fields. The problem is, some countries still display a different order. How can I force the custom order for all countries?
EDIT:
<?php
/*
* Modifing the order of form fields.
* More information here: http://www.trottyzone.com/change-order-of-woocommerce-fields-on-checkout-page/
*/
add_filter('woocommerce_checkout_fields','reorder_woo_fields');
function reorder_woo_fields($fields) {
//move these around in the order you'd like
$fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name'];
$fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name'];
$fields2['billing']['billing_email'] = $fields['billing']['billing_email'];
$fields2['billing']['billing_company'] = $fields['billing']['billing_company'];
$fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1'];
$fields2['billing']['billing_postcode'] = $fields['billing']['billing_postcode'];
$fields2['billing']['billing_city'] = $fields['billing']['billing_city'];
$fields2['billing']['billing_country'] = $fields['billing']['billing_country'];
$fields2['billing']['billing_state'] = $fields['billing']['billing_state'];
$fields2['billing']['billing_phone'] = $fields['billing']['billing_phone'];
$fields2['shipping']['shipping_first_name'] = $fields['shipping']['shipping_first_name'];
$fields2['shipping']['shipping_last_name'] = $fields['shipping']['shipping_last_name'];
$fields2['shipping']['shipping_email'] = $fields['shipping']['shipping_email'];
$fields2['shipping']['shipping_company'] = $fields['shipping']['shipping_company'];
$fields2['shipping']['shipping_address_1'] = $fields['shipping']['shipping_address_1'];
$fields2['shipping']['shipping_postcode'] = $fields['shipping']['shipping_postcode'];
$fields2['shipping']['shipping_city'] = $fields['shipping']['shipping_city'];
$fields2['shipping']['shipping_country'] = $fields['shipping']['shipping_country'];
$fields2['shipping']['shipping_state'] = $fields['shipping']['shipping_state'];
$fields2['shipping']['shipping_phone'] = $fields['shipping']['shipping_phone'];
//just copying these keeps the standard order
$fields2['account'] = $fields['account'];
$fields2['order'] = $fields['order'];
return $fields2;
}
?>
Check the woocommerce class-wc-countries.php file there it sets the locale. I think your problem can solved by the following code
add_filter( 'woocommerce_get_country_locale', 'use_only_default_locale' );
function use_only_default_locale( $locale ) {
return array();
}
EDIT:
Try this code
add_filter( 'woocommerce_default_address_fields', 'my_default_address_fields' );
function my_default_address_fields( $fields ) {
//move these around in the order you'd like
$fields2['first_name'] = $fields['first_name'];
$fields2['last_name'] = $fields['last_name'];
$fields2['email'] = $fields['email'];
$fields2['company'] = $fields['company'];
$fields2['address_1'] = $fields['address_1'];
$fields2['postcode'] = $fields['postcode'];
$fields2['city'] = $fields['city'];
$fields2['city']['label'] = 'City';
$fields2['city']['placeholder'] = 'City';
$fields2['country'] = $fields['country'];
$fields2['state'] = $fields['state'];
$fields2['phone'] = $fields['phone'];
return $fields2;
}
comment out add_filter('woocommerce_checkout_fields','reorder_woo_fields');
You need to change the field classes a bit to fill properly.
By using the woocommerce_checkout_fields filter you have full controll of the checkout fields.
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
//Minipulate the `$fields` vaiable and return it
$fields['order']['order_comments']['placeholder'] = 'My new placeholder';
return $fields;
}
See the docs for more information: http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters