ios - Shopify BUY SDK : Maintain cart items between view controllers
This is the first app I am developing involving Shopify's BUY SDK (https://github.com/Shopify/mobile-buy-sdk-ios) and cannot seem to figure the best way to maintain cart items across view controllers. If anyone has any experience with the mobile buy api for Shopify I would really appreciate any ideas on how this can be achieved.
For example, I haveShopViewController.swift
which is a generic browse view showing several items for sale. Upon clicking an item,BUYProductViewController.m
is presented displaying the item and its different variants. Upon clicking "Add to Cart" it will add that variant to the cart and dismissBUYProductViewController.m
. My issue lay in getting that newly added item back toShopViewController.swift
.
As I mentioned, any help would greatly be appreciated and thank you for taking the time to read my issue.
Answer
Solution:
You have to create one BUYCart property in AppDelegate and assign Domain, App_Id and API_key in didFinishLaunchingWithOptions.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.client = [[BUYClient alloc] initWithShopDomain:SHOP_DOMAIN
apiKey:API_KEY
appId:APP_ID];
return YES;
}
Now use BUYCart property in to cart. I have just complete one demo of Shopify.
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.