add_filter( 'woocommerce_cart_total', 'wc_modify_cart_price' );
function wc_modify_cart_price( $price ) {
$addition = 10;
return $price+addition;
}
Здесь
add_filter( 'woocommerce_calculated_total', 'modify_calculated_total', 20, 2 );
function modify_calculated_total( $total, $cart ) {
return $total + 10;
}
Итого товара = фиксированная сумма * Количество
add_action( 'woocommerce_before_calculate_totals', 'modify_cart_price', 20, 1);
function modify_cart_price( $cart_obj ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) || ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ))
return;
foreach ( $cart_obj->get_cart() as $cart_item ) {
$cart_item['data']->set_price( 1000);
}
}
Итого товара = Цена товара * Количество (по умолчанию)
add_action( 'woocommerce_before_calculate_totals', 'modify_cart_price', 20, 1);
function modify_cart_price( $cart_obj ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) || ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ))
return;
foreach ( $cart_obj->get_cart() as $cart_item ) {
$cart_item['data']->set_price( $cart_item['data']->get_price());
}
}
Итого по продукту в корзине
function filter_woocommerce_cart_product_subtotal( $product_subtotal, $product, $quantity, $instance ) {
$product_subtotal = $product->get_price()*$quantity;
return $product_subtotal;
};
add_filter( 'woocommerce_cart_product_subtotal', 'filter_woocommerce_cart_product_subtotal', 10, 4 );