Overriding specific third party Woocommerce plugin

2019-02-27 15:55发布

问题:

I'm using a Woocommerce based plugin called Mix 'n Match Products.

This plugin sits inside /plugins/woocommerce-mix-and-match-products/
This folder contains another folder for templates.

Following convention, I have copied the "templates" folder into my child theme and changed the folder name to "woocommerce-mix-and-match-products"

The structure is now themes/storevilla-child/woocommerce-mix-and-match-products/

However, none of the templates override the plugin templates. I have tested. Only once I change the actual plugin template files, does the HTML change.

Can anybody spot what I may be doing wrong?

Thanks

回答1:

The way to do it is a little bit different. All WooThemes woocommerce plugins use the default woocommerce templates folder described in this documentation:

2 cases:

  1. You have already a woocommerce folder in your active child theme (or theme).
    Copy from plugins/woocommerce-mix-and-match-products/templates/single-product/mnm/
    to themes/your_active_theme/woocommerce/single-product/
    And plugins/woocommerce-mix-and-match-products/templates/single-product/add-to-cart/mnm.php
    inside themes/your_active_theme/woocommerce/single-product/add-to-cart/

  2. You don't have any woocommerce folder in your active child theme (or theme).
    Copy from plugins/woocommerce-mix-and-match-products/templates/
    inside your active child theme (or theme) and rename it woocommerce.

So in your case you will have: themes/storevilla-child/woocommerce/

Reference: WooCommerce Template Structure + Overriding Templates via a Theme