/*
Theme Name: Bw Zenny
Theme URI: https://zenny.bzotech.com/intro/
Author: BZOTech
Author URI: https://bzotech.com/
Description: With Zenny Glasses WordPress template for WooCommerce you'll make a statement that it's not just about fashion accessories.
Version: 1.7.7
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Copyright: © 2024 BZOTech Theme. All rights reserved.
Tags: custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, post-formats, sticky-post, threaded-comments, block-styles, blog, news
Text Domain: bw-zenny
*/

<?php
// Désactiver l'achat en ligne
add_filter( 'woocommerce_is_purchasable', '__return_false' );

// Supprimer le bouton "Ajouter au panier" sur les pages boutique et produit
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 );

// Ajouter un bouton "Contactez-nous" à la place
function littoraloptique_custom_contact_button() {
    echo '<a href="/contact" class="button alt">📞 Contactez-nous</a>';
}
add_action( 'woocommerce_after_shop_loop_item', 'littoraloptique_custom_contact_button', 10 );
add_action( 'woocommerce_single_product_summary', 'littoraloptique_custom_contact_button', 30 );

// Bloquer l'accès direct au panier et au checkout
function littoraloptique_disable_cart_checkout_pages() {
    if ( is_cart() || is_checkout() ) {
        wp_redirect( home_url( '/contact' ) ); 
        exit;
    }
}
add_action( 'template_redirect', 'littoraloptique_disable_cart_checkout_pages' );
