Product Price equal to 0$ then mark it out of stock

Product Price equal to 0$ then mark it out of stock

HXtech001
Tourist
10 0 1

I have 70k product in my store around 6k product prices are 0$ these 6k products are in different categories hard to find. I want all 0$ product to be out of stock that people can see those but unable to add in cart or buy those.

looking for help

Reply 1 (1)

beauxbreaux
Shopify Partner
262 21 45

The easiest way to do this would be to bulk edit products and use Excel + Visual Basic Studio to update all of the products with $0 to have a 0 QTY.

 

That is if I am understanding you correctly. 

 

To do this you would:

 

  • Click on Products
  • Top right hand corner click export
  • Export everything to a CSV file
  • Change your sheet name to Sheet1
  • Click Alt + F11
  • Click Insert in the top menu and then Click Module
  • Past this code:
Sub UpdateQuantityAndRemoveOtherProducts()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long

    ' Set the worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your actual sheet name
    
    ' Find the last row in column X
    lastRow = ws.Cells(ws.Rows.Count, "X").End(xlUp).Row

    ' Loop through each row from the bottom up to prevent issues when deleting rows
    For i = lastRow To 2 Step -1 ' Assuming row 1 is header
        ' Check if the price is exactly 0 in column X
        If ws.Cells(i, "X").Value = 0 Then
            ' Set the quantity to 0 in column U
            ws.Cells(i, "U").Value = 0
        Else
            ' Delete the entire row if the price is not 0
            ws.Rows(i).Delete
        End If
    Next i
End Sub

 

  • Click F5 to run code.

What this code does is look for every product that has a price 0 and then changes the QTY of that product to 0. It then deletes any row that was not changed as it does not need to be updated.

 

This method of course only works if you have access to Excel. If you use Google Sheets this can be done relatively fast as well. You would very easily establish this same thing just by turning your data into a table. Then you would just organize your data by product price from least to highest. You can then delete everything higher than 0 dollars. Next you would just write 0 in the QTY. This can be speed fill with all 0's by clicking and holding down on the blue circle at the corner of the cell. You just drag that down to fill the rest out with 0. 

 

If your products are set to QTY 0 they should still show up but not be available to purchase unless you set the settings to sell when out of stock or if you set your setting to hide products when out of stock. If you just have the default setup, this should work. 

Beaux Barker
Developer
Hire me on Fiverr