Skip to content

Instantly share code, notes, and snippets.

@aldrienht
Last active November 30, 2022 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldrienht/52eb41ae8151ae88f411672f854a269b to your computer and use it in GitHub Desktop.
Save aldrienht/52eb41ae8151ae88f411672f854a269b to your computer and use it in GitHub Desktop.
Display points amount on product page
{% if template.name == 'product' %}
<script>
document.addEventListener('readystatechange', event => {
if (event.target.readyState === "complete") {
const orderPlacedSettings = window.BoosterApps.loy_config.ways_to_earn.filter(function(w) { return w.trigger === "order_placed" })[0];
if(!orderPlacedSettings || !window.BoosterApps?.common?.product){
return;
}
const brandThemeSettings = window.BoosterApps.loy_config.brand_theme_settings;
const translations = window.BoosterApps.loy_config.brand_panel_settings;
const potentialPoints = (window.BoosterApps.common.product.price / 100) * orderPlacedSettings.points_amount;
console.log('TODO - set selector where points amount content will appear: '+ potentialPoints)
document.getElementById(‘test_div’).innerHTML = `<div>some data and html tags here</div> `
}
});
</script>
{%- endif -%}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment