codeswholesale / codeswholesale-sdk-php

A PHP wrapper for CodesWholesale's API
Apache License 2.0
36 stars 21 forks source link

Client error: `POST https://api.codeswholesale.com/v2/orders` resulted in a `400 Bad Request` response: {"status":400,"code":310003,"message":"Cannot complete, too low stock." #41

Closed fefrik closed 4 years ago

fefrik commented 4 years ago

Hi,

After changes in CW API, We are not able to create new order! All our orders ended with error code 400 Bad Request response: {"status":400,"code":310003,"message":"Cannot complete, too low stock."}

When I call GET /product request, I got correct quantity state, that is similar with CW pricelist, so product is on stock:

        $product = \CodesWholesale\Resource\Product::get("https://api.codeswholesale.com/v2/products/" . $link);

        echo "Name: " . $product->getName() . "<br>";
        echo "BuyHref: " . $product->getBuyHref() . "<br>";
        echo "DefaultPrice: " . $product->getDefaultPrice() . "<br>";
        echo "LowestPrice: " . $product->getLowestPrice() . "<br>";
        echo "Quantity: " . $product->getStockQuantity() . "<br>";

But when I create order, I got error 400 Bad Request` response: {"status":400,"code":310003,"message":"Cannot complete, too low stock."

$createdOrder = \CodesWholesale\Resource\Order::createOrder(
            [
                [
                    "productId" => $product->getProductId(),
                    "quantity" => $orderItem->getCount(),
                ],
            ], null);

Please, Can you look on it. We have to handle all orders manually now... :-(

Thank you

officialmmt commented 4 years ago

If you check api you will see there is only one price now. https://codeswholesale.com/integration/docs/v2 and some products have an error with changes too. They going for big changes so maybe we have to wait for it.

fefrik commented 4 years ago

It seems to be fixed on backend side. Now it works fine.