I'm searching for a plugin or code snippet to disable the checkout of one of my clients webshops to disable the checkout on a specific day of the week. I couldn't talk it out of their head so it should be done. I found the advanced checkout plugin but found out it is horrible broken. I tried to find a code-snippet for WooCommerce for it but I failed in my search. Anybody has an idea of an existing snippet or one that is similar to the action I want to achieve so I could alter it a little and use it?
Thanks in advance!
Edit: i'm trying to write my own snippet and this is what I achieved so far:
add_action( 'wp_head', 'disable_checkout_sunday' );
function disable_checkout_sunday(){
if (date(D) == "Sun"){
remove__action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form');
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form');
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review');
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment');
}
}
This is something I have improvised but I'm not sure if this would work. Also, isn't there a cleaner way to do this?
I'm searching for a plugin or code snippet to disable the checkout of one of my clients webshops to disable the checkout on a specific day of the week. I couldn't talk it out of their head so it should be done. I found the advanced checkout plugin but found out it is horrible broken. I tried to find a code-snippet for WooCommerce for it but I failed in my search. Anybody has an idea of an existing snippet or one that is similar to the action I want to achieve so I could alter it a little and use it?
Thanks in advance!
Edit: i'm trying to write my own snippet and this is what I achieved so far:
add_action( 'wp_head', 'disable_checkout_sunday' );
function disable_checkout_sunday(){
if (date(D) == "Sun"){
remove__action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form');
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form');
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review');
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment');
}
}
This is something I have improvised but I'm not sure if this would work. Also, isn't there a cleaner way to do this?
Share Improve this question edited Nov 1, 2016 at 16:58 Nabil Kadimi 2,7261 gold badge22 silver badges30 bronze badges asked Nov 1, 2016 at 15:56 BreusBreus 1481 silver badge8 bronze badges 1- 1 You might try this plugin. It able to schedule your open time in terms of day & hours. Then you can set bar to notify user when your store close. – msmaromi Commented Sep 26, 2019 at 4:10
1 Answer
Reset to default 0A better approach in my opinion would be to redirect the cart and checkout pages to a static page with user friendly message.
This shows how to get Various WooCommerce Page URLs, you can hook a function to init
, that function will:
- See if the current URL matches the URL of the checkout or cart pages
- If so, it will
wp_redirect
to your static page.