In my checkout page, on applying and removing promo code, it changes the discount key in totals.totals().items. How to apply bindings and subscribe in knockoutjs, so that I can call my function which I am calling from my HTML.


<span class="tag-text">
    <!-- ko if: getFinalSale($parent)-->
      <u class="product-tag underline-bold-text checkout-final-sale" data-bind="text: getFinalSale($parent)"></u>
    <!-- /ko -->


 getFinalSale : function (quoteItem) {
        var item = this.getItems(quoteItem.item_id);
        var temp_item = this.getTempItems(quoteItem.item_id);
        var tagText = '';

        if((((temp_item.price*temp_item.qty) - temp_item.discount_amount)/(item.base_old_price*temp_item.qty)) < 0.5){
            var tagText = 'Final Sale';
            if(item.base_old_price && temp_item.price){
                // && item.price < item.price && item.base_old_price / item.price <= 0.5){
                if(((item.base_old_price - temp_item.price)/item.base_old_price)>0.5){
                    var tagText = 'Final Sale';
        return tagText;

1) How can i call getFinalSale on the change of totals.totals().items

2) The issue I am passing the $parent from my HTML and when the totals.totals().items the discount amount is changed for each item after applying promo code then how will I pass this $parent(quoteItem) from the very same js.

How to solve that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.