Skip to content

Commit 332608a

Browse files
refactor: undo cartResult rename
1 parent f9281af commit 332608a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: Samples/MobileBuyIntegration/MobileBuyIntegration/CartManager.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CartManager: ObservableObject {
4444
* Represents the `cart.totalTaxAmount.amount`
4545
* Due to BuySDK throwing if you access a property that hasn't been requested
4646
* this is separated off from the cart due to this behaviour, as the `totalTaxAmount` is
47-
* deprecated from cart operations except prepareForCompletion
47+
* deprecated from cart operations except prepareForCompletion
4848
*/
4949
@Published var tax: Decimal?
5050
@Published var isDirty: Bool = false
@@ -418,20 +418,23 @@ class CartManager: ObservableObject {
418418

419419
guard
420420
let result = payload.result as? Storefront.CartStatusReady,
421-
let cartResult = result.cart
421+
let cart = result.cart
422422
else {
423423
throw Errors.invariant(
424424
message: "CartPrepareForCompletionResult is not CartStatusReady")
425425
}
426426

427427
DispatchQueue.main.async {
428-
self.cart = cartResult
429-
if let tax = cartResult.cost.totalTaxAmount?.amount {
428+
self.cart = cart
429+
/**
430+
* Note - `totalTaxAmount` will not be available on self.cart, only access local value
431+
*/
432+
if let tax = cart.cost.totalTaxAmount?.amount {
430433
self.tax = tax
431434
}
432435
}
433436

434-
return cartResult
437+
return cart
435438
} catch {
436439
throw Errors.apiErrors(requestName: "cartSubmitForCompletion", message: "\(error)")
437440
}

0 commit comments

Comments
 (0)