Jump to content

Custom Javascript for item variants (Timezone)

Recommended Posts

Site URL: https://www.mandarintree.nl/store-1

Hi,

I'm selling online lessons to customers around the world. I'm currently listing variants in UTC time, but this has caused confusion with some customers.

I would like the time slot (the variant category) to display the client side timezone (see https://www.mandarintree.nl/store-1/p/g8unmo5nrqqe2bg7uc6nau94y6pkvg-w97bk) instead of UTC

I know some basic javascript - and I'm aware how to add that inside a code block in squarespace to get the client timezone:

e.g., 

<script type="text/javascript">
 var timezone = encodeURIComponent(jstz.determine().name()); 

</script>

What I'm not sure how to do (or if it's possible) is to modify the string of the variant name to update the time (i.e., edit variant-select-wrapper).

Is this possible, are there any similar examples I could work from?

Link to comment
  • 1 month later...
On 2/4/2021 at 6:39 AM, KarenKT said:

Site URL: https://www.mandarintree.nl/store-1

Hi,

I'm selling online lessons to customers around the world. I'm currently listing variants in UTC time, but this has caused confusion with some customers.

I would like the time slot (the variant category) to display the client side timezone (see https://www.mandarintree.nl/store-1/p/g8unmo5nrqqe2bg7uc6nau94y6pkvg-w97bk) instead of UTC

I know some basic javascript - and I'm aware how to add that inside a code block in squarespace to get the client timezone:

e.g., 

<script type="text/javascript">
 var timezone = encodeURIComponent(jstz.determine().name()); 

</script>

What I'm not sure how to do (or if it's possible) is to modify the string of the variant name to update the time (i.e., edit variant-select-wrapper).

Is this possible, are there any similar examples I could work from?

What is the variable jstz you are using?

We can convert the time across time zone using library like moment js

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.