PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How to add Shopify cart to Hugo Ecommerce site

 June 30, 2022     e-commerce, hugo, shopify, shopify-api     No comments   

Issue

I have created a Static e-commerce site using Hugo.

Hugo ecommerce site

want to add products thro' Shopify admin, and get it reflected on my site.

I'm quite familiar with liquid templating. Kindly let me know how to achieve this?

So far,

  1. I have created a Shopify store, added a theme and added one product.
  2. I'm not looking to customize an existing theme, but completely remove that theme add my website theme in it.

Solution

You should be able to get your products using the Shopify API. This endpoint could be the one for you. From Hugo, you can then retrieve the products by getJson function with telling it the Shopify authorization header X-Shopify-Access-Token. Like this:

{{ $data := getJSON "https://your-store.myshopify.com/admin/api/2022-01/products.json" (dict "X-Shopify-Access-Token" "your-token") }}
{{ range $data }}
    {{ . }}
{{ end }}

Just make sure that you've replaced both the your-store and your-token strings.



Answered By - Jan Švábík
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing