Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: type 'String is not a subtype of type int. #55

Open
Benkot1 opened this issue Apr 13, 2021 · 2 comments
Open

Error: type 'String is not a subtype of type int. #55

Benkot1 opened this issue Apr 13, 2021 · 2 comments

Comments

@Benkot1
Copy link

Benkot1 commented Apr 13, 2021

class WooCommerceApi {
WooCommerce prodMode = WooCommerce(
baseUrl: Config.url,
consumerKey: Config.key,
consumerSecret: Config.secret,
isDebug: true,
);

Future<List> getProductsRealDomain() async {
final dynamic myProducts = await prodMode.getProducts();
print("WooCommerceApi === getProducts1 : ${myProducts.length}");
return myProducts;
}
}

products shows in debug console but gives error on screen.
When I debug, it directs me to WooProduct - totalSales in the package.
Please Any help. Thanks

@MubeenMurj
Copy link

I also faced the same issue while fetching the products.
final fetchedProducts = await woocommerce.getProducts( orderBy: 'price', order: 'asc', );

After digging into the problem, I found out the issue lies in the fetched response from the Woocommerce API.
In JSON response from API, the type of total_sales for every product was int, as expected. Except for one whose, total_sales value was of type String, "0".
In my case, that product was a draft with no SKU (this is not a confirmed scenario, other products with the same config were working fine), so I added SKU and published it and afterward, the API started giving the correct response.

For now, you may check the product configuration, until this issue is fixed on the API side or check is added into the plugin.

@Fahroot
Copy link

Fahroot commented Feb 21, 2022

@MubeenMurj thank you man You are right 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants