Support » Plugin: Cart REST API for WooCommerce - CoCart Lite » Remove cart Item not working

  • Resolved shaileshprajapati

    (@shaileshprajapati)


    $_REQUEST[‘cart_item_key’] = ‘26657d5ff9020d2abefe558796b99584’;

    $curl = curl_init();

    $args[‘cart_item_key’] = $_REQUEST[‘cart_item_key’];

    curl_setopt_array( $curl, array(
    CURLOPT_URL => $base_url.”/wp-json/cocart/v1/item”,
    CURLOPT_CUSTOMREQUEST => “DELETE”,
    CURLOPT_POSTFIELDS => $args,
    CURLOPT_RETURNTRANSFER => true,
    ) );

    $response = curl_exec($curl);

    curl_close($curl);

    echo $response;
    ——————————-
    Please check this code, remove cart item not working, it says “No items in cart”.

    Please suggests

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

    (@sebd86)

    Hello.

    “No items in cart” means the cart is empty. If it said “Item in cart does not exist” then it would be because the cart item key was incorrect but there are no items to begin with.

    Is the cart for a guest customer?

    shaileshprajapati

    (@shaileshprajapati)

    yes it is for guest customer and cart item key also exist.

    Plugin Author Sébastien Dumont

    (@sebd86)

    What method for guest customers are you using and what code language?

    shaileshprajapati

    (@shaileshprajapati)

    <?php
    include(‘config.php’);

    $args[‘cart_key’] = $_REQUEST[‘cart_key’]; // this is generated by us
    $args[‘product_id’] = $_REQUEST[‘product_id’];
    $args[‘quantity’] = $_REQUEST[‘quantity’];

    if( $_REQUEST[‘product_type’] == ‘variable’ ) {
    $args[‘variation_id’] = $_REQUEST[‘variation_id’];
    foreach($_POST[‘variations’] as $key => $value)
    {
    $args[‘variation’][$key] = $value;
    }
    }

    $curl = curl_init();

    curl_setopt_array( $curl, array(
    CURLOPT_URL => $base_url.”/wp-json/cocart/v1/add-item”,
    CURLOPT_CUSTOMREQUEST => “POST”,
    CURLOPT_POSTFIELDS => $args,
    CURLOPT_RETURNTRANSFER => true
    ) );

    $response = curl_exec($curl);

    curl_close($curl);

    echo $response;


    We are using above code to add item to the cart. Please check it

    Plugin Author Sébastien Dumont

    (@sebd86)

    Your code looks fine to me. Latest patch should help too.

    shaileshprajapati

    (@shaileshprajapati)

    Please let me know what should cause the issue ?

    shaileshprajapati

    (@shaileshprajapati)

    Which latest patch are you suggesting to do ?

    Plugin Author Sébastien Dumont

    (@sebd86)

    Update CoCart.

    shaileshprajapati

    (@shaileshprajapati)

    I have updated the plugin but I am getting the same response:
    {“code”:”cocart_no_items”,”message”:”No items in cart.”,”data”:{“status”:404}}

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.