0

I have made a custom Wordpress theme that has the basic Woo Commerce plugin installed.

I have made some custom html and css changes to the Woo templates for example:

 * @see     https://docs.woocommerce.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.4.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Filter tabs and allow third parties to add their own.
 *
 * Each tab is an array containing title, callback and priority.
 * @see woocommerce_default_product_tabs()
 */
$tabs = apply_filters( 'woocommerce_product_tabs', array() );

if ( ! empty( $tabs ) ) : ?>

    <div class="woocommerce-tabs wc-tabs-wrapper">
        <?php the_content();?> //****** I added this extra content ******
        <ul class="tabs wc-tabs" role="tablist">
            <?php foreach ( $tabs as $key => $tab ) : ?>
                <li class="<?php echo esc_attr( $key ); ?>_tab" id="tab-title-<?php echo esc_attr( $key ); ?>" role="tab" aria-controls="tab-<?php echo esc_attr( $key ); ?>">
                    <a href="#tab-<?php echo esc_attr( $key ); ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', esc_html( $tab['title'] ), $key ); ?></a>
                </li>
            <?php endforeach; ?>
        </ul>
        <?php foreach ( $tabs as $key => $tab ) : ?>
            <div class="woocommerce-Tabs-panel woocommerce-Tabs-panel--<?php echo esc_attr( $key ); ?> panel entry-content wc-tab" id="tab-<?php echo esc_attr( $key ); ?>" role="tabpanel" aria-labelledby="tab-title-<?php echo esc_attr( $key ); ?>">
                <?php if ( isset( $tab['callback'] ) ) { call_user_func( $tab['callback'], $key, $tab ); } ?>
            </div>
        <?php endforeach; ?>
    </div>

<?php endif; ?>

The issue I'm having is when Woo Commerce updates it wipes out my changes and I have to re-implement them. My theme is made from scratch, so there isn't a child theme available to skip overrides.

Is there a way to protect these changes and allow Woo to update what it needs?

1

First and foremost you shouldn't be modifying Woocommerce files directly. For that matter, it's a bad idea for WordPress, themes, or plugins. Most plugins and themes provide a means to alter core functionality and appearance in update safe ways.

For Woocommerce some basic guidelines are here.

But in a nutshell, to modify appearance you would generally copy the pages or components to a subdirectory in your theme and modify those instead of the core Woocommerce files.

Woocommerce also supports many hooks, filters, and actions to modify functionality. At first glance, it looks as if you should be using the appropriate hook to modify Woocommerce to your liking.

  • So when you say "But in a nutshell, to modify appearance you would generally copy the pages or components to a subdirectory" You mean if I want to edit "form-checkout.php" for example in the woo templates, I would create an additional form-checkout.php with the changes I want and store it in my theme folder where all the other basic theme files are? – RLM Jun 7 '18 at 18:45
  • Check out the theming docs at Woo for more information. docs.woocommerce.com/documentation/plugins/woocommerce/… – Steve Jun 7 '18 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.