Skip to content

Instantly share code, notes, and snippets.

@nspeet
Last active July 24, 2019 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nspeet/e08142e8f56d0abba423bb4049cdf9a1 to your computer and use it in GitHub Desktop.
Save nspeet/e08142e8f56d0abba423bb4049cdf9a1 to your computer and use it in GitHub Desktop.
Cart Checkout
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