gilokimu / WooDroid

Simple, robust Woocommerce API sdk for java and android
84 stars 39 forks source link

Cart Woo endpoint #4

Closed ProgrammerN closed 5 years ago

ProgrammerN commented 5 years ago

404 Not Found https://example.com/wp-json/wc/v2/cart The woocommerce rest API seems not to have such an endpoint.Instead you should use oders endpoint and handle the cart in your own way

gilokimu commented 5 years ago

You have to use this https://github.com/co-cart/co-cart plugin, however I was not able to get it to work, I will pull down the cart endpoint until when I find a better solution

ProgrammerN commented 5 years ago

I seem to have noticed that issue with cookies but however they still fail at some point.Adding both interceptors at once has issues and you have to make a separate connection for received cookies and another for add cookies data respectively with receiving cart information and sending cart data.

gilokimu commented 5 years ago

That is literally what I had done, see below

OkHttpClient client = new OkHttpClient.Builder()
                .addInterceptor(new AddCookiesInterceptor(context))
                .addInterceptor(new ReceivedCookiesInterceptor(context))
                .addInterceptor(loggingInterceptor)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .connectTimeout(15, TimeUnit.SECONDS)
                .build();

I would intercept on any request to cart and add the cookies and capture any response from the cart api and store cookies. The implemented cart api does not work with woocommerce authentication

gilokimu commented 5 years ago

This has now been implemented through firebase but on the sample app