Hello @binarywc,
Thanks for your reply and your time. really appreciated. I’ve found what i am looking for i just paste code for ref. Thank you
// Add custom checkout datepicker field
add_action( ‘woocommerce_after_checkout_billing_form’, ‘datepicker_custom_field’ );
function datepicker_custom_field($checkout) {
$datepicker_slug = ‘my_datepicker’;
echo ‘<div id=”datepicker-wrapper”>’;
woocommerce_form_field($datepicker_slug, array(
‘type’ => ‘text’,
‘class’=> array( ‘form-row-first my-datepicker’, ‘update_totals_on_change’),
‘label’ => __(‘My Custom Date-picker’),
), ” );
woocommerce_form_field( ‘tip’, array(
‘type’ => ‘radio’,
‘class’ => array( ‘form-row-wide’, ‘update_totals_on_change’ ),
‘options’ => array(
‘5’ => ‘5’,
’10’ => ’10’,
’15’ => ’15’,
),
));
echo ‘<br clear=”all”></div>’;
// Jquery: Enable the Datepicker
?>
<script language=”javascript”>
jQuery( function($){
var a = ‘#<?php echo $datepicker_slug ?>’;
jQuery(a).datepicker({
dateFormat: ‘yy-mm-dd’, // ISO formatting date
});
});
</script>
<?php
}
// adds a custom fee based on the field valued
add_action( ‘woocommerce_cart_calculate_fees’, ‘update_custom_fields’, 10, 1 );
function update_custom_fields( $cart ) {
if ( ! $_POST || is_admin() || ! is_ajax() ) {
return;
}
if ( isset( $_POST[‘post_data’] ) ) {
parse_str( $_POST[‘post_data’], $post_data );
} else {
$post_data = $_POST;
}
if ( isset( $post_data[‘my_datepicker’] ) ) {
if($post_data[‘my_datepicker’]){
WC()->cart->add_fee( ‘Schedule a Fitment Date – ‘.$post_data[‘my_datepicker’], false );
}
}
if ( isset( $post_data[‘tip’] ) ) {
$percentage = $post_data[‘tip’];
WC()->cart->add_fee( ‘Tip’, $percentage, true );
}
}`