Last active
December 22, 2022 12:56
-
-
Save mbilalsiddique1/52c0d13cd5c78f8f00f0c024b521f761 to your computer and use it in GitHub Desktop.
WooCommerce - Enable Catalouge Mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: WooCommerce Catalog Mode | |
Plugin URI: https://gist.github.com/mbilalsiddique1/52c0d13cd5c78f8f00f0c024b521f761 | |
Description: This plugin enables catalog mode for WooCommerce and removes the shopping functionality. | |
Version: 1.0.0 | |
Author: Muhammad Bilal | |
Author URI: https://github.com/mbilalsiddique1 | |
License: GPLv2 or later | |
Text Domain: woocommerce-catalog-mode | |
*/ | |
function wc_catalog_mode_init() { | |
// Remove the add to cart button | |
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', 30 ); | |
// Remove the cart page | |
add_filter( 'woocommerce_cart_item_permalink', '__return_false' ); | |
add_filter( 'woocommerce_cart_needs_payment', '__return_false' ); | |
// Remove the checkout page | |
add_filter( 'woocommerce_checkout_fields', '__return_empty_array' ); | |
add_filter( 'woocommerce_cart_needs_payment', '__return_false' ); | |
// Remove the order tracking form | |
add_filter( 'woocommerce_order_button_text', '__return_empty_string' ); | |
add_filter( 'woocommerce_order_button_html', '__return_empty_string' ); | |
// Remove prices | |
add_filter( 'woocommerce_variable_price_html', '__return_empty_string' ); | |
add_filter( 'woocommerce_get_price_html', '__return_empty_string' ); | |
// Hide the "add to cart" notice | |
add_filter( 'wc_add_to_cart_message_html', '__return_empty_string' ); | |
} | |
add_action( 'init', 'wc_catalog_mode_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment