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...
  • Replies 1
  • Views 511
  • Created
  • Last Reply
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

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.