1
votes

I'm making a private application for my Shopify store. The application is supposed to replace the standard checkout process. Everything works well, the order is sent to my Shopify store and I can see it in the admin area, the only problem I'm facing is that after the order is placed the cart properties will not reset (the customer's products are still present in the cart and the most important, the cart token does not change). Anyone has any idea why is this happening and how I can fix it? I was thinking that maybe I'm not sending enough information to the store but I might be wrong. This is what i'm sending:

$product = $shopify('POST /admin/orders.json', array(), array
    (
      'order' => array
      (
        "email" => $email,
        "fulfilment_status" => "",
        "send_receipt" => true,
        "line_items" => $products,
        'customer' => array
        (
          "first_name" => $firstName,
          "last_name" => $name,
          "email" => $email
        ),
        'billing_address' => array
        (
          "first_name" => $firstName,
          "last_name" => $name,
          "address1" => $adress,
          "phone" => $telefon,
          "city" => $city,
          "province" => $province,
          "country" => $country,
          "zip" => $zip
        ),
        'note_attributes' => array (
        array("name" => "Company", "value" => $company),
        array("name" => "CUI","value" => $cui),
        array("name" => "Registration","value" => $reg)
        ),
        'shipping_address' => array
        (
          "first_name" => $firstName,
          "last_name" => $name,
          "address1" => $adress,
          "phone" => $phone,
          "city" => $city,
          "province" => $province,
          "province_code" => $provinceCode,
          "name" => $firstName." ".$name,
          "country_code" => $countryCode,
          "country" => $country,
          "zip" => $zip
        ),
        'shipping_lines' => $shipping,
        'financial_status' => 'pending'
      )
    ));
1

1 Answers

1
votes

Once you do the POST, there'll be a order_status_url field in the response data. Take the user to that URL and the cart will be reset.

Please note, that the order_status_url will be null unless the order is completed with the checkout processes.

Correction: Orders place through API can't be taken to the checkout process, in this case check below.

You can clear the cart by doing an AJAX GET to /cart/clear.js You can clear the attributes/note by doing AJAX POST to /cart/update.js with "attributes": {} or "note":"" respectively.