Check current url with script (content lock)

New Member
10 0 0

Hi gurus,

Anyone can assist to take a look at the below? Cant get it work, everytime it shows false. I checked assigned "value" and is same with the URL i indicated, but doesnt work in formula. Im trying to simple lock some features on the page with a custom url. So when custom URL trigger the formula "True" - i will open content. Features are not sensitive info or some sort of it, so simple trick with URL will do.

<div id="pre-order">
 {% assign value = '<script>document.getElementById("pre-order").innerHTML = window.location.href;</script>' %}        {% if value == '' %} 
{% else %}
{% endif %}



Any help will be appreciate, or maybe there is another concept.

Shopify Partner
918 17 159

Hi Tommy,

You are mixing client side evaluated code with server side evaluated code. Liquid runs server side. Javascript runs client side. You cannot assign some Javascript to a Liquid variable, expect that Javascript to run and get the result in that Liquid variable.

Best wishes!

I turn coffee in to code - since 1998
New Member
10 0 0

Understand. Thx for reply, still learning liquid.

If someone need

I solved my problem by creating custom Pre Order page,  apply Dynamic content script and also shopify out of stock notifier. Now content can be locked to pre order only. Its not sort of high security, but will work for me (i have a plan B just in case also).

Dynamic scipt here

Shopify out of stock notification here


Browsing normal page, which is locked for order, only pre order form, sample here

Unlocked page (url with extra params), which allow customers to make a purchase, here


Now there is still a message shows how many stock available, but im working on it removal, beeketing hide it dont know where, waiting their support to help.

New Member
53 0 0

Hi Tommy,


This is a nice trick, I will check when I get time, thanks for posting :)



Gajendra. | Top Rated Upworker | Shopify Developer and Designer | Theme Customization