Skip to content

Instantly share code, notes, and snippets.

@mmeo
Created March 20, 2019 17:55
Show Gist options
  • Save mmeo/03f9f786eb52768bc6f3ab2870fa1983 to your computer and use it in GitHub Desktop.
Save mmeo/03f9f786eb52768bc6f3ab2870fa1983 to your computer and use it in GitHub Desktop.
//This is a small script to create a call to action button on a Chargify receipt page,
//where the link has a dymanic subdomain, based on a custom field value.
//This script is meant solely as a *starting point*. You can edit the script as needed.
//define the subdomain, by reading the custom field value
var subdomain = $("body > div.wrapper > div.success-receipt > div.success-receipt__items > dl:nth-child(4) > dd").text();
//define the button and the button's link
var button = '<a href="https://' + subdomain + '.example.com"><button name="button" class="form__button form__button--primary button--block" id="call_to_action">Click to go to your subdomain</button></a>';
//insert the button on the page
$(button).insertBefore(".success-receipt__heading");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment