When customers have added products to their cart and are on the checkout page, it is a great idea to them know that they will earn loyalty rewards points for completing the order. This achieves two objectives - helps improve the conversion rate and it also increases the awareness about the program.

We have built a Javascript API which takes a set of products and returns the total number of points that will be earned for that set of products. 

The Javascript function to be used on product pages is 

zrl_mi.get_potential_points(product_array)

      Where product array contains the list of products.

Example Code: 

  zrl_mi.get_potential_points([
     {"product_id" : "product_five", "price": 20, "quantity": 1, "category": "cups"},
     {"product_id" : "product_six", "price": 20.00, "quantity": 3, "category": "butter"}
     ])

The function comes with success and failure handlers. If the product details are captured correctly and the points earning opportunity calculated by Zinrelo, the code to display the points can be written in the success handler.

Sample Code:    

zrl_mi.get_potential_points_success_handler = function(){

element = document.querySelection("#potential_product_points"); /* div by the name potential_product_points should exist at product page */

element.innerText = potential_points; // showing potential points
}
        }

In case of a failure, the code to handle the failure can be written in the failure handler function.

   zrl_mi.get_potential_points_failure_handler = function(){
         console.log(0); //error handling
      }

  

Did this answer your question?