How to overwrite Woocommerce template using Avada Child Theme

I need to overwrite my-account Woocommerce template. In order to do so using child theme I tried the following solutions:

  1. copied my-account.php file from woocommerce/templates into wp-content/themes/Avada-Child-Theme/woocommerce/myaccount
  2. in line 9 (just below comments) of my-account.php added this line:

    Read More
    die('test');
    

no expected result (message ‘test’).

  1. Also tried the above with my-account.php file located in

    wp-content/themes/Avada-Child-Theme/woocommerce/templates/myaccount

    no expected result.

  2. Also tried the above with folder:

    wp-content/themes/Avada/woocommerce/myaccount
    

no expected result.

  1. Also tried the above within folder:

     wp-content/plugins/woocommerce/templates/myaccount
    

and this worked, but it is not a good practice.

What I am doing wrong?

I am using WP 4.1, Woocommerce 2.2.10 and Avada Theme 3.7.2 with Avada Child Theme installed and active.

Regarding point 1. on System Status Woocommerce page I see this:

Avada/woocommerce/cart/cart.php, 
Avada/woocommerce/cart/shipping-calculator.php, 
Avada/woocommerce/checkout/form-checkout.php, 
Avada/woocommerce/checkout/review-order.php, 
Avada/woocommerce/checkout/thankyou.php, 
Avada/woocommerce/content-product.php, 
Avada/woocommerce/loop/loop-start.php, 
Avada/woocommerce/loop/pagination.php, 
Avada/woocommerce/myaccount/form-edit-address.php, 
Avada-Child-Theme/woocommerce/myaccount/my-account.php, 
Avada/woocommerce/single-product/add-to-cart/variable.php, 
Avada/woocommerce/single-product/product-image.php, 
Avada/woocommerce/single-product/product-thumbnails.php, 
Avada/woocommerce/single-product/short-description.php, 
Avada/woocommerce/single-product/tabs/description.php, 
Avada/woocommerce/single-product/title.php

So, it seems to be ok, but my changes do not affect the template. I also tried to make other changes, like adding some text inside p html tag – no effect.

Please help!

EDIT:

I generated list of active plugins:

` [0]=>  string(29) "gravityforms/gravityforms.php"
  [1]=>  string(27) "LayerSlider/layerslider.php"
  [2]=>  string(25) "duplicator/duplicator.php"
  [3]=>  string(27) "fusion-core/fusion-core.php"
  [4]=>  string(58) "gravity-forms-css-ready-selector/gf-readyclasses-addon.php"
  [5]=>  string(23) "revslider/revslider.php"
  [6]=>  string(21) "woochimp/woochimp.php"
  [7]=>  string(49) "woocommerce-customizer/woocommerce-customizer.php"
  [8]=>  string(71) "woocommerce-gravityforms-product-addons/gravityforms-product-addons.php"
  [9]=>  string(51) "woocommerce-pdf-invoice/woocommerce-pdf-invoice.php"
  [10]=>  string(65) "woocommerce-points-and-rewards/woocommerce-points-and-rewards.php"
  [11]=>  string(61) "woocommerce-product-details-customiser/details-customiser.php"
  [12]=>  string(27) "woocommerce/woocommerce.php"
  [13]=>  string(39) "woothemes-updater/woothemes-updater.php"`

Related posts

Leave a Reply

