• Resolved julianblauw

    (@julianblauw)


    Hi,

    I am back again with another question. The merge feature is not working correctly for me in Flutter. The cart does get merged but the row does not get deleted in the database when using Flutter.

    It only works when I merge the cart of a guest to a logged-in user in Postman. Then the row is removed in the CoCart table.

    P.S. I updated all the WP plugins already ??

    Do you have any idea why this is happening?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    I’m not sure why the previous cart would not remove it self after merge when doing it in Flutter but eventually the cart will expire within 7 days (by default).

    Unfortunatly, I have no experience with Flutter so it’s out of my expertise.

    Thread Starter julianblauw

    (@julianblauw)

    The code is actually not that hard in Flutter and it looks like javascript. Maybe you can see something I am missing. If you don’t know it, it is also fine!
    It is a simple get request and it adds the ‘?cart_key=’ when it has a cart key.

    
      static Future<Cart> getCart() async {
        String? token = await Auth().getToken();
        String? cartKey = "";
        String url = 'https://websitename.com/wp-json/cocart/v2/cart';
        Map<String, String> myHeaders = {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
        };
    
        if (token != null) {
          myHeaders['Authorization'] = 'Bearer $token';
        }
    
        cartKey = await Auth().getCartKey();
        if (cartKey != null) {
          String addOn = '?cart_key=${cartKey}';
          url = url + addOn;
        }
        var response = await http.get(
          Uri.parse(url),
          headers: myHeaders,
        );
    
        if (response.statusCode == 200) {
          return Cart.fromJson(jsonDecode(response.body));
        } else {
          throw Message.fromJson(jsonDecode(response.body));
        }
      }

    Thanks!

    Plugin Author Sébastien Dumont

    (@sebd86)

    It could be a server issue just not completing the action. Maybe increase the time allowed for the request.

    Thread Starter julianblauw

    (@julianblauw)

    I tried to increase the timeout amount with ‘.timeout(Duration(seconds: 120))’. But the behavior is still the same.

    Plugin Author Sébastien Dumont

    (@sebd86)

    I honestly don’t have a clue. I’m out of ideas. LOL… Sorry

    Closing ticket as a mystery unsolved.

    Thread Starter julianblauw

    (@julianblauw)

    Haha, no problem. Thank you for your help! I think you clicked the wrong button, it is saying ‘resolved’ right now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Merge carts working in postman but not in Flutter’ is closed to new replies.