Override woocommerce files from includes folder

2019-04-26 18:47发布

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?

5条回答
够拽才男人
2楼-- · 2019-04-26 19:01

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楼-- · 2019-04-26 19:11

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.

查看更多
小情绪 Triste *
4楼-- · 2019-04-26 19:11

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

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

查看更多
Viruses.
5楼-- · 2019-04-26 19:12

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/

查看更多
贼婆χ
6楼-- · 2019-04-26 19:21

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.

查看更多
登录 后发表回答