As a developer, you may want the option of launching the Givy gifting modal from a non-product page. This is great for custom Shopify pages, blog posts, or as an option from your home page.
The modal can be launched using basic JavaScript. This means you can add it as an onclick event for any button, image, form, etc...
Here it is - simply run the following command (replace the number with the product variant ID from Shopify). If you don't know how to find this ID, learn how to Find a Shopify Variant ID.
window.GIVY.displayModal('123456789')
For this JS command to work, the Givy app embed must be enabled on your theme
If you'd like to launch this from an existing <a> link on the page, or the url for an existing button, you should try this as the URL:
javascript:window.GIVY.displayModal('123456789')
This will load the gifting modal with the correct product variant selected.
To launch the gifting modal from an onClick event or from a page builder, and to redirect to the cart page after the gift is added to cart, use this code:
window.GIVY.displayModal('123456789', {
addToCartSuccessCallback: function() {
window.location.href = '/cart';},
addToCartFailCallback: function() {}
})
If you're doing this within a page builder such as PageFly, Ecomposer Builder, or GemPages, check out these dedicated articles:
Gifting with PageFly Page Builder (coming soon)
Gifting with Ecomposer Page Builder (coming soon)
Gifting with GemPages Page Builder (coming soon)
Having issues with this? Please reach out via chat and our team will be happy to assist.