14

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
nishant
  • 479
  • 2
  • 6
  • 19
  • 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 Answers6

8

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!

NetOperator Wibby
  • 1,354
  • 5
  • 22
  • 44
4

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.

Khurram
  • 41
  • 1
3

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:

http://docs.woothemes.com/document/hooks/

designtocode
  • 2,215
  • 4
  • 21
  • 35
1

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

Webfeya
  • 163
  • 1
  • 5
0

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.

Raptor
  • 53,206
  • 45
  • 230
  • 366
naren8642
  • 51
  • 3
-1

Yes you should be able to do this by uploading to this folder

/wp-content/themes/YOURTHEME/woocommerce/includes/class-wc-checkout.php

Ryan NZ
  • 616
  • 1
  • 9
  • 25