覆盖特定的第三方 Woocommerce 插件模板 [英] Overriding specific third party Woocommerce plugin templates

查看:37
本文介绍了覆盖特定的第三方 Woocommerce 插件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是基于 Woocommerce 的插件,名为 Mix 'n Match Products.

这个插件位于 /plugins/woocommerce-mix-and-match-products/
此文件夹包含另一个模板文件夹.

按照惯例,我已将templates"文件夹复制到我的子主题中,并将文件夹名称更改为woocommerce-mix-and-match-products"

结构现在是themes/storevilla-child/woocommerce-mix-and-match-products/

但是,没有任何模板会覆盖插件模板.我已经测试过了.只有在我更改了实际的插件模板文件后,HTML 才会更改.

有人能发现我做错了什么吗?

谢谢

解决方案

实现方式有点不同.所有 WooThemes woocommerce 插件都使用 本文档中描述的默认 woocommerce 模板文件夹:

2 种情况:

  1. 您的活动子主题(或主题)中已经有一个 woocommerce 文件夹.
    复制自 plugins/woocommerce-mix-and-match-products/templates/single-product/mnm/
    themes/your_active_theme/woocommerce/single-product/
    plugins/woocommerce-mix-and-match-products/templates/single-product/add-to-cart/mnm.php
    themes/your_active_theme/woocommerce/single-product/add-to-cart/

  2. 您的活动子主题(或主题)中没有任何 woocommerce 文件夹.
    复制自 plugins/woocommerce-mix-and-match-products/templates/
    在您活动的子主题(或主题)中并将其重命名为 woocommerce.

<块引用>

因此,在您的情况下,您将拥有:themes/storevilla-child/woocommerce/

参考:WooCommerce 模板结构 + 通过主题覆盖模板

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

解决方案

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

这篇关于覆盖特定的第三方 Woocommerce 插件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