Giter Site home page Giter Site logo

I have problems using Cart about woocommerce HOT 11 OPEN

rayokaah avatar rayokaah commented on August 17, 2024 1
I have problems using Cart

from woocommerce.

Comments (11)

CarloDotLog avatar CarloDotLog commented on August 17, 2024 1

Hi, me too. My attempts never succeeded. So I've skipped the problem and I have adopted the CoCart plugin with this add-on enabled.
I've made implementation at the app level, so I've no changed the library.
I hope this can help.
Happy coding.

from woocommerce.

CarloDotLog avatar CarloDotLog commented on August 17, 2024 1

Yes, I use CoCart only to manage the cart. So I can add/remove items to the cart and every change is saved on WordPress DB.
You can continue to use this library and add your code to implement CoCart.

from woocommerce.

CarloDotLog avatar CarloDotLog commented on August 17, 2024 1

Hi! No, there is no Flutter documentation.
You can find the plugin documentation here . You need to create the CoCart entities classes and then call the CoCart endpoints. As I said, I suggest using this add-on.
Happy conding!

from woocommerce.

ngominhtrungit avatar ngominhtrungit commented on August 17, 2024 1

Thank you.i use it. Thank for share. If i has issue. Pls help thank

from woocommerce.

CarloDotLog avatar CarloDotLog commented on August 17, 2024 1

@federico2390 As I said, this code is 15 months old.. I think you must update it. =/
If you need help, we could see it together.

For the entities, I have a Gist --> https://gist.github.com/CarloDotLog/d85d24e6e23e2f019386c5f737d1216d

The following method add an Item or Variation to CoCart.
It's based on v1 CoCart API and woocommerce: ^0.9.7.

static const String URL_COCART_API_PATH = "/wp-json/cocart/v1/";

/// Accepts an int [productId] of a product, int quantity, int [variationId] of a product or product variation
/// Related endpoint : cocart/v1/add-item
///
Future<Items> addItemToCoCart({required String cartKey, required int productId, required int quantity, int? variationId}) async {
  Map<String, dynamic> data = {
    'cart_key': cartKey,
    'product_id': "$productId",
    'quantity' : "$quantity",
  };
  if(variationId!=null) data['variation_id'] = "$variationId";
  debugPrint("$data");
  
  String authToken = await wooCommerce.getAuthTokenFromDb();
  _urlHeader['Authorization'] = 'Bearer $authToken';
  
  final response = await http.post(Uri.parse(baseUrl + URL_COCART_API_PATH + "add-item"), headers: _urlHeader, body: data);
  debugPrint(baseUrl + URL_COCART_API_PATH + 'add-item');

  if (response.statusCode >= 200 && response.statusCode < 300) {
    final jsonStr = json.decode(response.body);

    debugPrint("added to my cart : "+jsonStr.toString());
    return Items.fromJson(jsonStr);
  } else {
    WooCommerceError err = WooCommerceError.fromJson(json.decode(response.body));
    throw err;
  }
}

from woocommerce.

ngominhtrungit avatar ngominhtrungit commented on August 17, 2024

Only cart use cocart? Because now i use my phone, I don't search

from woocommerce.

ngominhtrungit avatar ngominhtrungit commented on August 17, 2024

Yeah! I'm try it, But I will try to code using WooCart of the woocommercer package. thank you.

from woocommerce.

ngominhtrungit avatar ngominhtrungit commented on August 17, 2024

Yes, I use CoCart only to manage the cart. So I can add/remove items to the cart and every change is saved on WordPress DB.
You can continue to use this library and add your code to implement CoCart.

hello, do you have documentation on flutter with cocart plugin?

from woocommerce.

federico2390 avatar federico2390 commented on August 17, 2024

@CarloDotLog Do u have an example of api for adding item in cart with cocart?

from woocommerce.

CarloDotLog avatar CarloDotLog commented on August 17, 2024

Yes I have something.. somewhere... I use this package into an old project dated 1+ year.
I'll update you as soon as I find the code 😉

from woocommerce.

federico2390 avatar federico2390 commented on August 17, 2024

@CarloDotLog Yes please if u find the code can share here or via mail?
Thx for help

from woocommerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.