This file contains 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
// Add the code below to viewDidLoad() | |
// Default configuration initializer reads from | |
// CommercetoolsConfig.plist file from your app bundle | |
if let configuration = Config() { | |
// You can also specify custom logging level | |
// configuration.logLevel = .error | |
// Or completely disable all log messages from Commercetools SDK | |
// configuration.loggingEnabled = false | |
// Finally, you need set your configuration before using the SDK | |
Commercetools.config = configuration |
This file contains 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
// Step 1. create a menu button to select products | |
// Then on this menu button click... search for products, you can set a filter as required | |
ProductProjection.search(sort: ["name.en asc"], limit: 10, lang: Locale(identifier: "en"), { result in | |
if let response = result.model, let total = response.total as? UInt, | |
let results = response.results as? Array<ProductProjection>, result.isSuccess { | |
//handle showing results | |
} | |
.... |
This file contains 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
//1. Check if the PKPaymentAuthorizationViewController can make payments | |
if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks) { | |
// develop your payment request | |
let request = PKPaymentRequest() | |
request.merchantIdentifier = "merchant.yourmerchantid" //add more info to the payment request as needed | |
//2. Then present the Apple Pay authorizationViewController | |
let authorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: request) | |
if let viewController = authorizationViewController { | |
viewController.delegate = self |
This file contains 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
//.dae file | |
var object3D: SCNNode! | |
let chair = SCNScene(named: "art.scnassets/furniture/chair/bag-chair.dae") | |
object3D = chair?.rootNode; | |
self.object.removeFromParentNode() | |
self.object = object3D; | |
//.obj file | |
let url = URL.init(string: "https://3D2348.com/couch.obj") | |
let entity = MDLAsset(url: url) |
This file contains 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 |
This file contains 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
// Create Cart | |
using (var client = new HttpClient()) | |
{ | |
// assembledEndpoint: {{host}}/{{projectKey}}/me/carts | |
var endpoint = assembledEndpoint; | |
var body = new Dictionary<string, string> | |
{ | |
{ "currency", "USD" }, | |
{ "shippingAddress", { | |
"country": "US" |
This file contains 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
// add line item to Cart | |
using (var client = new HttpClient()) | |
{ | |
// assembledEndpoint: {{host}}/{{projectKey}}/me/carts/cartId | |
var endpoint = assembledEndpoint; | |
var body = new Dictionary<string, string> | |
{ | |
{ "version", "1" }, | |
{ "actions": [{ | |
"action": "addLineItem", |
This file contains 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
let timer = Timer.scheduledTimer(timeInterval: 5.0, target: self, selector: #selector(updateData), userInfo: nil, repeats: true) | |
@objc func updateData() { | |
print("update data here and then display!") | |
} |