Команды get_post_meta (get_the_ID (), 'add_price', true); не работают над этой функцией моего WordPress сайта:
function misha_recalculate_price( $cart_object ) {
var_dump(get_post_type($post_ID));
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
foreach ( $cart_object->get_cart() as $hash => $value ) {
$nowprice = $value['data']->get_price();
$addprice = get_post_meta(get_the_ID(), 'add_price', true);
$newprice = $nowprice+$addprice ;
$value['data']->set_price( $newprice );
}
}
add_action( 'woocommerce_before_calculate_totals', 'misha_recalculate_price' );