In the product API reference for Shopify, there is a published parameter, which I keep changing to "false", however this does not do anything to hide the desired products.
I have also tried to change the published date to 'null', which does not work and also tried to change this date to a date in the future, which also does not work (i.e. publish it later in the month).
My last attempt, which worked, was to use tags and the Shopify theme files with regex, however this technique does not generalise well to every Shopify theme and only works with debut.
It can't be this hard to make a product sold out using the API!!! Any ideas guys?
You can do this by setting the value of published_at to null or empty value
product = shopify.Product.find(123456789) product.published_at = None product.save()
product = ShopifyAPI::Product.find(123456789) product.published_at = nil product.save
In PHP using cURL:
$data = array( 'product' => array( 'id' => 123456789, 'published_at' => '') ); $url = "https://$api_key:$api_pass@$store_handle.myshopify.com/admin/products/123456789.json"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close($curl);
I hope this helps!