Forum

The forum is a free service supported by community members. Please consider opening a support ticket if you need timely help.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 11 Jul 2021 07:01 PM by  Carl Norloff
Auto Entering Required Points to Pay For an Order.
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages


New Member


Posts:32
New Member


--
29 Apr 2021 01:08 AM

    On the checkout review page I want to pre-fill the points needed to pay for the order or the available points whichever is the smallest.

    I almost have this working in the MultipleStepCheckout template by using the following:

    this.viewModel.RewardsPoint = ko.observable((this.viewModel.SalesOrderSet.TotalAmount()) * 100 > this.viewModel.AvailableRewardsPoints() ? this.viewModel.AvailableRewardsPoints() : (this.viewModel.SalesOrderSet.TotalAmount()) * 100)

    The problem I am having is that at the time this code executes the shipping charge has not been added to the SalesOrderSet.TotalAmount. So the points value that is calculated is not the correct amount. If I refresh the page then it updates to the correct amunt. 

    How can I refresh viewModel.RewardsPoint after the Review Order Button  is clicked?

    Or, is their a better way to do what i want to accomplish.

    Thanks

    0


    New Member


    Posts:32
    New Member


    --
    05 May 2021 09:43 PM

    I have this working exactly the way we wanted. Here is how i did it.

    In the checkout template "Initialize progress loading" script section we added the bolded code.

            // Initialize progress loading
            $(document).ajaxStart(function () {
                // Only show loading if it exceeds 1 sec
                $("#rvdsfLoading").data("timer", setTimeout(function () { $("#rvdsfLoading").show(); }, 1000))
            }).ajaxStop(function () {
                if ($("#rvdsfLoading").data("timer"))
                    clearTimeout($("#rvdsfLoading").data("timer"))

                $("#rvdsfLoading").hide();

                //RSA Addition - Auto apply points filling
                if (!$(".rsa-points-applied").length) {
                    //Calculate points to pay for order
                    var points = Math.round($("#rvdsfCheckoutPanelContainer")[0].viewModel.SalesOrderSet.TotalAmount() * 100); 
                    //Make points = avaialble points, when less than payment due amount
                    if (points > $("#rvdsfCheckoutPanelContainer")[0].viewModel.AvailableRewardsPoints() )
                        points = $("#rvdsfCheckoutPanelContainer")[0].viewModel.AvailableRewardsPoints();  
                    if (points > 0 )  //Only set points to apply when > 0
                        $("#rvdsfCheckoutPanelContainer")[0].viewModel.RewardsPoint(points); 
                }


            })

     

    0


    Basic Member


    Posts:394
    Basic Member


    --
    05 May 2021 09:44 PM

    Awesome job!

    Thanks for sharing :)

    0


    New Member


    Posts:32
    New Member


    --
    05 May 2021 09:45 PM
    Additional comment. We hard coded in our modification that a point is worth $0.01. That is why we multiplied the balance due by 100.
    0


    New Member


    Posts:4
    New Member


    --
    11 Jul 2021 07:01 PM
    Hi Rutledge - Thanks for sharing. I was wondering if I could ask you for some assistance as I am not a coder. I am trying to do the same thing in the list template where I want to show the number of points necessary to purchase the product. So right under the Product price, I want to show the points required based on a 0.01 point value. I would greatly appreciate any input! Thanks!
    0
    You are not authorized to post a reply.