melitaR
Hello
I have added custom PHP code for redirect in Woocommerce, so that - after payment, the customer is redirected to the correct page, as this was not given by the theme I am using.
Also, I needed to add the birthdate to the Woocommerce billing form, also using custom PHP code, and I need to transfer the word/string "Birthdate" from the form, which is not shown in the string translation.
My redirect code
add_action( 'wp_enqueue_scripts', 'emeritus_child_theme_enqueue_scripts' );
}
add_action( 'woocommerce_thankyou', 'bbloomer_redirectcustom');
function bbloomer_redirectcustom( $order_id ){
$order = wc_get_order( $order_id );
$url = 'hidden link ';
if ( ! $order->has_status( 'failed' ) ) {
wp_safe_redirect( $url );
exit;
}
}
my billing form custom birthdate field code:
add_filter( 'woocommerce_billing_fields', 'display_birthdate_billing_field', 20, 1 );
function display_birthdate_billing_field($billing_fields) {
$billing_fields['billing_birthdate'] = array(
'type' => 'date',
'label' => __('Birthdate'),
'class' => array('form-row-wide'),
'priority' => 25,
'required' => true,
'clear' => true,
);
return $billing_fields;
}
add_action( 'woocommerce_checkout_update_customer', 'save_account_billing_birthdate_field', 10, 2 );
function save_account_billing_birthdate_field( $customer, $data ){
if ( isset($_POST['billing_birthdate']) && ! empty($_POST['billing_birthdate']) ) {
$customer->update_meta_data( 'billing_birthdate', sanitize_text_field($_POST['billing_birthdate']) );
}
}
add_filter('woocommerce_admin_billing_fields', 'admin_order_billing_birthdate_editable_field');
function admin_order_billing_birthdate_editable_field( $fields ) {
$fields['birthdate'] = array( 'label' => __('Birthdate', 'woocommerce') );
return $fields;
}
// WordPress User: Add Billing birthdate editable field
add_filter('woocommerce_customer_meta_fields', 'wordpress_user_account_billing_birthdate_field');
function wordpress_user_account_billing_birthdate_field( $fields ) {
$fields['billing']['fields']['billing_birthdate'] = array(
'label' => __('Birthdate', 'woocommerce'),
'description' => __('', 'woocommerce')
);
return $fields;
}
how could I achieve that?
I have 12 languages in usage, German being default lanugage of the page.
thank you
Andreas
Hello there
Thank you for contacting us. I am happy to help you.
First of all I would like to clarify that it is out of the scope of WPML support to debug custom code.
For the parts of gettext stings that you have it it seems correct to me
Have you tried to rescan for new strings before search in String Translation ?
If you have added this code in your theme for example you need to search the theme again for new strings.
Please follow this guide :
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/
I hope this helps. Please let us know how it goes or if you need any further assistance. I'll gladly help you. 🙂
Regards,
Andreas