Shopify shortcode for product page - shopify

I'm trying to display my only product's salespage on homepage through a shortcode.
I downloaded plugin from github and installed shortcode.liquid and shortcode-render.liquid.
I uploaded shortcode-youtube.liquid example.
I activated shortcode functionality by changing liquid tag from
{{ page.content }}
to
{% include 'shortcode' load: page.content %}
I used shortcode [youtube] on a test page and it works fine! It displays video on a homepage through a shortcode.
Question: How do I do the same for a products sales page?
I know I need to create shortcode-product.liquid file but what code do I put inside it?
Cheers for help,
Rafal

Related

Is there any way to add metafields data on the homepage of shopify site?

I want to show some content on the homepage of my shopify site, the content is added in metafields created for pages. Is there any way to add metafields data on the homepage of shopify site?
You can access metafields of a page resource like this:
{{ page.metafields.namespace.key }}
If you are on another page (e.g. the homepage) you need to request the page object first in order to access its metafields:
{{ pages['page-handle'].metafields.namespace.key }}
Note: Make sure to replace page-handle with the handle of your page.

How to add Shopify cart to Hugo Ecommerce site

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,
I have created a Shopify store, added a theme and added one product.
I'm not looking to customize an existing theme, but completely remove that theme add my website theme in it.
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.

How to add a credit card logo in the product page of a Shopify site

Reviewing our Shopify site, I realized that a major difficulty with Shopify is that it's as if the theme does everything possible to obfuscate credit card usage. The site is replete with all sorts of references to Google Pay, Amazon Pay, etc., but credit card payments are always difficult to find.
I would like to know how to add a credit card logo right below the BUY IT NOW button. Could you please let me know if it is possible to do it in Shopify by editing LIQUID file? If so, please point me
Yes, Its possible to do in shopify by editing Liquid file.
You can find code of "Buy It Now" button in your template.
{% if enable_dynamic_buttons %}
{{ form | payment_button }}
{% endif %}
Either code is in sections/product-template.liquid or in snippets/product-form.liquid
You can add code of logo after above code. You can upload logo image either in theme or under files in shopify and then can use HTML code to put logo image.
For e.g.
<img src="{{'creditcardlogo.png' | file_img_url: 'original' }}">

Shopify Liquid - Can You Get a Specific Page's Metafields On A Product Page?

I have a product page in my store. All my products have an associated vendor. For each vendor, I have a custom Shopify page and on this page is attached several metafields. Metafields include things like the vendor (company) country, year founded, etc...
On my product page, I would like to show the above info about the vendor. I can get to the metafields for the vendor if I was on the custom vendor page by using something like:
{% assign vendor_country = page.metafields.mynamespace.country %}
Is there anyway to get the same metafield info if I was on a product page? In this case, the context of the Liquid page variable would not be correct by default. I need a way to set this context based on the product.vendor variable and then request the custom vendor page data.
This is possible if you know the page handle. To do so you will have to make use of pages global object. So just get a page by handle and then call the metafields.
Example Code in Product template
{{ pages['page-handle'].metafields.namespace.fieldName }}
Global Pages Object

Shopify Liquid tag modify HTML?

I have shopify store. I want to amend HTML output of app.
basically app adds some Img tag which is not visible to client via CSS. I want to remove those Img tags from it.
{% include 'my-appinfo', app-arg-1: 'test' %}
As above we include app into theme.liquid file.