M
M
Muvka2018-01-27 18:10:24
JavaScript
Muvka, 2018-01-27 18:10:24

What should an AJAX request look like?

The store has a coupon removal using ajax and the remove_coupon( ) function. But when adding a coupon, the page reloads. Looked at the documentation and found the apply_coupon( ) function there. Can you please tell me how the ajax request to this function should look like?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Baiguzhaev, 2018-01-27
@TimurBaiguzhaev

Maybe I didn't fully understand, but it seems easier to put this plugin, which allows you to add a coupon by making a get request, without calling the function directly.

EXAMPLE: APPLY COUPON VIA AN URL
Apply coupon through an url like this:
Use the url www.example.com/url-to-shop?apply_coupon=my_coupon
Voila! Any coupon can be applied this way.

WooCommerce Extended Coupon Features
And make an ajax request with the desired link.
$.ajax({
      type: 'GET',
      headers: {
      },
      url: "www.example.com/url-to-shop?apply_coupon=my_coupon",
      data: {},
      response: 'text',
      success: function(data){}
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question