Skip to content

Apply partial reward point

I’m using Magento 2 EE version and implement the reward point. Currently, Magento will apply all of user point. I overrided the reward point block with an input for user to enter how many points he want to use. Then he will click a button to trigger an ajax. Here is my code so far:

            $.ajax({
                url: url.build('rest/default/V1/reward/mine/use-reward'),
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify({ amount: rewardPoints }),
                success: function (response) {
                    console.log('point', rewardPoints);
                    console.log('Response', response);
                    customerData.reload(['cart', 'checkout'], true);
                },
                error: function () {
                    console.error('Fail to apply');
                }
            });

After I click the button, it log to console point, response = true. But it does not update the total amount. When I reload the page, it then show the deducted point, but the whole point of user.

Do you have any suggestion? Thank you very much