Answer the question
In order to leave comments, you need to log in
How to make bilingual strings I added in js file?
By design, the checkout is very unfriendly to the default in woocommerce. It was necessary to add several static blocks just before some inpets inside the form. That is, hooks that would add them before or after the checkout form would not solve the problem, they need to be right inside the form.
I hardcoded them in my main.js with before-after methods exactly where they are by design.
jQuery('p#billing_first_name_field').before('<div class="form-row form-row-first personal_details_toggle"><div class="woocommerce-input-wrapper"><div class="input-text form-control" id="personal_details_toggle">Personal details of recepient<span class="fa-arrow-down"></span></div></div></div>');
jQuery('p#billing_country_field').before('<div class="form-row form-row-first delivery_address"><div class="woocommerce-input-wrapper"><div class="input-text form-control" id="delivery_address">Delivery address<span class="fa-arrow-down"></span></div></div></div>');
// Register the script
wp_register_script( 'some_handle', 'path/to/myscript.js' );
// Localize the script with new data
$translation_array = array(
'some_string' => __( 'Some string to translate', 'plugin-domain' ),
'a_value' => '10'
);
wp_localize_script( 'some_handle', 'object_name', $translation_array );
// Enqueued script with localized data.
wp_enqueue_script( 'some_handle' );
// Register the script
wp_register_script( 'some_handle', get_template_directory_uri() . '/assets/js/main.js' );
// Localize the script with new data
$translation_array = array(
'Delivery address' => get_theme_mod('delivery_address_text'),
);
wp_localize_script( 'some_handle', 'main_js', $translation_array );
// Enqueued script with localized data.
wp_enqueue_script( 'some_handle' );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question