WooCommerce产品模板 [英] WooCommerce Product Template

查看:427
本文介绍了WooCommerce产品模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在WooCommerce中的产品模板上移动缩略图,将其放在大产品图片旁边,价格下方并添加到购物车按钮. (作为标准,它们直接位于大产品图片的下方)

I would like to move my thumbnails on my product template in WooCommerce, to position them beside the big product picture, underneath the price and add to cart buttons. (As standard, they are positioned directly underneath the big product picture)

模板似乎正在使用钩子,而我之前从未尝试过使用钩子.我找到了一个似乎可以完成此工作的"content-single-product.php",但在该文件中找不到有关缩略图的任何信息.

The template seems to be using hooks though, and I haven't tried using that before. I have found a 'content-single-product.php' that seems to do the stuff, but I can't find anything about thumbnails in that file.

有人可以指出我正确的方向吗?

Can someone point me in the right direction?

已经感谢!

推荐答案

首先,请确保在以下文件夹结构中的主题目录中覆盖WooCommerce模板:/woocommerce/templates/(即yourtheme/woocommerce/templates/).这样,如果Woo有更新,您的自定义代码将不会被覆盖.

First off, make sure you override WooCommerce templates in your theme directory in this folder structure: /woocommerce/templates/ (i.e. yourtheme/woocommerce/templates/). This way, if Woo has an update, your custom code won't be overridden.

对此,我不是100%积极的,但是通常使用Woo模板替代功能,应该可以使您受益匪浅.

I'm not 100% positive on this, but generally having worked with Woo template overrides, this should get you pretty far.

缩略图实际上很深.

他们在这里:templates/single-product/product-thumbnails.php

它在第43行中加载:woocommerce / templates / single-product / product-image.php

It's loaded in Line 43 here: woocommerce / templates / single-product / product-image.php

该product-image.php部分在此处加载: woocommerce / templates / content-single-product.php "woocommerce_before_single_product_summary".

That product-image.php section is loaded in here: woocommerce / templates / content-single-product.php "woocommerce_before_single_product_summary".

因此,您需要将其从product-image.php的第43行中删除,然后将其放在"woocommerce_single_product_summary"部分中.您应该尝试将此操作添加到您自己的自定义函数文件中(显然是将其删除-该操作-从现在的位置删除),该文件是

So you will need to remove it from line 43 on the product-image.php and then put it in the "woocommerce_single_product_summary" section. You should try and put this action add in your own custom functions file (obviously removing it - the action - from where it is now) which is

add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );

并更改为

add_action('woocommerce_after_single_product_summary','woocommerce_show_product_thumbnails', 20 );

此处引用了操作列表:

woocommerce / includes / wc-template-hooks.php

订单已开通

woocommerce / templates / content-single-product.php

这篇关于WooCommerce产品模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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