Saving Line Items without recalculating

Usually, whenever you add/remove/update line items, Simple Commerce will automatically recalculate your totals for you.

There are some cases where the totals continuously being recalculated can be a pain, so there's a way to turn it off while doing things...

1$this->withoutRecalculating(function () use ($calculate, $request) {
2 $this->clearLineItems();
4 collect($request->lineItems)
5 ->each(function ($lineItem) {
6 $this->addLineItem($lineItem);
7 });