Changing Shopify store product prices programmatically

Hello!

I’m looking for a way to change the prices of items in my storefront programmatically.

I’m sure there’s an API for it, I’m just a bit overwhelmed with all of the lingo I’m seeing, “apps” and whatnot.

Also noticed that the API’s are broken in to many subcategories (Admin, Partner, App Bridge, Remix, Payments, Shopify Function, and Multipass) so was wondering someone could guide me towards which might be best suited for changing item prices?

1 Like

Hey there Mgiara!

Let’s break down the components involved in programmatically changing item prices on a Shopify storefront and understand the relevant APIs and technologies:

  1. Shopify Storefront:

    • A Shopify storefront is the public-facing online store where customers browse and purchase products.
    • It typically includes product listings, product details, a shopping cart, and a checkout process.
  2. Admin API:

    • The Shopify Admin API allows you to interact with the administrative backend of your Shopify store.
    • It provides access to manage products, collections, orders, customers, and other store-related data.
    • You can use the Admin API to change item prices programmatically.
  3. Storefront API:

    • The Shopify Storefront API is designed for building custom, client-side storefronts.
    • It allows you to fetch store data like product information, collections, and customer details.
    • While it’s essential for building custom storefronts, it doesn’t have the capability to directly modify item prices.
  4. Remix:

    • Remix is not a Shopify API; it is a modern framework for building web applications.
    • It’s used for creating interactive and engaging web experiences.
    • You may use Remix alongside Shopify APIs to enhance your storefront, but it doesn’t handle price changes directly.
    • Remix is built on top of React and is used to combine front and backend technologies, simplifying the building process for embedded Shopify apps in general.
  5. App Bridge:

    • Shopify App Bridge is a JavaScript library that helps embedded apps seamlessly integrate into the Shopify Admin.
    • It allows your app to interact with the Shopify Admin without leaving the Shopify environment.
    • Useful if you’re building an app that modifies prices through the admin interface but not directly on the storefront.
  6. Shopify Functions:

    • Shopify Functions is a feature that enables serverless functions to be deployed within Shopify.
    • These functions can be used to customize your storefront’s behavior.
    • While they can enhance your storefront, they are not typically used to change item prices directly.
  7. Multipass:

    • Multipass is a feature that helps with single sign-on (SSO) between your Shopify store and other applications.
    • It’s not directly related to changing item prices on your storefront.

To programmatically change item prices on your Shopify storefront, you’ll primarily want to use the Shopify Admin API. Here’s a high-level overview of the steps involved:

Here is an example of how to authenticate to a Shopify API in Python / Flask with an Access Token in the header of the request. This is a GET and a PUT request, for your edification.

_bp.route('/')
def index():
    return render_template('index.html')

@products_bp.route('/products', methods=['GET'])
def get_all_products():
    # Define the URL for the REST API request
    url = f'https://{SHOP_NAME}.myshopify.com/admin/api/{ADMIN_API_VERSION}/products.json'

    # Headers for the REST API request
    headers = {
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': ADMIN_API_ACCESS_TOKEN
    }

    # Make the REST API request
    response = requests.get(url, headers=headers)

    # Check if the request was successful
    if response.status_code == 200:
        return jsonify(response.json())
    else:
        return jsonify({'error': 'Unable to fetch products'}), response.status_code

@products_bp.route('/products/
5 Likes

This has to be the best reply I’ve ever received from a question on any kind of forum.

Can’t thank you enough James.

3 Likes

Hi - Can you elaborate on REST API’s and GRAPHQL API’s and where does these stand between ADMIN API and STOREFRONT API?

That is an amazing reply. Shows your dedication in the community. One thing, what is the difference between Storefront API, AJAX API and Headless Storefront API?

1 Like