3 comments

  1. Solved using this in functions.php

    <?php
    add_filter('wc_get_template', 'ovr_product_meta_template', 10, 5);
    function ovr_product_meta_template($located, $template_name, $args, $template_path, $default_path) {
        if ('single-product/meta.php' == $template_name) {
            $default_path = get_stylesheet_directory();
            $template_path = 'woocommerce/';
            $located = wc_locate_template($template_name, $template_path, $default_path);
        }
        return $located;
    }
    ?>
    
  2. I came to this post because i’m having the same question. I did some research in the theme files to figure out where the source of all evil lies.

    First off: It’s no use replacing the templates for the my-account page in the child theme, nor the main theme. Reason: there’s an override in place on the entire my-account page from the Avada / Fusion Core files.

    I’ve checked the theme’s functions.php, avada-functions.php and the various my-account.php and my-address.php; nothing. Then I went and started opening several random files and folders until I came to this file: Avada/includes/woo-config.php.

    It appears there are several hooks in place, which overwrite the original woo-commerce template files with static code setup, like below. The ‘woocommerce_before_my_account’ hook (further in the php-file) is used to display the content of the my-account page.

        //function under myaccount hooks
        remove_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
        add_action( 'woocommerce_thankyou', 'avada_woocommerce_view_order', 10 );
        /* end checkout hooks */
    
        /* begin my-account hooks */
        add_action( 'woocommerce_before_customer_login_form', 'avada_woocommerce_before_customer_login_form' );
    function avada_woocommerce_before_customer_login_form()
    {
    
        global $woocommerce;
    
    if ( get_option( 'woocommerce_enable_myaccount_registration' ) !== 'yes' ) :
        ?>
    
    <div id="customer_login" class="woocommerce-content-box full-width">
    
    <?php
    endif;
    }
    
        add_action( 'woocommerce_after_customer_login_form', 'avada_woocommerce_after_customer_login_form' );
    function avada_woocommerce_after_customer_login_form()
    {
    
        global $woocommerce;
    
    if ( get_option( 'woocommerce_enable_myaccount_registration' ) !== 'yes' ) :
        ?>
    
    </div>
    
    <?php
    endif;
    }
    
    function avada_top_user_container() {
        global $smof_data, $woocommerce, $current_user;
    
        echo '<div class="avada_myaccount_user">';
            echo '<span class="myaccount_user_container">';
                echo '<span class="username">';
    
                    if ( $current_user->display_name ) {
                        printf( '%s, %s:', __( 'Hallo', 'Avada' ), $current_user->display_name );
                    } else {
                        echo __( 'Hallo', 'Avada' );
                    }
    
                echo '</span>';
    
                if ( $smof_data['woo_acc_msg_1'] ) {
                    echo '<span class="msg">';
                        echo $smof_data['woo_acc_msg_1'];
                    echo '</span>';
                }
    
                if ( $smof_data['woo_acc_msg_2'] ) {
                    echo '<span class="msg">';
                        echo $smof_data['woo_acc_msg_2'];
                    echo '</span>';
                }
                echo '<span class="view-cart">';
                    printf( '<a href="%s">%s</a>', get_permalink( get_option( 'woocommerce_cart_page_id' ) ), __( 'View Cart', 'Avada' ) );
                echo '</span>';
            echo '</span>';
        echo '</div>';
    }
    

    This unfortunately is not the solution, but it is an explanation on why the custom or edited original my-account does not work. I’ve created a ticket with Avada’s Theme-Fusion authors with this question. When I’ve got a response, i’ll check in again.

  3. Since the theme Avada is always up to date with the latest and also upcoming releases of WooCommerce they setup a compatability folder for the release about to be old. At the time of this writing 2.7 is about to come out and Avada has created a folder called compatability inside the folder woocommerce. Under that folder the version about to be old is represented with a folder, in this instance a folder named 2.6 exists by default.

    Inside the class Avada_WooCommerce you can find the filter called woocommerce_template_path that is hooked into by Avada, defining a function that checks if the current version is 2.7 or 2.6 and returning the path to the template folder. Since 2.7 is not yet released, 2.6 is running and for that, the folder is set to woocommerce/compatability/2.6.

    So if you are running 2.6 and want to override the templates in your child-theme, create a folder in your child-theme folder that is called woocommerce/compatability/2.6 and place your overriding templates there.

    If you then upgrade to WooCommerce 2.7 when it comes out, remember to place the overriding templates in the usual folder, woocommerce.

    Took me some time to figure out and I hope it helps!