2

I'm implementing @sandeep shetty shopify api to insert records into my shopify store. I have implemented insertion completely and working fine for my store. I'm facing problem during update. I'm unable to update records that are being inserted in store. I'm updating records as per their id being generated by api after insertion.
Here is my code that i have written for update product.

Array that will pass as parameter in shopify api call.

$product = array
    (

        "product" => array
        (
            "variants" => array
                (
                    "price" =>  $cat['selling_price'],
                    "inventory_quantity"=>($cat['original_qty']!="") ? $cat['original_qty'] : 'Null',
                )
        )
    );

Code for update product.

$update = $shopify('PUT', "/admin/products/#{id}.json", $product); 
1
  • I went ahead and deleted my answer. So I assume the $shopify method is replacing the {id}? As the #{id} is pseudo code. What error messages are you getting back? Commented Nov 9, 2012 at 15:46

1 Answer 1

3

I used to provide the ID inside the json data. Code that I use:

$data_string = '
{
    "variant": {
        "id": "'.$idVar.'",
        "option1": "'.$this->input->post('variant').'",
        "price": "'.$this->input->post('salesPrice').'",
        "inventory_quantity": "'.$this->input->post('stockQty').'"
    }
}
';

To update variant I use the following url:

/admin/variants/".$idVar.".json"

Also, use 000000000.json, removing the # symbol.

Sign up to request clarification or add additional context in comments.

1 Comment

it's really good one and very handy in case of updating quantity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.