Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //расчет итоговой цены товара
- function ut_before_calculate_totals( $cart_obj ) {
- echo '<pre>';
- var_dump($cart_obj->get_cart());
- echo '</pre>';
- foreach( $cart_obj->get_cart() as $key => $value ) {
- $product_total_price = ( !empty( get_post_meta( $value['data']->get_id(), '_sale_price', true) ) ) ? get_post_meta( $value['data']->get_id(), '_sale_price', true) : get_post_meta( $value['data']->get_id(), '_regular_price', true);
- $volume = ( isset( $value['variation']['attribute_m-3-na-poddone'] ) ) ? $value['variation']['attribute_m-3-na-poddone'] : 1 ;
- $result_price = $product_total_price * $volume ;
- $value['data']->set_price( $result_price );
- }
- }
- add_action( 'woocommerce_before_calculate_totals', 'ut_before_calculate_totals', 10, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement