Commit 9d576b5 1 parent a988310 commit 9d576b5 Copy full SHA for 9d576b5
File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -160,16 +160,16 @@ public function taxTotalSplit(): Collection
160
160
161
161
public function rawTaxTotalSplit (): Collection
162
162
{
163
- return collect ($ this ->items ())
164
- ->groupBy (function ($ item ) {
165
- return $ item ['tax ' ]['rate ' ];
166
- })
167
- ->map (function ($ group , $ groupRate ) {
163
+ if (! $ this ->hasCart ()) {
164
+ return collect ();
165
+ }
166
+
167
+ return $ this ->getCart ()->lineItems ()
168
+ ->groupBy (fn ($ lineItem ) => $ lineItem ->tax ()['rate ' ])
169
+ ->map (function ($ group , $ rate ) {
168
170
return [
169
- 'rate ' => $ groupRate ,
170
- 'amount ' => $ group ->sum (function ($ item ) {
171
- return $ item ['tax ' ]['amount ' ];
172
- }),
171
+ 'rate ' => $ rate ,
172
+ 'amount ' => $ group ->sum (fn ($ lineItem ) => $ lineItem ->tax ()['amount ' ]),
173
173
];
174
174
})
175
175
->values ();
Original file line number Diff line number Diff line change 429
429
$ taxReduced = $ cartProduct3 ->tax ()['amount ' ];
430
430
$ taxReducedFormatted = Currency::parse ($ taxReduced , Site::default ());
431
431
432
+ // Expected tag output format = '19:1234|7:5678'
433
+ $ renderedTag = (string ) tag ('{{ sc:cart:rawTaxTotalSplit }}{{ rate }}:{{ amount }}|{{ /sc:cart:rawTaxTotalSplit }} ' );
434
+
435
+ expect ($ renderedTag )->toContain ($ taxRateDefault ->rate ().': ' .$ taxDefault );
436
+ expect ($ renderedTag )->toContain ($ taxRateReduced ->rate ().': ' .$ taxReduced );
437
+
432
438
// Expected tag output format = '7:£12.34|19:£56.78'
433
439
$ renderedTag = (string ) tag ('{{ sc:cart:taxTotalSplit }}{{ rate }}:{{ amount }}|{{ /sc:cart:taxTotalSplit }} ' );
434
440
You can’t perform that action at this time.
0 commit comments