Skip to content

Instantly share code, notes, and snippets.

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 m1k3lm/f0e6389806391eb59eabd87cd0fea341 to your computer and use it in GitHub Desktop.
Save m1k3lm/f0e6389806391eb59eabd87cd0fea341 to your computer and use it in GitHub Desktop.
Sequra.onLoad(function(){
//CUSTOMIZE
var item_selector = ".owl-wrapper .owl-item";
var price_selector_in_item = ".price-box";
var dest_selector_in_item = ".actions";
var msg_template = "<i class='sequra_installment'>Desde %s /mes</i>"
//CUSTOMIZE
document.querySelectorAll(item_selector).forEach(function (item, index) {
var price_item = item.querySelector(price_selector_in_item);
if(!price_item) return;
var the_amount = "" + parseInt(
parseFloat(
price_item.innerText.replace(/^\D*/,'')
.replace(sequraConfigParams.thousandSeparator,'')
.replace(sequraConfigParams.decimalSeparator,'.')
) * 100
);
var creditAgreement = Sequra.computeCreditAgreements({
amount: the_amount,
product: "pp3"
})["pp3"]
.filter(function (item){return item.default})[0];
var installment_el = document.createElement('span');
installment_el.innerHTML = msg_template.replace("%s",creditAgreement["instalment_total"]["string"]);
item.querySelector(dest_selector_in_item).appendChild(installment_el);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment