File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ These snippets might come in handy... they're all pretty self-explanatory:
5757* ` {{ cart:sub_total }} `
5858* ` {{ cart:discount_total }} `
5959* ` {{ cart:tax_total }} `
60+ * ` {{ cart:line_item_tax_total }} `
61+ * ` {{ cart:shipping_tax_total }} `
6062* ` {{ cart:shipping_total }} `
6163* ` {{ cart:is_free }} `
6264* ` {{ cart:has_physical_products }} `
Original file line number Diff line number Diff line change 77use DuncanMcClean \Cargo \Orders \LineItem ;
88use Statamic \Data \AbstractAugmented ;
99use Statamic \Fields \Field ;
10+ use Statamic \Fields \Value ;
1011
1112class AugmentedCart extends AbstractAugmented
1213{
@@ -47,6 +48,7 @@ private function commonKeys(): array
4748 'tax_breakdown ' ,
4849 'has_physical_products ' ,
4950 'has_digital_products ' ,
51+ 'line_items_tax_total ' ,
5052 ];
5153 }
5254
@@ -126,4 +128,18 @@ public function hasDigitalProducts(): bool
126128 ->filter (fn (LineItem $ lineItem ) => $ lineItem ->product ()?->get('type ' , 'physical ' ) === 'digital ' )
127129 ->isNotEmpty ();
128130 }
131+
132+ public function lineItemsTaxTotal ()
133+ {
134+ $ moneyField = new Field ('line_items_tax_total ' , [
135+ 'type ' => 'money ' ,
136+ 'save_zero_value ' => true ,
137+ ]);
138+
139+ return new Value (
140+ value: $ this ->data ->lineItems ()->sum ('taxTotal ' ),
141+ fieldtype: $ moneyField ->fieldtype (),
142+ augmentable: $ this ->data
143+ );
144+ }
129145}
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ private function commonKeys(): array
4444 'tax_breakdown ' ,
4545 'has_physical_products ' ,
4646 'has_digital_products ' ,
47+ 'line_items_tax_total ' ,
4748 'downloads ' ,
4849 ];
4950 }
You can’t perform that action at this time.
0 commit comments