How to hide Sold Out items?

Shopify Partner
14 0 2

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?

83 0 25

Hi Kyle,

You can do this by setting the value of published_at to null or empty value

In Python:

product = shopify.Product.find(123456789)
product.published_at = None

In Ruby:

product = ShopifyAPI::Product.find(123456789)
product.published_at = nil

In PHP using cURL:

$data = array(
            'product' => array(
                               'id' => 123456789,                                       
                               'published_at' => '')
$url = "https://$api_key:$api_pass@$";
$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);       


I hope this helps!

1 Like
Shopify Partner
14 0 2

Thank you very much...and do I put it back on the store?? Hahahaha

83 0 25

Anytime! You can just set that same value as the publish days date in ISO 8601 format and that should make it published again