I have tried redirect the purchase button on a Squarespace product page from adding items to a cart to third party site, in this case so that users can purchase an item on Amazon. I was not able to change this as a simple redirect so I tried to replace the button, however now the button only shows up when you refresh the page, and not on the initial page load. I am not sure what is going on here.
The site page is here: https://www.oakhurstpublishing.com/books/mistys-tale
Here is tthe header code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script>
$(function() {
$(".sqs-add-to-cart-button").replaceWith("<div class='amazoncheckoutbuttonwrapper'><a class='amazoncheckoutbutton' target='_blank' href='https://www.amazon.com/Mistys-Tale-Leopold-J-Cimino/dp/1733605800/'>SHOP NOW</a></div>");
});
</script>
Here is the CSS:
.amazoncheckoutbuttonwrapper{
margin-top: 45px;
margin-bottom: 45px;
}
.amazoncheckoutbutton {
display: inline-block;
visibility: visible !important;
font-family: "proxima-nova";
text-transform: uppercase;
letter-spacing: 3px;
font-weight: 300;
font-style: normal;
font-size: 16px;
color: #fff;
text-align: center;
text-decoration: none;
letter-spacing: 1px;
text-transform: uppercase;
line-height: normal;
font-family: proxima-nova;
padding: 21px 34px;
background-color: rgba(92,183,204, 1);
cursor: pointer;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.amazoncheckoutbutton:hover {
color: #fff;
background-color: rgba(92,183,204, 0.5) !important;
cursor: pointer;
}