Vasko
New member
Hi fellas,
I am trying to create a custom check out dropdown fields on the Woocomerse checkout page. When the field is selected I want to show the HTML code to the user where they can fill out the details for invoce. I have the following coded added the function.php:
however, the jQuery function is no working and when the checkbox is clicked it does not slide the HTML code up or down. I am trying to integrate for two days but no aval. Any help is much appreciated!
I am trying to create a custom check out dropdown fields on the Woocomerse checkout page. When the field is selected I want to show the HTML code to the user where they can fill out the details for invoce. I have the following coded added the function.php:
Code:
<?php
// add fields
add_action( 'woocommerce_after_checkout_billing_form', 'vasko_select_field' );
// save fields to order meta
add_action( 'woocommerce_checkout_update_order_meta', 'vasko_save_what_we_added' );
// select
function vasko_select_field( $checkout ){
// you can also add some custom HTML here
woocommerce_form_field( 'contactmethod', array(
'type' => 'checkbox', // text, textarea, select, radio, checkbox, password, about custom validation a little later
'required' => false, // actually this parameter just adds "*" to the field
'class' => array('vasko-field', 'form-row-wide'), // array only, read more about classes and styling in the previous step
'label' => 'Желая да ми бъде издадена фактура',
'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox') // sometimes you need to customize labels, both string and arrays are supported
), $checkout->get_value( 'contactmethod' ) );
// you can also add some custom HTML here
echo '<label>
<span>* Фирма</span>
<input id="company" type="text" name="client[company]" value="" placeholder="Фирма" class="required">
</label>
<label>
<span>* ЕИК</span>
<input id="tax_num" type="text" name="client[tax_num]" value="" placeholder="ЕИК" class="required">
</label>
<label>
<span>ИН по ЗДДС</span>
<input id="vat_num" class="" type="text" name="client[vat_num]" value="" placeholder="ИН по ЗДДС">
</label>
<label class="">
<span>* Град</span>
<input id="city_company" type="text" name="client[company_cityName]" value="" placeholder="Град" class="ui-autocomplete-input required" autocomplete="off">
<input id="city_companyId" type="hidden" name="client[company_cityId]" value="" class="">
</label>
<label>
<span>* Адрес</span>
<input id="company_address" type="text" name="client[company_address]" value="" placeholder="Адрес" class="required">
</label>';
function bbloomer_conditionally_hide_show_new_field() {
wp_enqueue_script( "
jQuery('input#contactmethod').change(function(){
if (this.checked) {
jQuery('#contactmethod').slideDown);
jQuery('#contactmethod input').val('');
} else {
jQuery('#contactmethod').slideUp
}
});
");
}
}
however, the jQuery function is no working and when the checkbox is clicked it does not slide the HTML code up or down. I am trying to integrate for two days but no aval. Any help is much appreciated!