Skip to content

Instantly share code, notes, and snippets.

@geetfun
Created November 22, 2016 16:03
Show Gist options
  • Save geetfun/7cd724c69c6a999df388b6ea0b8ea51f to your computer and use it in GitHub Desktop.
Save geetfun/7cd724c69c6a999df388b6ea0b8ea51f to your computer and use it in GitHub Desktop.
<!-- Checkend Recurring Billing -->
{% assign row_loop_index = forloop.index %}
{% for p in item.properties %}
{% if p.first == "Subscription" %}
<script>
$.getJSON('https://subscriptionorder.com/product_lookup/{{ item.product.id }}/variants/{{ item.variant.id }}', function(response) {
var discountPercentage = response.discount_percentage;
var discount = Number(discountPercentage) / 100;
var unitPrice = $("#checkend-cart-row-{{row_loop_index}}").find("[data-checkend-unit-price]").data("checkend-unit-price");
var discountUnitPrice = (unitPrice * (1-discount));
console.log(unitPrice);
$("#checkend-cart-row-{{row_loop_index}}").find("[data-checkend-unit-price]").html("$ "+(discountUnitPrice/100).toFixed(2));
var quantity = $("#checkend-cart-row-{{row_loop_index}}").find("[data-checkend-quantity]").data("checkend-quantity");
$("#checkend-cart-row-{{row_loop_index}}").find("[data-checkend-total-price]").html("$ "+(discountUnitPrice*quantity/100).toFixed(2));
});
window.subscriptionOrderApp = true;
</script>
{% endif %}
{% endfor %}
<!-- Checkend Recurring Billing -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment