How we can send discount code from cart page to checkout page? I am trying to add discount code on cart page in hidden field and want to use it on checkout page automatically. I also don't want to enter discount code on checkout page manually.
I have discount code on cart page and I am trying to put it into hidden filed with the help of javascript. following is my code:
$.ajax({
type: "GET",
url: url,
data: data,
contentType: "application/json",
headers: { 'Access-Control-Allow-Origin': '*' },
success: function(data) {
var dcv = data.discountCode;
console.log(dcv);
document.getElementById("quantityDiscount").value = 'dcv';
}
});
from above Ajax call, I received discount code in my dcv variable and put it on input field having #quantityDiscount as id. following is my input filed where I am trying to save this discount code.
<input id="quantityDiscount" class="js-form-discount" type="hidden" name="discount" value="" >
Please look at this issue and help me to solve it.
Thanks in advance!