Skip to content

Commit 3c89a24

Browse files
committed
Set discount line type.
1 parent 5686138 commit 3c89a24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Processor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ public function entry_post_save( $lead, $form ) {
378378
}
379379

380380
$line->set_total_amount( new Money( $value, $currency ) );
381+
382+
if ( $value->get_value() < 0 ) {
383+
$line->set_type( PaymentLineType::DISCOUNT );
384+
}
381385
}
382386

383387
if ( array_key_exists( 'quantity', $product ) ) {
@@ -411,6 +415,10 @@ public function entry_post_save( $lead, $form ) {
411415
$value = $value->multiply( Number::from_mixed( $line->get_quantity() ) );
412416

413417
$line->set_total_amount( new Money( $value, $currency ) );
418+
419+
if ( $value->get_value() < 0 ) {
420+
$line->set_type( PaymentLineType::DISCOUNT );
421+
}
414422
}
415423
}
416424
}

0 commit comments

Comments
 (0)