Update Shopify price using PowerShell via API

Here’s a simple script using PowerShell to update the price of a Shopify variant product. You can update the code to include a foreach loop to update a list of prices.

If you’re looking to update the quantity of a Shopify product, check out this link here.

If you are looking for my help with getting a script created to help with bulk upload (for a service fee), reach out to me. I can help.

## Required Variables
$apiToken = "<your-token>"
$apiKey = "<you-api-key>"
$basestoreURL = "<your-shopify-store>.myshopify.com/"
$library = "2023-10"
$shopifyVariantID = "<the-variant-id>"
$price = "<the-new-price-of-the-item>"
#################################
## API Header
#################################
$headers = @{
    "Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($apikey+":"+$apiToken))
    "Content-Type" = "application/json"
} 
###################################
## Base URL reset
###################################
$uri = $null 
$uri = "https://" + $basestoreURL + "admin/api/" + $library + "/" + "variants/" + $shopifyVariantID + ".json"
      
#################################
## Post to Shopify
#################################
$results = $postbody = $null
 
## Body
$postbody = [pscustomobject]@{
     variant = [pscustomobject]@{
          id = $shopifyVariantID
          price = $price
     }
} | convertTo-json
$results = Invoke-WebRequest -Method PUT -Uri $uri -Header $headers -Body $postbody -UseBasicParsing
Sign Up to get updates on the latest article

Get the latest from my blog when you sign up.  Special offers are only offered to those who sign up.  Specific DIY are emailed to users when they become available.  Sign up today to get notified.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.