hurab
Forum Replies Created
-
Hi thank you so much actually it works but i want this on the registration page as well instead of username. could you help me with that too
Hello in setup field>user>add field and added
i am sorry but i still cannot export the account number
also i wanted to ask can i set the option Filter by Account Number
is it that you are asking whether i have guest checkout or not? if this is your question then no i only have registered customers and they cannot get into the shop page until and unless they register themselves
could you please explain bit further sorry i am new to it
i inserted this code and i added the field in user
please guide
add_filter(‘woe_get_user_value_{FIELD}’,function ($value, $user,$fieldname) {
$value = unserialize($value);
return $value[0];
},10,3);yes i correct that speelings too still causing fatal error
Forum: Plugins
In reply to: [WooCommerce] extra field not appearing in backendupdate: just in case if anyone is looking for it
// Display a field in Registration / Edit account
add_action( ‘woocommerce_register_form_start’, ‘display_account_registration_field’ );
add_action( ‘woocommerce_edit_account_form_start’, ‘display_account_registration_field’ );
function display_account_registration_field() {
$user = wp_get_current_user();
$value = isset($_POST[‘billing_account_number’]) ? esc_attr($_POST[‘billing_account_number’]) : $user->billing_account_number;
?>
<p class=”woocommerce-form-row woocommerce-form-row–wide form-row form-row-wide”>
<label for=”reg_billing_account_number”><?php _e( ‘Ship to/ Account number’, ‘woocommerce’ ); ?> <span class=”required”>*</span></label>
<input type=”text” maxlength=”6″ class=”input-text” name=”billing_account_number” id=”reg_billing_account_number” value=”<?php echo $value ?>” />
</p>
<div class=”clear”></div>
<?php
}// registration Field validation
add_filter( ‘woocommerce_registration_errors’, ‘account_registration_field_validation’, 10, 3 );
function account_registration_field_validation( $errors, $username, $email ) {
if ( isset( $_POST[‘billing_account_number’] ) && empty( $_POST[‘billing_account_number’] ) ) {
$errors->add( ‘billing_account_number_error’, __( ‘Error: account number is required!’, ‘woocommerce’ ) );
}
return $errors;
}// Save registration Field value
add_action( ‘woocommerce_created_customer’, ‘save_account_registration_field’ );
function save_account_registration_field( $customer_id ) {
if ( isset( $_POST[‘billing_account_number’] ) ) {
update_user_meta( $customer_id, ‘billing_account_number’, sanitize_text_field( $_POST[‘billing_account_number’] ) );
}
}// Save Field value in Edit account
add_action( ‘woocommerce_save_account_details’, ‘save_my_account_billing_account_number’, 10, 1 );
function save_my_account_billing_account_number( $user_id ) {
if( isset( $_POST[‘billing_account_number’] ) )
update_user_meta( $user_id, ‘billing_account_number’, sanitize_text_field( $_POST[‘billing_account_number’] ) );
}// Display field in admin user billing fields section
add_filter( ‘woocommerce_customer_meta_fields’, ‘admin_user_custom_billing_field’, 10, 1 );
function admin_user_custom_billing_field( $args ) {
$args[‘billing’][‘fields’][‘billing_account_number’] = array(
‘label’ => __( ‘Ship to/ Account number’, ‘woocommerce’ ),
‘description’ => ”,
‘custom_attributes’ => array(‘maxlength’ => 6),
);
return $args;
}but i am still stuck with admin area please guide
Much thanksForum: Plugins
In reply to: [WooCommerce] extra field not appearing in backendsure i used business bloomers functions
/**
* @snippet Add Ship to/ Account Number to My Account Register Form – WooCommerce
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=21974
* @author Rodolfo Melogli
* @credits Claudio SM Web
* @compatible WC 3.5.2
* @donate $9 https://businessbloomer.com/bloomer-armada/
*////////////////////////////////
// 1. ADD FIELDSadd_action( ‘woocommerce_register_form_start’, ‘bbloomer_add_account_woo_account_registration’ );
function bbloomer_add_account_woo_account_registration() {
?><p class=”form-row form-row-first”>
<label for=”reg_billing_account_number”><?php _e( ‘Ship to/ Account number’, ‘woocommerce’ ); ?> <span class=”required”>*</span></label>
<input type=”text” class=”input-text” name=”billing_account_number” id=”reg_billing_account_number” value=”<?php if ( ! empty( $_POST[‘billing_account_number’] ) ) esc_attr_e( $_POST[‘billing_account_number’] ); ?>” />
</p><div class=”clear”></div>
<?php
}///////////////////////////////
// 2. VALIDATE FIELDSadd_filter( ‘woocommerce_registration_errors’, ‘bbloomer_validate_account_fields’, 10 );
function bbloomer_validate_account_fields( $errors, $username, $email ) {
if ( isset( $_POST[‘billing_account_name’] ) && empty( $_POST[‘billing_account_number’] ) ) {
$errors->add( ‘billing_account_number_error’, __( ‘Error: account number is required!’, ‘woocommerce’ ) );
$fields[‘billing_account_number’][‘maxlength’] = 6;
}
return $errors;
}///////////////////////////////
// 3. SAVE FIELDSadd_action( ‘woocommerce_created_customer’, ‘bbloomer_save_account_fields’ );
function bbloomer_account_number_fields( $customer_id ) {
if ( isset( $_POST[‘billing_account_number’] ) ) {
update_user_meta( $customer_id, ‘billing_account_number’, sanitize_text_field( $_POST[‘billing_account_number’] ) );
update_user_meta( $customer_id, ‘account_number’, sanitize_text_field($_POST[‘billing_account_number’]) );
}
}
and for the admin backend
/* to display the custom field content in the admin area */function fyndaa_manage_users_custom_column( $output, $column_key, $user_id ) {
switch ( $column_key ) {case ‘user_accountnumber’:
$value = get_user_meta( $user_id, ‘user_accountnumber’, true );
return $value;
break;
default: break;
}// if no column slug found, return default output value
return $output;
}
please guideMuch thanks
Forum: Plugins
In reply to: [WooCommerce] separating east and West state names in checkout pageHi Thanks i solved it.
could you please guide that it is possible to extract sales report according to each customer?
basically my client wants that they should extract the sales report made by each customeractually what i have done is that on my clients account dashboard i have inserted the button return order and when they press the button the form should appear autofilling their product name and order number. they just have to write Reason of return
i changed your code wording only
add_action( ‘wp_ajax_nopriv_get_user_information’,’smartform_ext_get_user_information’);
add_action( ‘wp_ajax_get_user_information’,’smartform_ext_get_user_information’);function smartform_ext_get_user_information(){
$current_user = wp_get_current_user();
if($current_user==false)
return “{}”;echo json_encode(array(
“name”=>$current_user->user_firstname. ‘ ‘. $current_user->user_lastname,
“ordernumber”=>$current_user->order_number,
“productName”=>$current_user->product_name
));
die();}
is there something i am doing wrong please help me to get the autofilled order numberhi if you want so i can provide you the login so you can check
oops sorry
https://www.greencotton.my/returrn/
now i saw its only that name can be autofilled defaulted but the other cannot
Please guideMuch Thanks
I use the below code which you provided but with some ammendments i changed the email with order number and products.
add_action( ‘wp_ajax_nopriv_get_user_information’,’smartform_ext_get_user_information’);
add_action( ‘wp_ajax_get_user_information’,’smartform_ext_get_user_information’);function smartform_ext_get_user_information(){
$current_user = wp_get_current_user();
if($current_user==false)
return “{}”;echo json_encode(array(
“name”=>$current_user->user_firstname. ‘ ‘. $current_user->user_lastname,
“ordernumber”=>$current_user->order_number,
“productName”=>$current_user->product_name
));
die();}
this is the link of the form https://www.greencotton.my/post_type=smartforms_preview&p=11213&sfpreview=true
2. please guide why the two lines are appearing as the header on the form
Much Thanks