Last active
July 24, 2019 19:45
-
-
Save nspeet/e08142e8f56d0abba423bb4049cdf9a1 to your computer and use it in GitHub Desktop.
Cart Checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cart.active(result: { result in | |
if let cart = result.model, result.isSuccess { | |
// Cart successfully retrieved, response contains currently active cart | |
Cart.byId(cart.id, result: { result in | |
if let cart = result.model, result.isSuccess { | |
// successfully retrieved current cart | |
let draftOrder = OrderDraft(id: cart.id, version: cart.version); | |
Order.create(draftOrder, result: { result in | |
if let order = result.model, result.isSuccess { | |
// order successfully created, response contains updated order | |
let alertController = UIAlertController(title: NSLocalizedString("Orders Placed",comment:""), message: NSLocalizedString( "",comment:""), preferredStyle: .alert) | |
let defaultAction = UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .default, handler: { (pAlert) in | |
}) | |
alertController.addAction(defaultAction) | |
self.present(alertController, animated: true, completion: nil) | |
} | |
} | |
)} | |
} | |
)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment