Override Core WooCommerce Template Files in Oxygen Builder

Oxygen builder have an add-on for WooComerce plugin and you can create the custom shop, archive, single product etc pages quickly. But sometimes we are getting the complex challenge, and that time we need to edit the core templates files.

WooCommerce have an option. You can easily override the templates file from your active theme’s folder. But there have a problem for Oxygen builder. We knew that Oxygen builder is not loading the theme. In this scenario we need the custom plugin and edit the templates.

I already created a blank helper plugin Customize Oxygen Builder. Download the plugin and upload on your site via Dashboard. You can avoid my plugin if you built one for your site. In that case you can just use my PHP snippet.

In my plugin have a helpers.php file inside the includes folder. Open the file and put this PHP snippets

/*************************************************
Add your custom PHP code inside this PHP file
*************************************************/
 
add_action( 'after_setup_theme', 'pauloxyb_after_setup_oxyb' );
function pauloxyb_after_setup_oxyb() {
 
    //* Allow to override WC /templates path
    add_filter( 'wc_get_template',         'pauloxyb_wc_template', 10, 5 );
    add_filter( 'wc_get_template_part', 'pauloxyb_wc_template_part', 10, 3 );
    
}
function pauloxyb_wc_template( $located, $template_name, $args, $template_path, $default_path ) {
    $newtpl = str_replace( 'woocommerce/templates', basename( POXYB_DIR ) . '/woocommerce', $located );
    
    if ( file_exists( $newtpl ) )
        return $newtpl;
 
    return $located;
}
 
function pauloxyb_wc_template_part( $template, $slug, $name ) {
    $newtpl = str_replace( 'woocommerce/templates',basename( POXYB_DIR ) . '/woocommerce', $template );
    
    if ( file_exists( $newtpl ) )
        return $newtpl;
 
    return $template;
}
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.