13
votes

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?

6
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

6 Answers

8
votes

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!

3
votes

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/

3
votes

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.

1
votes

Example

You need to edit file: /plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php

Copy the file to themes/YOURTHEME/inc/class-wc-shortcode-products.php

Add to function.php: require 'inc/class-wc-shortcode-products.php';

0
votes

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.

-2
votes

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

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