D
D
Dmitry Dmitriev2017-10-15 16:34:19
WordPress
Dmitry Dmitriev, 2017-10-15 16:34:19

Prevent adding product to cart on woocommerce from 00:00 am to 10:00 am?

Greetings!
I do not have enough knowledge and experience to implement a ban on adding goods to the cart on woocommerce from 00:00 am to 10:00 am? this is planned to be a food delivery site as a result. The delivery service is open from 10:00 to midnight. So far, everything is on a local server only...
All that was enough for me was to add to the functions.php file:
function ubiraem_add (){
$time_now[1] = date("H:i",time () + 10800 );
$time_x[1]= date("10:00"); // 10:00 AM
$time_y[1]= date("00:00"); // 00:00 Night
if(($time_now > $time_y)&&($time_now < $time_x)){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action('init','ubiraem_add');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2017-10-15
@kawabanga

It's more of a question of how to present it to clients.
In my opinion - a banner from 12 am to 10 am, such as Sorry, but we can process your orders only in the morning is much more useful than blocking the action at some stage.
And so, you will have a contact of a person, and you can beat him, for example, by offering a 20% discount the next day.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question