• Resolved iworys

    (@iworys)


    Hi, is it possible to use your plugin for an unauthorized user?

    I would like to add products in the e-shop and then send the user to the cart to complete the order.

    The API requires an API token that is bound to the user. Is it possible to store the cart in a cookie only and then retrieve the cart from the cookie when the cart is navigated?

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

    (@sebd86)

    Hi, is it possible to use your plugin for an unauthorized user?

    Yes. When you add the first item to the cart you will get a cart key in the header response.

    Use that cart key for all further requests by adding it to the endpoint like so: ?cart_key={cartkeygoeshere}

    Thread Starter iworys

    (@iworys)

    Thank you, but the API initialization wants some user’s authorization keys and then stores everything against that account. That doesn’t sound like unauthorized access to me.

    Plugin Author Sébastien Dumont

    (@sebd86)

    API initialization wants some user’s authorization keys.

    Can you explain more on what your doing and getting then for clarification?

    Thread Starter iworys

    (@iworys)

    On my domain shop.myproject.com I have wordpress running with woocomerce and your plugin.

    On myproject.com domain I have VueJS application with products.

    My idea is that every visitor of the site can make a purchase without registration.
    I would add products to the cart through your plugin (CoCart.post(“cart/add-item”, data)…?).
    When he wants to complete the order, I would send him to shop.myproject.com directly to the cart where he could complete the order.

    Now I have a follow-up experiment:

    
    const coCart = new CoCartAPI({
       url: "https://shop.myproject.com",
       consumerKey: 'ck_acf0ac0906c...8', // required
       consumerSecret: 'cs_ce9f6123...22, // required
    });

    (consumerKey, consumerSecret) are required and bound to the user registered in the e-shop.

    Add to cart:

    
    const data = {"quantity": "1", "id": "12"}
    coCart.post("cart/add-item", data) // returns cart_key "1"
    

    Load cart:
    coCart.get("cart/items", {"cart_key": "1" }) // return error code 403

    I don’t know if I’m doing everything right and if it’s even possible to achieve my idea.
    If I need to buy a plugin, I have no problem, but I don’t know if it will help.

    Thank you for an answer

    Plugin Author Sébastien Dumont

    (@sebd86)

    Consumer Key and Consumer Secret are tokens created by WooCommerce API. Using these will authenticate the user they are assigned to.

    Anyway, the CoCart JS Wrapper is designed for the REST API only!

    If you wish to load a cart on the frontend, this guide will help you. https://cocart.dev/guide/load-cart-from-session/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘NOT authenticating users’ is closed to new replies.