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];