File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,4 +133,14 @@ public function removeCoupon(string|Coupon $coupon): void;
133133 * Get the applicable discount rules.
134134 */
135135 public function getApplicableDiscountRules (): Collection ;
136+
137+ /**
138+ * Get the discount total.
139+ */
140+ public function getDiscountTotal (): float ;
141+
142+ /**
143+ * Get the formatted discount total.
144+ */
145+ public function getFormattedDiscountTotal (): string ;
136146}
Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ public function toOrder(): Order
209209 $ this ->order ->applyCoupon ($ coupon );
210210 });
211211
212+ $ this ->order ->calculateDiscount ();
212213 $ this ->order ->calculateTax ();
213214 });
214215 } catch (Throwable $ exception ) {
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ public function getFormattedGrossPrice(): string
246246 */
247247 public function getTotal (): float
248248 {
249- return $ this ->getGrossPrice () * $ this ->getQuantity ();
249+ return ( $ this ->getGrossPrice () * $ this ->getQuantity ()) - $ this -> getDiscount ();
250250 }
251251
252252 /**
Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ public function getFormattedGrossPrice(): string
248248 */
249249 public function getTotal (): float
250250 {
251- return $ this ->getGrossPrice () * $ this ->getQuantity ();
251+ return ( $ this ->getGrossPrice () * $ this ->getQuantity ()) - $ this -> getDiscount ();
252252 }
253253
254254 /**
Original file line number Diff line number Diff line change @@ -449,6 +449,16 @@ public function getDiscount(): float
449449 {
450450 $ value = $ this ->__getDiscount ();
451451 $ value += $ this ->coupons ->sum ('coupon.value ' );
452+
453+ return $ value ;
454+ }
455+
456+ /**
457+ * Get the discount total.
458+ */
459+ public function getDiscountTotal (): float
460+ {
461+ $ value = $ this ->getDiscount ();
452462 $ value += ($ this ->needsShipping () ? $ this ->shipping ->getDiscount () : 0 );
453463 $ value += $ this ->items ->sum (static function (Item $ item ): float {
454464 return $ item ->getDiscount ();
@@ -457,6 +467,14 @@ public function getDiscount(): float
457467 return $ value ;
458468 }
459469
470+ /**
471+ * Get the formatted discount total.
472+ */
473+ public function getFormattedDiscountTotal (): string
474+ {
475+ return $ this ->getCurrency ()->format ($ this ->getDiscountTotal ());
476+ }
477+
460478 /**
461479 * Get the discountable currency.
462480 */
You can’t perform that action at this time.
0 commit comments