如何定制woocommerce相关产品?
1 个回答
- 投票数
-
- 2014-09-30
我们不要在这里愚弄自己.接受的答案只会使用户达到他的目标.
第一个问题就在这里:
<?php // display upsells and related products within dedicated div with different column and number of products remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20); remove_action( 'woocommerce_after_single_product', 'woocommerce_output_related_products',10); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
一个动作被删除,然后放在它被删除的确切位置.目标是完全不清楚的.
我在搜索相关产品时遇到了这个问题,因为我不知道标签和类别是驱动此插件中
woocommerce_output_related_products
功能的原因.此问题的最佳答案是以下链接,并且与
woocommerce_output_related_products_args()
过滤器有关: https://stackoverflow.com/questions/23554993/output-posts-related-to-the-tagsLet's not fool ourselves here guys. The accepted answer only got the user to his goal.
The very first problem lies here:
<?php // display upsells and related products within dedicated div with different column and number of products remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20); remove_action( 'woocommerce_after_single_product', 'woocommerce_output_related_products',10); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
An action is removed, and then placed in the EXACT position it was removed from. The goal is completely unclear.
I came across this with a search on the related products because I did not understand that TAGS and CATEGORIES are what drives the
woocommerce_output_related_products
function in this plugin.The best answer to THIS question is the following link, and has everything to do with the
woocommerce_output_related_products_args()
filter: https://stackoverflow.com/questions/23554993/output-posts-relating-to-the-tags-
这实际上很有趣.为什么要问,因为如果您已经仔细阅读了我的答案,那么您会看到,它仅使用一个过滤器.确切地说,当时只有一个可用的过滤器,但是您应该知道,如果您确实阅读了我写的内容,并且会花时间查看不同版本的源文件.只是说.除此之外,您链接的答案很好地解释了可用的新Sine v2.1挂钩.This is actually quite funny. Why you might ask, because if you've read my answer carefully, then you would've seen, it uses only one filter. To be exact the only filter available at that time, but you would have known that, if you actually had read what I wrote and would have taken the time to look at the source files of the different versions. Just saying. Aside from that, the answer you linked explains the new hooks available sine v2.1 very well.
- 0
- 2014-10-06
- Nicolai
-
抱歉,这是一个深夜.我希望解释一下OP中代码中的明显错误.Sorry about that, it was a late night. I was hoping to explain a bit about the obvious fault in the code by the OP.
- 0
- 2014-10-16
- Nathan Powell
-
不用担心,但是我还是不得不说些什么.No worries, but felt I had to say something though.
- 0
- 2014-10-18
- Nicolai
-
内森,您的参考链接对我有用.谢谢,现在我已经尝试2个小时亲自为自己做.现在我知道正确应用过滤器了:)Your reference link worked for me Nathan, thanks, been trying to do it for myself 2 hours now. Now I know to apply filters properly :)
- 0
- 2015-07-08
- marcovega
我的网站上有以下几行代码,它们将在WooCommerce的单个产品页面底部显示 相关产品 ...
functions.php:
由于它显示4个产品的分类名称相同,我该如何修改上面的内容,以显示 相关标签 ?
例如,我有一个名为"汽车"的产品类别,并且在此类别中,有一些标签-" Holden"," Ford"," Toyota"," Nissan"等.
我希望它在底部显示4个产品,与用户当前正在查看的产品标签有关.