Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override woocommerce files from includes folder

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?

like image 480
nishant Avatar asked Jul 04 '14 12:07

nishant


People also ask

How do I bypass WooCommerce files?

To override WooCommerce template files in your theme (or better yet, child theme) simply make a folder named 'woocommerce' within your theme directory, and then create the folders/template file you wish to override within it.

How do I override WooCommerce template files plugin?

To do that just copy the WooCommerce template you need to customize and add it to your plugin folder. Now all the customizations you need to make to the WooCommerce cart page can be made in the 'cart. php' file in your plugin folder.

How do I override a single product page in WooCommerce?

If yes, then go to the Templates->Theme Builder then go to Single Product tab and make all of them Draft. Then after try to override the single-product. php . Thanks!

What is Wc_get_template_part?

As mentioned in the comments, wc_get_template_part() tries to locate and load the requested template file. These template files could be ether in the /woocommerce/ sub-directory of a child-theme, or defined in another third party plugin (with the help of woocommerce_locate_template filter hook).


1 Answers

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

like image 182
Webfeya Avatar answered Sep 22 '22 15:09

Webfeya