Php 覆盖商业功能
我需要在Php 覆盖商业功能,php,woocommerce,Php,Woocommerce,我需要在WC\u购物车类中完全更改函数获取折扣价格的逻辑 在childfunctions.php中,我写了: function get_discounted_price_new( $values, $price, $add_totals = false ) { //My code that extends standart function } add_action('get_discounted_price', 'get_discounted_price_new'); 但我看不到任何变化。
WC\u购物车类
中完全更改函数获取折扣价格
的逻辑
在childfunctions.php
中,我写了:
function get_discounted_price_new( $values, $price, $add_totals = false )
{
//My code that extends standart function
}
add_action('get_discounted_price', 'get_discounted_price_new');
但我看不到任何变化。哪里出错了?我认为不需要采取行动 您需要过滤器
woocommerce\u获得折扣\u价格
检查以下代码-
// define the woocommerce_get_discounted_price callback
function filter_woocommerce_get_discounted_price( $price, $values, $instance ) {
// make filter magic happen here...
return $price;
};
// add the filter
add_filter( 'woocommerce_get_discounted_price', 'filter_woocommerce_get_discounted_price', 10, 3 );
我发现了这个,但是我需要做的这些改变,我不能用过滤器。我需要完全重写这个功能,你可以指定你想要实现什么吗?我需要删除优惠券销售时,每一个购物车奇数产品应用优惠券。我在每次迭代后检查优惠券名称和产品计数器。所以在你的答案中,是$price——这是应用优惠券后的结果价格。