I am working on a custom module where I need to show my discount in cart totals. I am following Classyllama and Turnkey blog posts in order to achieve the same.

I have come to a point where my custom discount is shown in cart totals block. But that is not ajax based. User have to click on a submit button and then only I can see by block being added in cart totals.

What I need to do now is when I click on a checkbox, it should call my controller and after some processing show my block added in cart totals without page reload, as shown below.

enter image description here

function updateCreditPoints()
    var amount = $('discount_amount').value;

    new Ajax.Request("<?php echo $myFormAction?>", {
           method: 'post',
           postBody: "discount="+$('discount_amount').value,
           onComplete: function(data) {
                //somecontainer to update

If checkbox is selected, then container should show the discount block else it should not.

I am unable to find what code should be written in controller action to show my discount block on ajax request.

Please Help.


closed as too broad by Marius May 7 '15 at 7:04

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    post the code of the controller or specifically of this form action. – MTM Aug 25 '14 at 13:23