kloon / WooCommerce-REST-API-Client-Library

A PHP wrapper for the WooCommerce REST API
GNU General Public License v3.0
356 stars 175 forks source link

product->update() ... doesn't? #169

Closed i-make-robots closed 8 years ago

i-make-robots commented 8 years ago

Thank you for this sweet sweet library. You totally rock.

My keys were set up with read/write. I call

$obj = $wc_api->products->update( $product_id, '{
          "product": {
            "downloads": [
              {
                "file": "' . $newURL . '"
              }
            ]
          }
        }');
        print_r( $obj );

the returned $obj displays the old URL, and the product['updated_at'] value remains unchanged.

What am I doing wrong?

i-make-robots commented 8 years ago

Never mind! I was following http://stackoverflow.com/questions/29635202/woocommerce-downloadable-files-disappear-after-database-restore/36322809#36322809 which is out of date.

The correct format for the change is

$wc_api->products->update( $product_id, array('downloads'=>array(array('file'=>$newURL))));