I need to display on my single page, each taxonomy name and image.
i have 10 different image for taxonomy : 'brique'
It's ok for the name but i can't display image
For the image
<?php
$tax = 'brique';
$terms = get_terms( $tax, $args = array(
'hide_empty' => false, // do not hide empty terms
));
foreach( $terms as $term ) {
$term_link = get_term_link( $term );
$image = get_field('visuel' . $term_id );
if( $term->count > 0 ) {
echo '<a href="' . esc_url( $term_link ) . '">';
echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] .'">';
echo $term->name .'</a>';
} elseif( $term->count !== 0 ) {
echo '' . $term->name .'';
}
}
?>
Try the below code. first, you need to pass taxonomy Since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument in the $args array: you can check here get_terms()
in get_field you have pass second parameter as term_id or $term object
<?php
$tax = 'brique';
$terms = get_terms( array(
'taxonomy' => $tax,
'hide_empty' => false,
) );
foreach( $terms as $term ) {
$term_link = get_term_link( $term );
$image = get_field( 'visuel', $term );
if( $term->count > 0 ) {
echo '<a href="' . esc_url( $term_link ) . '">';
echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] .'">';
echo $term->name .'</a>';
} elseif( $term->count !== 0 ) {
echo '' . $term->name .'';
}
}
?>
I want to display some information about the user using function new WP_User_Query
"umeta_id": "606",
"user_id": "18",
"meta_key": "facebook_login_data",
"meta_value": "a:24:{s:10:\"identifier\";s:16:\"XXXXX\";s:10:\"webSiteURL\";s:0:\"\";s:10:\"profileURL\";s:61:\"https://www.facebook.com/app_scoped_user_id/XXXXXX/\";s:8:\"photoURL\";s:72:\"https://graph.facebook.com/XXXXXX/picture?width=150&height=150\";s:11:\"displayName\";s:14:\"Osadchiy Yuriy\";s:11:\"description\";s:0:\"\";s:9:\"firstName\";s:5:\"Yuriy\";s:8:\"lastName\";s:8:\"Osadchiy\";s:6:\"gender\";s:4:\"male\";s:8:\"language\";s:5:\"ru_RU\";s:3:\"age\";N;s:8:\"birthDay\";i:25;s:10:\"birthMonth\";i:11;s:9:\"birthYear\";i:1988;s:5:\"email\";s:15:\"XXXX.com\";s:13:\"emailVerified\";s:15:\"XXXX.com\";s:5:\"phone\";N;s:7:\"address\";N;s:7:\"country\";N;s:6:\"region\";s:0:\"\";s:4:\"city\";N;s:3:\"zip\";N;s:9:\"job_title\";N;s:17:\"organization_name\";N;}"
How can I get the avatar of the user photoURL
I use this code:
$args = array(
'role' => 'Customer'
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '<p>' . $user->ID . '</p>';
echo '<p>' . $user->display_name . '</p>';
echo '<p>' . $user->user_email . '</p>';
echo '<p>' . $user->billing_phone . '</p>';
echo '<p>' . $user->billing_first_name . '</p>';
echo '<p>' . $user->billing_last_name . '</p>';
echo '<p>' . $user->facebook_login_data
}
}
I would be grateful for the help.
My decision:
$args = array(
'role' => 'Customer'
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '<p>' . $user->ID . '</p>';
echo '<p>' . $user->display_name . '</p>';
echo '<p>' . $user->user_email . '</p>';
echo '<p>' . $user->billing_phone . '</p>';
echo '<p>' . $user->billing_first_name . '</p>';
echo '<p>' . $user->billing_last_name . '</p>';
if ($user->facebook_login_data){
echo '<p>' . $user->facebook_login_data["profileURL"] .'</p>';
}
}
}
I'm having a little hard time here implementing a modal view to display the post content rather than sending the user to another page.
I have this
function get_grid_archive_theme( $post, $archive_template = null ) {
$archive_template = isset( $archive_template ) ? $archive_template : get_product_listing_template();
$return = '';
if ( $archive_template == 'grid' ) {
$product_id = $post->ID;
$excerpt = get_the_excerpt( $product_id );
$post_content = get_the_content( $product_id );
$image_id = get_post_thumbnail_id( $product_id );
$thumbnail_product = wp_get_attachment_image_src( $image_id, 'classic-grid-listing' );
$product_name = get_product_name();
if ( $thumbnail_product ) {
$img_class[ 'alt' ] = $product_name;
$img_class[ 'class' ] = 'classic-grid-image';
$image = wp_get_attachment_image( $image_id, 'classic-grid-listing', false, $img_class );
} else {
$url = default_product_thumbnail_url();
$image = '<img src="' . $url . '" class="classic-grid-image default-image" alt="' . $product_name . '" >';
}
$archive_price = apply_filters( 'archive_price_filter', '', $post );
$classic_grid_settings = get_classic_grid_settings();
$row_class = get_row_class( $classic_grid_settings );
$return = '<div class="col-xs-12 col-sm-6 col-md-3 product-' . $product_id . ' classic-grid ' . $row_class . ' ">';
$return .= '<a data-toggle="modal" data-target="#' . $product_id . ' " href="#">';
//$return .= '<div style="background-image:url(\'' . $url . '\');" class="classic-grid-element"></div>';
$return .= '<div class="classic-grid-image-wrapper"><div class="pseudo"></div><div class="image">' . $image . '</div></div>';
$return .= '<div class="excerpt-cnt"><div class="excerpt-text">' . $excerpt . '</div></div><h3 class="product-name">' . $product_name . '</h3>' . $archive_price;
if ( $classic_grid_settings[ 'attributes' ] == 1 && function_exists( 'product_attributes_number' ) ) {
$attributes_number = product_attributes_number();
if ( $attributes_number > 0 && has_product_any_attributes( $product_id ) ) {
$max_listing_attributes = apply_filters( 'max_product_listing_attributes', $classic_grid_settings[ 'attributes_num' ] );
$return .= '<div class="product-attributes">';
$a = 0;
for ( $i = 1; $i <= $attributes_number; $i++ ) {
$attribute_value = get_attribute_value( $i, $product_id );
if ( !empty( $attribute_value ) ) {
$return .= '<div><span class="attribute-label-listing">' . get_attribute_label( $i, $product_id ) . ':</span> <span class="attribute-value-listing">' . get_attribute_value( $i, $product_id ) . '</span> <span class="attribute-unit-listing">' . get_attribute_unit( $i, $product_id ) . '</span></div>';
$a++;
}
if ( $a == $max_listing_attributes ) {
break;
}
}
$return .= '</div>';
}
}
$return .= '</a>';
$return .= apply_filters( 'classic_grid_product_listing_element', '', $product_id );
$return .= '</div>';
}
$return .= '<div id="' . $product_id . ' " class="modal" role="dialog">';
$return .= '<div class="modal-dialog"><div class="modal-content">';
$return .= '<div class="modal-header">';
$return .= '<h4 class="modal-title">' . $product_name .'</h4>';
$return .= '</div>';
$return .= '<div class="modal-body">';
$return .= '<p>' . $post_content .'</p>';
$return .= '</div>';
$return .= '<div class="modal-footer">';
$return .= '</div>';
$return .= '</div></div>';
$return .= '</div>';
return $return;
}
This code extracts a series of posts excerpts and displays them in a 4 column layout As the picture below depicts
Each one can be clicked and it will show the content of that post in a modal. Well the thing is, it just doesn't but the modal is loaded in the DOM because when I inspect the code there are no JS errors, and the modals are shown in the HTML but still as display:none;. If I click that off or change it to block manually in the web-dev tool the modal shows.
Bootstrap is loaded in the site too. What am I missing? Why doesn't the data-target toggle the display from none to block?
I think there is just a small space problem in your code, in the line below.
$return .= '<div id="' . $product_id . ' " class="modal" role="dialog">';
Remove the space before the close of id attribute, as given below.
$return .= '<div id="' . $product_id . '" class="modal" role="dialog">';
I hope this will help!
I would like to be able to add a custom CSS class to my WooCommerce checkout fields. I'm using twitter Bootstrap and I would like to be able to use their .form-control class.
I looked in the woocommerce templates folder in form-billing.php but I'm not sure where to add the .form-control class to each text field.
Here is the code for form-billing.php
<?php
/**
* Checkout billing information form
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<div class="woocommerce-billing-fields">
<?php if ( WC()->cart->ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
<h3><?php _e( 'Billing & Shipping', 'woocommerce' ); ?></h3>
<?php else : ?>
<h3><?php _e( 'Billing Details', 'woocommerce' ); ?></h3>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
<?php foreach ( $checkout->checkout_fields['billing'] as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<?php do_action('woocommerce_after_checkout_billing_form', $checkout ); ?>
<?php if ( ! is_user_logged_in() && $checkout->enable_signup ) : ?>
<?php if ( $checkout->enable_guest_checkout ) : ?>
<p class="form-row form-row-wide create-account">
<input class="input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true) ?> type="checkbox" name="createaccount" value="1" /> <label for="createaccount" class="checkbox"><?php _e( 'Create an account?', 'woocommerce' ); ?></label>
</p>
<?php endif; ?>
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
<?php if ( ! empty( $checkout->checkout_fields['account'] ) ) : ?>
<div class="create-account">
<p><?php _e( 'Create an account by entering the information below. If you are a returning customer please login at the top of the page.', 'woocommerce' ); ?></p>
<?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
<?php endif; ?>
</div>
Do I need to to look in another template file?
Thanks
icc97's answer is almost there but doesn't work.
I took icc97's answer, and debugged it:
add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
public function addBootstrapToCheckoutFields($fields) {
foreach ($fields as &$fieldset) {
foreach ($fieldset as &$field) {
// if you want to add the form-group class around the label and the input
$field['class'][] = 'form-group';
// add form-control to the actual input
$field['input_class'][] = 'form-control';
}
}
return $fields;
}
As #Peanuts pointed out, what if we want to add CSS classes to certain input types only?
After experimenting with the solutions posted here so far, (thanks to everybody!), I've came up with a mod using a simple "switch case", in which the logic is taken from /woocommerce/includes/wc-template-functions.php. The function allow us to target all the input types at once, be it the default input types or even custom ones.
There's no need to rewrite the woocommerce_form_field function to simply change the $defaults args for the input types. It is valid to mention that the function also allow us to add much more than just css classes to the fields.
-- So here's the function --
/*********************************************************************************************/
/** WooCommerce - Modify each individual input type $args defaults /**
/*********************************************************************************************/
add_filter('woocommerce_form_field_args','wc_form_field_args',10,3);
function wc_form_field_args( $args, $key, $value = null ) {
/*********************************************************************************************/
/** This is not meant to be here, but it serves as a reference
/** of what is possible to be changed. /**
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
'placeholder' => '',
'maxlength' => false,
'required' => false,
'id' => $key,
'class' => array(),
'label_class' => array(),
'input_class' => array(),
'return' => false,
'options' => array(),
'custom_attributes' => array(),
'validate' => array(),
'default' => '',
);
/*********************************************************************************************/
// Start field type switch case
switch ( $args['type'] ) {
case "select" : /* Targets all select input type elements, except the country and state select input types */
$args['class'][] = 'form-group'; // Add a class to the field's html element wrapper - woocommerce input types (fields) are often wrapped within a <p></p> tag
$args['input_class'] = array('form-control', 'input-lg'); // Add a class to the form input itself
//$args['custom_attributes']['data-plugin'] = 'select2';
$args['label_class'] = array('control-label');
$args['custom_attributes'] = array( 'data-plugin' => 'select2', 'data-allow-clear' => 'true', 'aria-hidden' => 'true', ); // Add custom data attributes to the form input itself
break;
case 'country' : /* By default WooCommerce will populate a select with the country names - $args defined for this specific input type targets only the country select element */
$args['class'][] = 'form-group single-country';
$args['label_class'] = array('control-label');
break;
case "state" : /* By default WooCommerce will populate a select with state names - $args defined for this specific input type targets only the country select element */
$args['class'][] = 'form-group'; // Add class to the field's html element wrapper
$args['input_class'] = array('form-control', 'input-lg'); // add class to the form input itself
//$args['custom_attributes']['data-plugin'] = 'select2';
$args['label_class'] = array('control-label');
$args['custom_attributes'] = array( 'data-plugin' => 'select2', 'data-allow-clear' => 'true', 'aria-hidden' => 'true', );
break;
case "password" :
case "text" :
case "email" :
case "tel" :
case "number" :
$args['class'][] = 'form-group';
//$args['input_class'][] = 'form-control input-lg'; // will return an array of classes, the same as bellow
$args['input_class'] = array('form-control', 'input-lg');
$args['label_class'] = array('control-label');
break;
case 'textarea' :
$args['input_class'] = array('form-control', 'input-lg');
$args['label_class'] = array('control-label');
break;
case 'checkbox' :
break;
case 'radio' :
break;
default :
$args['class'][] = 'form-group';
$args['input_class'] = array('form-control', 'input-lg');
$args['label_class'] = array('control-label');
break;
}
return $args;
}
The function above completely solved the issue of targeting the checkout form inputs all at once, which is really straight forward for the checkout form default input types or even custom new ones. It seems not to be possible though, to print each input type html output without creating a new function as #abhisek shows on his answer.
Bonus
It seems that the function might also affect other forms fields printed by WooCommerce's functions or templates outside the checkout page.
I've managed to conditionally apply the function only when on the checkout page by using the is_page() function. Your checkout page might have a different slug, so change that to reflect it accordingly.
If you need to apply the function only for the checkout page, do as follows:
Comment add_filter()
//add_filter('woocommerce_form_field_args','wc_form_field_args', 10, 3);
And use add_action instead
add_action('woocommerce_form_field_args', 'wc_form_field_args', 10, 3);
function wc_form_field_args( $args, $key, $value = null ) {
...
// Right after
return $args;
// Place the following
if ( !is_page('checkout') ) {
add_filter('woocommerce_form_field_args','wc_form_field_args', 10, 3);
} else {
remove_filter('woocommerce_form_field_args','wc_form_field_args', 10, 3);
}
}
After that, the function will only affect the checkout page form.
#Chetan's link and run answer does kind of give you what you want, but as ever they're never very good answers.
The best resource for this is the WooCommerce Codex page on Customizing checkout fields using actions and filters.
In the 'Customizing WooCommerce Checkout Field Labels and Placeholder Text' in Chetan's page you have the following code which you need to add to your functions.php, I've modified it in such a way that it should do what you want, but I haven't tested the code:
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'my_theme_custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function my_theme_custom_override_checkout_fields( $fields ) {
foreach ($fields as $fieldset) {
foreach ($fieldset as $field) {
$field['class'] = array('form-control');
}
}
return $fields;
}
I am fixed the issue by defining a custom function. The logic is taken directly from wc-template-functions.php (I am not sure if this is the right way but it does solve the problem).
/*
* Custom form field function for Bootstrap 3
*/
function bootstrap_woocommerce_form_field( $key, $args, $value = null ) {
$defaults = array(
'type' => 'text',
'label' => '',
'placeholder' => '',
'maxlength' => false,
'required' => false,
'class' => array(),
'label_class' => array(),
'input_class' => array(),
'return' => false,
'options' => array(),
'custom_attributes' => array(),
'validate' => array(),
'default' => '',
);
$args = wp_parse_args( $args, $defaults );
if ( ( ! empty( $args['clear'] ) ) ) $after = '<div class="clear"></div>'; else $after = '';
if ( $args['required'] ) {
$args['class'][] = 'validate-required';
$required = ' <abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
} else {
$required = '';
}
$args['maxlength'] = ( $args['maxlength'] ) ? 'maxlength="' . absint( $args['maxlength'] ) . '"' : '';
if ( is_string( $args['label_class'] ) )
$args['label_class'] = array( $args['label_class'] );
if ( is_null( $value ) )
$value = $args['default'];
// Custom attribute handling
$custom_attributes = array();
if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) )
foreach ( $args['custom_attributes'] as $attribute => $attribute_value )
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
if ( ! empty( $args['validate'] ) )
foreach( $args['validate'] as $validate )
$args['class'][] = 'validate-' . $validate;
switch ( $args['type'] ) {
case "country" :
$countries = $key == 'shipping_country' ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries();
if ( sizeof( $countries ) == 1 ) {
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . '</label>';
$field .= '<strong>' . current( array_values( $countries ) ) . '</strong>';
$field .= '<input type="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="' . current( array_keys($countries ) ) . '" ' . implode( ' ', $custom_attributes ) . ' class="country_to_state" />';
$field .= '</div>' . $after;
} else {
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">'
. '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>'
. '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" class="country_to_state form-control country_select" ' . implode( ' ', $custom_attributes ) . '>'
. '<option value="">'.__( 'Select a country…', 'woocommerce' ) .'</option>';
foreach ( $countries as $ckey => $cvalue )
$field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
$field .= '</select>';
$field .= '<noscript><input type="submit" name="woocommerce_checkout_update_totals" value="' . __( 'Update country', 'woocommerce' ) . '" /></noscript>';
$field .= '</div>' . $after;
}
break;
case "state" :
/* Get Country */
$country_key = $key == 'billing_state'? 'billing_country' : 'shipping_country';
if ( isset( $_POST[ $country_key ] ) ) {
$current_cc = wc_clean( $_POST[ $country_key ] );
} elseif ( is_user_logged_in() ) {
$current_cc = get_user_meta( get_current_user_id() , $country_key, true );
if ( ! $current_cc) {
$current_cc = apply_filters('default_checkout_country', (WC()->customer->get_country()) ? WC()->customer->get_country() : WC()->countries->get_base_country());
}
} elseif ( $country_key == 'billing_country' ) {
$current_cc = apply_filters('default_checkout_country', (WC()->customer->get_country()) ? WC()->customer->get_country() : WC()->countries->get_base_country());
} else {
$current_cc = apply_filters('default_checkout_country', (WC()->customer->get_shipping_country()) ? WC()->customer->get_shipping_country() : WC()->countries->get_base_country());
}
$states = WC()->countries->get_states( $current_cc );
if ( is_array( $states ) && empty( $states ) ) {
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field" style="display: none">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>';
$field .= '<input type="hidden" class="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '" />';
$field .= '</div>' . $after;
} elseif ( is_array( $states ) ) {
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" class="state_select form-control " ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '">
<option value="">'.__( 'Select a state…', 'woocommerce' ) .'</option>';
foreach ( $states as $ckey => $cvalue )
$field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
$field .= '</select>';
$field .= '</div>' . $after;
} else {
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<input type="text" class="form-control input-text ' . implode( ' ', $args['input_class'] ) .'" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
$field .= '</div>' . $after;
}
break;
case "textarea" :
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<textarea name="' . esc_attr( $key ) . '" class="form-control input-text ' . implode( ' ', $args['input_class'] ) .'" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '"' . ( empty( $args['custom_attributes']['rows'] ) ? ' rows="2"' : '' ) . ( empty( $args['custom_attributes']['cols'] ) ? ' cols="5"' : '' ) . implode( ' ', $custom_attributes ) . '>'. esc_textarea( $value ) .'</textarea>
</div>' . $after;
break;
case "checkbox" :
$field = '<div class="checkbox form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">
<label for="' . esc_attr( $key ) . '" class="checkbox ' . implode( ' ', $args['label_class'] ) .'" ' . implode( ' ', $custom_attributes ) . '>
<input type="' . esc_attr( $args['type'] ) . '" class="input-checkbox" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" value="1" '.checked( $value, 1, false ) .' />'
. $args['label'] . $required . '</label>
</div>' . $after;
break;
case "password" :
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<input type="password" class="form-control input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />
</div>' . $after;
break;
case "text" :
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . $required . '</label>';
$field .= '<input type="text" class="form-control input-text ' . implode( ' ', $args['input_class'] ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />
</div>' . $after;
break;
case "select" :
$options = '';
if ( ! empty( $args['options'] ) )
foreach ( $args['options'] as $option_key => $option_text )
$options .= '<option value="' . esc_attr( $option_key ) . '" '. selected( $value, $option_key, false ) . '>' . esc_attr( $option_text ) .'</option>';
$field = '<div class="form-group form-row ' . esc_attr( implode( ' ', $args['class'] ) ) .'" id="' . esc_attr( $key ) . '_field">';
if ( $args['label'] )
$field .= '<label for="' . esc_attr( $key ) . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" class="select form-control" ' . implode( ' ', $custom_attributes ) . '>
' . $options . '
</select>
</div>' . $after;
break;
default :
$field = apply_filters( 'woocommerce_form_field_' . $args['type'], '', $key, $args, $value );
break;
}
if ( $args['return'] ) return $field; else echo $field;
}
Don't forget to replace all occurrences of woocommerce_form_field with bootstrap_woocommerce_form_field Hope it helps!