I have added a new custom field in checkout page named " Date of event "
, It's working fine. But i want one thing to be done which is " When user order single/multiple products then hide "Add to cart"
button and show unavailable message instead of button for that selected date of event. " Like if user selected date " 7/2/2019 "
in " Date of event field "
during checkout, then after he ordered that product, hide " Add to cart " button and show unavailable message instead of button for " 7/2/2019 "
date of event. I don't know how to do this.
Which hooks and actions will do this.
I have googled it a lot, but didn't get any answer.
Please help me.
Custom field Code:
add_action('woocommerce_after_checkout_billing_form', 'date_of_event_field');
function date_of_event_field($checkout){
echo '<div id="date_of_event_field" class="margin-top-20">';
woocommerce_form_field( 'date_of_event', array(
'type' => 'date',
'class' => array('my-field-class form-row-wide'),
'label' => __('Date Of Event'),
'required' => true,
), $checkout->get_value( 'date_of_event' ));
echo '</div>';
}
Code to hide Add to cart button and show message instead of button:
function make_product_unavailable( $_product, $order ) {
if( $order->id == $_product ){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
}
}
It's a try from my side, because i don't know how to do to this and i don't know which filter/action hook will be used for this.
Please help me.