Created
May 23, 2019 22:49
-
-
Save m1k3lm/f0e6389806391eb59eabd87cd0fea341 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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