Tebogo Sewape
Tebogo Sewape

Reputation: 94

Vend API updating a product

i'm trying to update a product in vend using their API, if i update anything but price i get it updated in the dashboard, but when i try price the API returns success but nothing has changed in the dashboard.

Here is my code:

    public function updateProductByID( $productID, $price, $access_token, $ProductUrl ) {
        $aupdateProduct = '
                {
                    "id": "b8ca3a6e-728c-11e4-efc6-9a4ac50e8ba7",
                    "price_book_entries": 
                        [ { "price" : 100 }], 
                    "price": 100
                }' ;
        $ch = curl_init() ;
        curl_setopt( $ch, CURLOPT_URL, $ProductUrl ) ;
        curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" ) ;
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $aupdateProduct ) ;
        curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer '.$access_token ) ) ;
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ) ;
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ) ;
        $result = curl_exec( $ch ) ;
        var_dump($result) ;
        curl_close($ch) ;
    }

Is there anything im missing? thanx in adv

Upvotes: 1

Views: 472

Answers (1)

Tebogo Sewape
Tebogo Sewape

Reputation: 94

I have found a solution, the price when you update is retail_price so my code had to change to:

    $aupdateProduct = '
            {
                "id": "b8ca3a6e-728c-11e4-efc6-9a4ac50e8ba7",
                "retail_price": "100"
            }' ;

I hope it helps someone with the same problem.

Upvotes: 1

Related Questions