How to print the cart items,remove cart items in shopify ios sdk?

情到浓时终转凉″ 提交于 2019-12-08 05:43:42

问题


Hi I'm using Shopify ios sdk for my e-commerce app.I created login,signup and even list out the products in table view.I need to view products in my cart.So far I found only buyCart.clear; in shopify which clears all the cart item. I tried to print cart items by BUYProductVariant *variant = cartArray[i]; but it produces error.I struck here and don't know how to proceed further. Can any one help me to solve this and thanks in advance.


回答1:


This is how you get BUYProduct from BUYCart

BUYCart *cartvalue = yourCart;

NSMutableArray *arrCartProducts = [NSMutableArray new];

arrCartProducts = [[cartvalue lineItems]mutableCopy];

// I am assuming you have at least one product in your cart

if (arrCartProducts.count !=0 ) {
    BUYCartLineItem *cartLintItemvalue=[arrCartProducts objectAtIndex:0] ;
    BUYProductVariant *variantsValue=[cartLintItemvalue variant];
    BUYProduct *product= [variantsValue product];
}

and this is how you remove BUYProductVariant from BUYCart

BUYCartLineItem *cartLintItemvalue=[arrCartProducts objectAtIndex:0];
BUYProductVariant *variantsValue=[cartLintItemvalue variant];
[cartvalue removeVariant:variantsValue];


来源:https://stackoverflow.com/questions/40904455/how-to-print-the-cart-items-remove-cart-items-in-shopify-ios-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!