【发布时间】:2021-11-17 23:52:14
【问题描述】:
我需要应用一个 sn-p,其中显示 woocommerce 产品的最大可变价格,但仅在类别 ID 29 中。我没有设法做到这一点,所以我留下了没有类别的函数代码.它适用于最大可变价格。我希望有一个人可以帮助我!非常感谢。
// define the woocommerce_variable_price_html callback
function filter_woocommerce_variable_price_html( $wc_format_price_range, $instance ) {
$index = strpos($wc_format_price_range, "– ");
$wc_format_price_range = substr($wc_format_price_range, $index+7);
//This will remove the first price by dividing the standard string with dash
//You may add a prefix like, $wc_format_price_range = "Max Price: $wc_format_price_range";
return $wc_format_price_range = "Max Price: $wc_format_price_range";;
};
// add the filter
add_filter( 'woocommerce_variable_price_html', 'filter_woocommerce_variable_price_html', 10, 2
);
【问题讨论】:
标签: wordpress woocommerce hook e-commerce code-snippets