Jump to content

How to add a widget code to a Header/Navigation Button

Recommended Posts

Posted

Hello! I'm looking for a solution to add a widget code to a header button.

website: https://millandmainrestaurant.squarespace.com/reservations 
Does anyone know how to do that?
Thank you!

 

the code I have: 

<div style="text-align: center;"><a href="https://resy.com/cities/kerhonkson-ny/venues/mill-and-main" id="resyButton-ZMLifg9xYpLYfaOawWuqJ">Book your Mill & Main reservation on Resy</a></div>


<script src="https://widgets.resy.com/embed.js"></script>
<script>
resyWidget.addButton(document.getElementById('resyButton-ZMLifg9xYpLYfaOawWuqJ'), {"venueId":72291,"apiKey":"sAqIjRUrrfAL9EzFQNEQjH6gTP64obBX","replace":true});
</script>

 

  • Replies 7
  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

@ChristinaB Hi! I haven't been able to test the code on your site since it requires a custom script to set the ID to the header button. Please try adding this code under Website > Settings > Advanced > Code Injection > Header.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>

<script>
$(document).ready(function() {
    var link = $('.header-actions-action .btn');
    link.attr('href', 'https://resy.com/cities/kerhonkson-ny/venues/mill-and-main" id="resyButton-ZMLifg9xYpLYfaOawWuqJ');
    link.attr('id', 'resyButton-ZMLifg9xYpLYfaOawWuqJ');
});
</script>

<script src="https://widgets.resy.com/embed.js"></script>
<script>
resyWidget.addButton(document.getElementById('resyButton-ZMLifg9xYpLYfaOawWuqJ'), {"venueId":72291,"apiKey":"sAqIjRUrrfAL9EzFQNEQjH6gTP64obBX","replace":true});
</script>

Let me know how it goes. Thanks! 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Posted

@ChristinaB I only added the URL and ID to the button based on the information you shared in your script. How it is supposed to pop up on the page depends on the third-party platform where you got the embed code from. Please check if everything is set up correctly there, and if there is an issue, try contacting their support.

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Posted

@ChristinaB Yes I checked your link and wrote the code solution based on your website header. However, code I shared isn't working as the red button is opening the popup inside an iframe. 

You can try adding a link under you main navigation. Then add the embed code inside the link URL. 

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

  • 4 months later...

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.