I need to fully change logic of function get_discounted_price
in WC_Cart class
.
In child functions.php
i have wrote:
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');
But i do not see any changes. Where is mistake?
I think do_action is not required.
You need the filter woocommerce_get_discounted_price
.
Check the following code -
// 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 );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.