Ajax add tickets to cart

Home Forums Ticket Products Event Tickets Plus Ajax add tickets to cart

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1185523
    darrienw93
    Participant

    Hey there,

    I searched the forums and was unable to find a solution for my problem.

    I would like to make it so that when on the event page when a customer adds a ticket to the cart, it’s added but they remain on the event page.

    When I use the following code, the tickets are not added to the cart. I’m just hoping someone can point out whether or not there’s something special that needs to be done specifically for WooCommerce in order for this to work.

    I’m not sure why the data is not being passed along.

    <script type="text/javascript">
    $(function() {
      $('form.ticket-checkout').submit(function(event) {
        event.preventDefault(); // Prevent the form from submitting via the browser
        var form = $(this);
        $.ajax({
          type: form.attr('method'),
          url: form.attr('action'),
          data: form.serialize()
        }).done(function(data) {
          // Optionally alert the user of success here...
          alert('ok');
        }).fail(function(data) {
          // Optionally alert the user of an error here...
        });
      });
    });
    </script>
    #1186003
    darrienw93
    Participant

    Okay, so I definitely know there’s nothing special about working with WooCommerce.

    I ended up trying out this plugin http://malsup.github.io/min/jquery.form.min.js and ajax submit works.

    I suspect that the code I used above must have some sort of error. So I’ll have to figure it out.

    #1186065
    Nico
    Member

    Hi there darrienw93,

    Thanks for getting in touch with us! And thanks for the heads-up on your solution ๐Ÿ™‚

    If I understand correctly this is working for you know, right?

    Please let me know about it,
    Best,
    Nico

    #1186372
    darrienw93
    Participant

    Yes the jquery plugin I linked to made it work.

    Thanks for the help though Nico.

    #1186626
    Nico
    Member

    Thanks for confirming! That was my thought but wanted to double check before closing the thread ๐Ÿ™‚

    Iโ€™ll go ahead and close it now, but if you need help with anything else please donโ€™t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Ajax add tickets to cart’ is closed to new replies.