I have directly modified the class-wc-checkout.php
file from includes
folder in woocommerce plugin to add custom line item meta
data. Is there any way to override
the class-wc-checkout.php file from my-theme folder as we override template files in woocommerce?
-
I am in a similar situation, needing to modify the `apply_coupon` function in `woocommerce/includes/class-wc-cart.php`. The provided hooks aren't sufficient, and this file can't be overridden. Is there any other way to override this function without just editing the original plugin file? – nabrown Jul 09 '19 at 20:30
6 Answers
I was having this same issue. I don't have a need for reviews on my site, so I copied what I wanted to remove from a file inside of the includes
folder and copied it into my functions.php
file like so:
// Remove reviews from WooCommerce
if (! function_exists( 'woocommerce_default_product_tabs')) {
function woocommerce_default_product_tabs($tabs = array()) {
}
}
Works for me!

- 1,354
- 5
- 22
- 44
Only Templates folder files can be override by coping it into your child theme.
For all other files like in includes folder files you can either edit it or use hooks and filters to do so.

- 41
- 1
I'm not too sure what you are editing for the Woocommerce plugin but yes you can override the woocommerce plugin by adding these hooks and filters to your functions.php file in your theme:

- 2,215
- 4
- 21
- 35
Example
You need to edit file: /plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php
Copy this file to themes/YOURTHEME/inc/class-wc-shortcode-products.php
Add to function.php:
require 'inc/class-wc-shortcode-products.php';

- 163
- 1
- 5
-
Only Templates folder files can be override by coping it into your child theme. – Ravi Soni Apr 22 '22 at 09:58
What seems to work for me is to put the file here:
/wp-content/themes/YOURTHEME/includes/class-wc-checkout.php
The difference between the other suggestion and mine is that I don't have the 'woocommerce' folder in the path.
Yes you should be able to do this by uploading to this folder
/wp-content/themes/YOURTHEME/woocommerce/includes/class-wc-checkout.php

- 616
- 1
- 9
- 25
-
1See comments by designtocode and Khurram - doesn't work like that, unfortunately – Ralf Oct 25 '18 at 14:56