Solved

How can i pull a price from another product to display on my homepage

Gevlik
Visitor
2 1 0

Apologies I'm very new to liquid/coding and I've googled as much as I can and can't find an answer.  I'm looking to add text to my homepage that pulls the price of a product into the text of a homepage.  I'd like a paragraph of text to say something like this:

"with 100 blades costing only [price of specific product] you are set for two plus years" (again this is not on the product page. but on a separate page, calling the price up of a specific product)

bonus points if I can also do math like [price of product / 2] 

the idea is i have text for a page change based on the user, so it will display whatever price they're currently set to see.  eg: canadians will CAD, americans will see USD.  (but ideally not have the currency code)

I'm sure this is extremely simple, I'm just struggling to find an answer.

Thank you.

Accepted Solution (1)

Gevlik
Visitor
2 1 0

This is an accepted solution.

figured it out. I was just messing up the product handle when trying to assign a product to a variable, so I had found the solution earlier, just messed up implementation. I knew it had to be simple.

{% assign content_price = all_products['asdf-asdf'] %}  (the product handle is the name of the product in the URL eg:/products/asdf-asdf  the handle is asdf-asdf
{{ content_price.title }} is {{ content_price.price | divided_by: 100 | money }}

result: 
Asdf Asdf is $0.10

View solution in original post

Reply 1 (1)

Gevlik
Visitor
2 1 0

This is an accepted solution.

figured it out. I was just messing up the product handle when trying to assign a product to a variable, so I had found the solution earlier, just messed up implementation. I knew it had to be simple.

{% assign content_price = all_products['asdf-asdf'] %}  (the product handle is the name of the product in the URL eg:/products/asdf-asdf  the handle is asdf-asdf
{{ content_price.title }} is {{ content_price.price | divided_by: 100 | money }}

result: 
Asdf Asdf is $0.10