remove cart

How to remove the cart function for WooComerce

Find the woocommerce.php,insert the below codes:
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 );

remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );

remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );

Then the whole page would look like below:
<?php
/**

  • Plugin Name: WooCommerce
  • Plugin URI: https://woocommerce.com/
  • Description: An eCommerce toolkit that helps you sell anything. Beautifully.
  • Version: 4.3.0
  • Author: Automattic
  • Author URI: https://woocommerce.com
  • Text Domain: woocommerce
  • Domain Path: /i18n/languages/
  • Requires at least: 5.2
  • Requires PHP: 7.0
    *
  • @package WooCommerce
    */

defined( ‘ABSPATH’ ) || exit;

if ( ! defined( ‘WC_PLUGIN_FILE’ ) ) {
define( ‘WC_PLUGIN_FILE’, FILE );
}

// Load core packages and the autoloader.
require DIR . ‘/src/Autoloader.php’;
require DIR . ‘/src/Packages.php’;

if ( ! \Automattic\WooCommerce\Autoloader::init() ) {
return;
}
\Automattic\WooCommerce\Packages::init();

// Include the main WooCommerce class.
if ( ! class_exists( 'WooCommerce', false ) ) {
include_once dirname( WC_PLUGIN_FILE ) . '/includes/class-woocommerce.php';
}

/**
 * Returns the main instance of WC.
 *
 * @since  2.1
 * @return WooCommerce
 */
function WC() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid


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 );

remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );

remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
return WooCommerce::instance();
}

// Global for backwards compatibility.
$GLOBALS['woocommerce'] = WC();