简体   繁体   English

WooCommerce-产品类别中的百分比折扣小部件

[英]WooCommerce - Percentage Discount in products categories widget


I need to custom the output of Woocommerce Products Categories Widget showing the percentage discount for that category (Discount_Price*100/Standard_Price). 我需要自定义Woocommerce产品类别小部件的输出,以显示该类别的折扣百分比(Discount_Price * 100 / Standard_Price)。
I can easily create a function that takes from the first product of that category: 我可以轻松创建一个从该类别的第一个产品中提取的函数:

  • Discount Price 折扣价
  • Standard Price 标准价格

and calculate the percentage discount, but I don't know how to show it in the output of the widget like this: 并计算百分比折扣,但我不知道如何在小部件的输出中显示它,如下所示:

  • First Category (50% discount) 头等舱(50%折扣)
  • Second Category (30% discount) 第二类(30%折扣)

Can you help me? 你能帮助我吗?
Thanks 谢谢

Looks like the only entry point is the filter woocommerce_product_categories_widget_args . 看起来唯一的入口点是过滤器woocommerce_product_categories_widget_args The output is done via wp_list_categories and I guess you'll have to do a custom walker to achieve what you want. 输出是通过wp_list_categories完成的,我想您必须做一个自定义的walker才能实现所需的功能。 Or duplicate the widget code and make your custom one. 或复制小部件代码并进行自定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM