File tree Expand file tree Collapse file tree 5 files changed +25
-19
lines changed
Expand file tree Collapse file tree 5 files changed +25
-19
lines changed Original file line number Diff line number Diff line change 44
55namespace Cone \Bazar \Interfaces ;
66
7+ use Cone \Bazar \Enums \Currency ;
78use Cone \Bazar \Models \DiscountRule ;
89use Illuminate \Database \Eloquent \Relations \MorphToMany ;
910use Illuminate \Support \Collection ;
@@ -64,4 +65,9 @@ public function getDiscountableQuantity(): float;
6465 * Get the applicable discount rules.
6566 */
6667 public function getApplicableDiscountRules (): Collection ;
68+
69+ /**
70+ * Get the discountable currency.
71+ */
72+ public function getDiscountableCurrency (): Currency ;
6773}
Original file line number Diff line number Diff line change 55namespace Cone \Bazar \Models ;
66
77use Cone \Bazar \Database \Factories \ItemFactory ;
8+ use Cone \Bazar \Enums \Currency ;
89use Cone \Bazar \Interfaces \Buyable ;
910use Cone \Bazar \Interfaces \Models \Item as Contract ;
1011use Cone \Bazar \Traits \InteractsWithDiscounts ;
@@ -350,10 +351,10 @@ public function getApplicableDiscountRules(): Collection
350351 }
351352
352353 /**
353- * Get the formatted discount .
354+ * Get the discountable currency .
354355 */
355- public function getFormattedDiscount (): string
356+ public function getDiscountableCurrency (): Currency
356357 {
357- return $ this ->checkoutable ->getCurrency ()-> format ( $ this -> getDiscount ()) ;
358+ return $ this ->checkoutable ->getCurrency ();
358359 }
359360}
Original file line number Diff line number Diff line change 55namespace Cone \Bazar \Models ;
66
77use Cone \Bazar \Database \Factories \ShippingFactory ;
8+ use Cone \Bazar \Enums \Currency ;
89use Cone \Bazar \Interfaces \Models \Shipping as Contract ;
910use Cone \Bazar \Support \Facades \Shipping as Manager ;
1011use Cone \Bazar \Traits \Addressable ;
@@ -350,11 +351,11 @@ public function getDiscountableQuantity(): float
350351 }
351352
352353 /**
353- * Get the formatted discount .
354+ * Get the discountable currency .
354355 */
355- public function getFormattedDiscount (): string
356+ public function getDiscountableCurrency (): Currency
356357 {
357- return $ this ->shippable ->getCurrency ()-> format ( $ this -> getDiscount ()) ;
358+ return $ this ->shippable ->getCurrency ();
358359 }
359360
360361 /**
Original file line number Diff line number Diff line change 2929use Illuminate \Support \Arr ;
3030use Illuminate \Support \Collection ;
3131use Illuminate \Support \Facades \App ;
32- use Illuminate \Support \Number ;
3332use Throwable ;
3433
3534trait AsOrder
@@ -342,7 +341,6 @@ public function calculateTax(): float
342341 */
343342 public function findItem (array $ attributes ): ?Item
344343 {
345-
346344 $ attributes = array_merge (['properties ' => null ], $ attributes , [
347345 'checkoutable_id ' => $ this ->getKey (),
348346 'checkoutable_type ' => static ::class,
@@ -459,19 +457,11 @@ public function getDiscount(): float
459457 }
460458
461459 /**
462- * Get the formatted discount.
463- */
464- public function getFormattedDiscount (): string
465- {
466- return $ this ->getCurrency ()->format ($ this ->getDiscount ());
467- }
468-
469- /**
470- * Get the formatted discount rate.
460+ * Get the discountable currency.
471461 */
472- public function getFormattedDiscountRate (): string
462+ public function getDiscountableCurrency (): Currency
473463 {
474- return Number:: percentage ( $ this ->getDiscountRate () );
464+ return $ this ->getCurrency ( );
475465 }
476466
477467 /**
Original file line number Diff line number Diff line change @@ -110,4 +110,12 @@ public function calculateDiscount(): float
110110
111111 return $ this ->getDiscount ();
112112 }
113+
114+ /**
115+ * Get the formatted discount.
116+ */
117+ public function getFormattedDiscount (): string
118+ {
119+ return $ this ->getDiscountableCurrency ()->format ($ this ->getDiscount ());
120+ }
113121}
You can’t perform that action at this time.
0 commit comments