MK
Size: a a a
MK
НМ
OG
OG
ДА
MK
A
A
add_action( 'woocommerce_checkout_create_order_line_item', 'blow_order_line_item', 10, 4 );
function blow_order_line_item( $item, $cart_item_key, $values, $order ) {
if ( array_key_exists( 'app_price_points', $values ) ) {
$item->add_meta_data( '_app_price_points', $values['app_price_points'] );
$item->add_meta_data( '_total_points', $values['app_price_points'] * $values['quantity'] );
}
if ( array_key_exists( 'app_price_npa', $values ) ) {
$item->add_meta_data( '_app_price_npa', $values['app_price_npa'] );
$item->add_meta_data( '_total_price_npa', $values['app_price_npa'] * $values['quantity'] );
}
$item->set_subtotal( $item->get_meta( '_app_price_npa' ) );
$item->set_total( $item->get_meta( '_total_price_npa' ) );
}
add_filter( 'woocommerce_order_formatted_line_subtotal', 'blow_set_points_npa_emails_orders', 10, 3 );
function blow_set_points_npa_emails_orders( $subtotal, $item, $order ) {
$price_points = $item->get_meta( '_total_points' ) ? blow_points( $item->get_meta( '_total_points' ) ) : '';
$price_npa = $item->get_meta( '_total_price_npa' ) ? wc_price( $item->get_meta( '_total_price_npa' ) ) : $subtotal;
return $price_npa . $price_points;
}
Это добавление произвольных полей, но с весами принцип тот жеДА
ДА
O
AL
O
O
O
O
НМ