Skip to content

Instantly share code, notes, and snippets.

@shirokoweb
Created July 18, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirokoweb/f310b5813104b89fac98a89476340cf5 to your computer and use it in GitHub Desktop.
Save shirokoweb/f310b5813104b89fac98a89476340cf5 to your computer and use it in GitHub Desktop.
Mode vacances WooCommerce
<?php
// Mode vacances
add_action ('init', 'mode_vacances_boutique');
// Désactiver les fonctionnalités de WC
function mode_vacances_boutique() {
// Désactiver l'ajout au panier
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
// Désactiver le bouton passer commande
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
// Désactiver la page de paiement
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
}
// Afficher un message
function messages_wc_shop_disabled() {
add_action( 'woocommerce_before_main_content', 'messages_wc_shop_disabled', 5 );
add_action( 'woocommerce_before_cart', 'messages_wc_shop_disabled', 5 );
add_action( 'woocommerce_before_checkout_form', 'messages_wc_shop_disabled', 5 );
wc_print_notice( 'La boutique est fermée du 1er au 15 août 2019', 'error');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment