Move the "add to cart button" on WooCommerce Tickets – alternative form.php

Home Forums Ticket Products Event Tickets Plus Move the "add to cart button" on WooCommerce Tickets – alternative form.php

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1102932
    Jürgen
    Participant

    Hi there,

    I successfully moved the “add to cart” button on my single event template to the top like you have described it in the knowledgebase.

    But I also want to sell the tickets via Woocommerce, so I added the no_hijack snippet to my functions.php. Then my Button was gone and, like in the tutorial, I added the WooCommerce Tickets – alternative form.php.

    But … on this form the “add to cart button” is below the picture etc. How do I have to edit the snippet in my functions.php that it applies to the new template ?

    I hope, I was successfully making myself clear 😉

    Regards,
    Jürgen

    #1103316
    Geoff B.
    Member

    Good evening Jürgen and welcome back!

    Thank you for reaching out to us.
    I would love to help you with this topic.

    To do so, could you please first provide us with your system information in a private reply ? (following the instructions found in the link)

    Secondly, it would be very awesome if you could provide me with a URL of a page where you have performed the customization so that can get a better idea of the current state of things.

    Have a good week-end,

    Geoff B.

     

    #1103379
    Jürgen
    Participant

    This reply is private.

    #1103380
    Jürgen
    Participant

    Hi Geoff,

    this is an example of the single event template – I copied the code from github as you´ve described it in the knowledgebase.
    What I want to achieve is, that the tickets-section moves up below the title, right on top of the picture.

    I had achieved that with the original template, just as was described in your tutorials, but since I changed the template, the effect is gone.

    That´s the snippet, I added to the functions.php :
    <?php
    /*
    * Moves the front-end ticket purchase form, accepts WP action/hook and optional hook priority
    *
    * @param $ticket_location_action WP Action/hook to display the ticket form at
    * @param $ticket_location_priority Priority for the WP Action
    */
    function tribe_etp_move_tickets_purchase_form ( $ticket_location_action, $ticket_location_priority = 10 ) {
    if ( ! class_exists( ‘Tribe__Tickets__Tickets’) ) return;
    $etp_classes = array(
    ‘Easy_Digital_Downloads’ => ‘Tribe__Tickets_Plus__Commerce__EDD__Main’,
    ‘ShoppVersion’ => ‘Tribe__Tickets_Plus__Commerce__Shopp__Main’,
    ‘WP_eCommerce’ => ‘Tribe__Tickets_Plus__Commerce__WPEC__Main’,
    ‘Woocommerce’ => ‘Tribe__Tickets_Plus__Commerce__WooCommerce__Main’,
    ‘Tribe__Tickets__Tickets’ => ‘Tribe__Tickets__RSVP’,
    );
    foreach ( $etp_classes as $ecommerce_class => $ticket_class) {
    if ( ! class_exists( $ecommerce_class ) || ! class_exists( $ticket_class ) ) continue;
    $form_display_function = array( $ticket_class::get_instance(), ‘front_end_tickets_form’ );
    if ( has_action ( ‘tribe_events_single_event_after_the_meta’, $form_display_function ) ) {
    remove_action( ‘tribe_events_single_event_after_the_meta’, $form_display_function, 5 );
    add_action( $ticket_location_action, $form_display_function, $ticket_location_priority );
    }
    }
    }
    /*
    * TO MOVE THE TICKET FORM UNCOMMENT ONE OF THE FOLLOWING BY REMOVING THE //
    */
    /*
    * Uncomment to Move Ticket Form Below Related Events
    */
    //tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_after_the_meta’, 20 );
    /*
    * Uncomment to Move Ticket Form Below the Event Description
    */
    //tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_after_the_content’, 5 );
    /*
    * Uncomment to Move Ticket Form Above the Event Description
    */
    //tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_before_the_content’ );

    Got it from here : https://gist.github.com/elimn/a7dcd0a63815db583c1e

    And I need it modified, so that it applies to the new template, which code I found here :

    https://gist.github.com/elimn/a7dcd0a63815db583c1e

    and it looks like this :

    <?php
    $count = 0;
    echo ‘

      ‘;
      foreach ( $tickets as $ticket ) {
      global $product;
      $count++;
      if ( class_exists( ‘WC_Product_Simple’ ) ) $product = new WC_Product_Simple( $ticket->ID );
      else $product = new WC_Product( $ticket->ID );
      $price = $product->get_price_html();
      $link = ‘get_permalink() . ‘”>Buy!‘;
      echo “

    • $ticket->name $price $link
    • “;
      }
      if ( 0 === $count )
      echo ‘

    • There are no tickets available for this event
    • ‘;
      echo ‘

    ‘;

    So you see, I took it all off your resources.

    If you need anything else, just let me know,

    Regards,

    Jürgen

    #1104019
    Geoff B.
    Member

    Good evening Jürgen,

    Thank you for providing me with your system information and with the snippets you tried applying.

    What I am not clear about yet, for which I apologize, is what the issue is exactly ?

    I think this is mainly because the picture you were referring to in the first comment is no longer there.

    Also, you mentioned that you were successful doing your customization with the previous template. Does that mean that you have switched WordPress themes recently or that you are using a different page template?

    Just to set expectations, before we continue, as you might know, the scope of our support is mostly to get our wonderful customers started on the right track to customize their site and to help them in case of issues. We unfortunately do not provide complete support for customization.

    With that in mind, I think what is going on is that you are combining 2 pieces of codes that were done at 2 different times. I also think that the second part of your code actually doesn’t come from the https://gist.github.com/elimn/a7dcd0a63815db583c1e link.

    Would you mind providing me with the correct origin of the second part of your snippet so that I can ask the snippet author ?

    Best regards,

    Geoff B.

     

    #1104104
    Jürgen
    Participant

    Hi Geoff,

    you are right, I accidentally copied the same link twice.
    The original code is found here :

    https://gist.github.com/theeventscalendar/eedc81ba148e0346dfee

    I´ve followed the instructions here : https://theeventscalendar.com/knowledgebase/selling-tickets-from-the-woocommerce-products-page/

    So, what I´m trying to achieve, is simply to move the ticket section in that above form back on top just above the picture – to make sure, customers actually find the “buy now” button.

    Appreciate your help,

    Jürgen

    #1104657
    Geoff B.
    Member

    Good evening Jürgen,

    Thank you for clarifying things and for sending the correct link to the second part of the code.
    That helps.

    I have some pretty good news for you.
    You can move the ticket form exactly where you want by following the instructions found here: https://theeventscalendar.com/knowledgebase/moving-the-ticket-form/

    Basically, you will just need to uncomment the line that places the form where you want.

    Let me know how that goes.

    Best regards,
    Geoff B.

     

    #1104720
    Jürgen
    Participant

    Hi Geoff,

    I know that code and I´ve added it into the functions.php already.

    But it doesn´t work with the alternative form – there must be some line to be changed in order to work with the form I´m using – but I don´t know, which.

    I´ve posted the code you are regarding to already in my second message.

    Where do I have to edit the code so that it works for the alternative form ?

    Regards, Jürgen

    #1105162
    Geoff B.
    Member

    Hey Jürgen,

    I am sorry to hear that. I actually tested the code with the alternative form prior to contacting you and got it to work perfectly.

    There is no code to edit to get to work with the alternative form. So I guess we now have to find out how to get it to work on your website as well.

    But back to your comment (that you already submitted that), this is totally my bad. My apologies.

    But I am noticing that you did not remove any of the commented functions as suggested in this part of the code “* TO MOVE THE TICKET FORM UNCOMMENT ONE OF THE FOLLOWING BY REMOVING THE //”

    In other words, lines 29 to 39 of that code contain different possibilities of where to move the alternative form. But, you need to choose the one you want and remove the // in front of the one that reflects what you are trying to do.

    For example, you could erase the // found at line 39. Otherwise, this code will have no effect.

    Let me know how that goes.

    Best regards,
    Geoff B.

     

    #1105261
    Jürgen
    Participant

    Hi Geoff,

    the code you are referring to was taken from the github site.
    My actual functions.php looks like that :

    /*
    * Moves the front-end ticket purchase form, accepts WP action/hook and optional hook priority
    *
    * @param $ticket_location_action WP Action/hook to display the ticket form at
    * @param $ticket_location_priority Priority for the WP Action
    */
    function tribe_etp_move_tickets_purchase_form ( $ticket_location_action, $ticket_location_priority = 10 ) {
    if ( ! class_exists( ‘Tribe__Tickets__Tickets’) ) return;
    $etp_classes = array(
    ‘Easy_Digital_Downloads’ => ‘Tribe__Tickets_Plus__Commerce__EDD__Main’,
    ‘ShoppVersion’ => ‘Tribe__Tickets_Plus__Commerce__Shopp__Main’,
    ‘WP_eCommerce’ => ‘Tribe__Tickets_Plus__Commerce__WPEC__Main’,
    ‘Woocommerce’ => ‘Tribe__Tickets_Plus__Commerce__WooCommerce__Main’,
    ‘Tribe__Tickets__Tickets’ => ‘Tribe__Tickets__RSVP’,
    );
    foreach ( $etp_classes as $ecommerce_class => $ticket_class) {
    if ( ! class_exists( $ecommerce_class ) || ! class_exists( $ticket_class ) ) continue;
    $form_display_function = array( $ticket_class::get_instance(), ‘front_end_tickets_form’ );
    if ( has_action ( ‘tribe_events_single_event_after_the_meta’, $form_display_function ) ) {
    remove_action( ‘tribe_events_single_event_after_the_meta’, $form_display_function, 5 );
    add_action( $ticket_location_action, $form_display_function, $ticket_location_priority );
    }
    }
    }
    /*
    * TO MOVE THE TICKET FORM UNCOMMENT ONE OF THE FOLLOWING BY REMOVING THE //
    */
    /*
    * Uncomment to Move Ticket Form Below Related Events
    */
    //tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_after_the_meta’, 20 );
    /*
    * Uncomment to Move Ticket Form Below the Event Description
    */
    //tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_after_the_content’, 5 );
    /*
    * Uncomment to Move Ticket Form Above the Event Description
    */
    tribe_etp_move_tickets_purchase_form( ‘tribe_events_single_event_before_the_content’ );

    /*
    * Causes WooCommerce Ticket product pages to stop redirecting to their event page
    * See https://theeventscalendar.com/knowledgebase/selling-tickets-from-the-woocommerce-products-page/
    */
    function tribe_wootix_no_hijack() {
    if ( ! class_exists( ‘Tribe__Tickets_Plus__Commerce__WooCommerce__Main’ ) ) return;
    $woo_tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
    remove_filter( ‘post_type_link’, array( $woo_tickets, ‘hijack_ticket_link’ ), 10, 4 );
    }
    add_action( ‘init’, ‘tribe_wootix_no_hijack’ );

    So unfortunately that simple solution you suggested doesn´t work…

    Any other idea ?

    Regards,

    Jürgen

    #1105733
    Geoff B.
    Member

    Hey Jürgen,

    After this last email, I believe I might have found the cause of your issue.

    I went ahead and literally pasted your code in my text editor and there seems to be an issue with your ‘ characters (delimitation). They are curved apostrophes (quote marks) which caused the code to break on my end.

    As you might know, you absolutely need to have straight quotations marks: http://typographyforlawyers.com/straight-and-curly-quotes.html for this to work

    Could you verify that please ?

    Let me know how that goes.

    Best regards,
    Geoff B.

    #1106226
    Jürgen
    Participant

    Hi Geoff,

    sorry to disappoint you, but I checked the code in the functions.php and there are only straight apostrophes.
    I guess, when I paste the code into the answeer field it gets translated (unicode or whatever) and therefore shows different marks.

    I´ve added a screenshot, so you can verify what I´m saying.

    Regards,

    Jürgen

    #1106937
    Geoff B.
    Member

    This reply is private.

    #1107815
    Jürgen
    Participant

    Hi Geoff,

    I´m not sure if I understand you correctly.
    I´m using a child-theme, so the theme-folder is quite small and I´ve added it to this post.
    If you need something more, just tell me.
    Regards,
    Jürgen

    #1108070
    Geoff B.
    Member

    Good evening Jürgen,

    Thank you for the requested folder.
    I checked it thoroughly and everything looks great.

    This leaves us with 2 possible causes:

    1. Some users have reported that the https://theeventscalendar.com/knowledgebase/moving-the-ticket-form/ does not work properly with WordPress 4.5 under certain conditions.

      This might be your case. At any rate, we are working on making the snippet more thoroughly compatible with WordPress 4.5. Unfortunately, I cannot commit to a release date at this point. But stay tuned!

      We apologize for any inconvenience this might cause.

    2. It is possible that one of your other plugin might be conflicting. In which case you would need to go through our testing for conflicts procedure (preferably in a staging/dev environment or local install of your WordPress website) and let us know what you find out.Basically the goal here is to revert back to a bare WordPress installation to see if the problem persists. It also allows us to pinpoint what the cause of the issue is.

    I wish I had a better answer for you, but for now it’s the best one I have.

    Have a great day!

    Geoff B.

     

Viewing 15 posts - 1 through 15 (of 16 total)
  • The topic ‘Move the "add to cart button" on WooCommerce Tickets – alternative form.php’ is closed to new replies.