redirect single event "add to cart" button to another event page

Home Forums Ticket Products Event Tickets Plus redirect single event "add to cart" button to another event page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1157310
    Valerie
    Participant

    This is a workaround since you don’t offer ticket upsells. I made my main event and added 9 tickets. Then I made a secondary event page with 2 tickets that are available as upsells.

    When the user clicks “add to cart” on the main event page, I want to send them to the secondary page.

    I know how to do this for regular “products” post types, but since these are events pages, I’m wondering if you can help.

    Here’s how to do it with Product post type IDs:

    // * Redirect users after add to cart. */
    function my_custom_add_to_cart_redirect( $url ) {
    	
    	if ( ! isset( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) {
    		return $url;
    	}
    	
    	$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) );
    	
    	// Only redirect the product IDs in the array to the checkout
    	if ( in_array( $product_id, array( 718 ) ) ) {
    		$url = get_permalink( 751 ); // URL to redirect to (1 is the page ID here)
    
    	}
    		return $url;
    }
    add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
    #1157411
    Geoff B.
    Member

    Good evening Valerie and welcome back!

    Thank you for reaching out to us.

    I would love to help you with this topic.

    I would recommend using WooCommerce’s snippet: https://docs.woocommerce.com/document/set-a-custom-add-to-cart-url-to-redirect-to/

    As an alternative, there are a few plugins to do this too: https://wordpress.org/plugins/woocommerce-add-to-cart-custom-redirect/

    Let me know if that helps.

    Have a great day!

    Geoff B.

    #1157466
    Valerie
    Participant

    Hi–thanks, but the WC snippet changes ALL add to cart buttons and I need to change just this event’s button. The snippet I gave in the first message of this thread allows putting in a product ID but it’s not working for this event, which has 9 tickets, and is therefore a grouping of 9 simple products into that one Add to Cart button.

    So what I need to know is whether it’s possible to target just that one button on that one event. I know the event ID, but my snippet only is for products. I tried putting in one of the 9 ticket product IDs and that still didn’t work. So I don’t know if any of those plugins will work for this purpose, which is to point the one event to it’s secondary event since they’re all made for Products and not Events (which are groups of simple products). Does that makes sense?

    #1157854
    Geoff B.
    Member

    Good evening Valerie,

    Thank you for writing back.
    I totally see your point.

    The main issue you have to deal with is that there is one “Add to cart” button for all of these tickets by default.

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

    With that in mind, I think there are a couple of ideas worth exploring:

    1. Use Ajax to handle “Add to cart” which would offer more flexibility: https://theeventscalendar.com/support/forums/topic/add-to-cart-via-ajax/#post-1012713
    2. You could hide the default ticket box altogether for that event (using CSS) and, in the content, use single products shortcodes for each ticket. The net result will be that you have one “Add to cart” button for each product, which in turn should get you one step closer to what you are trying to achieve (it might also enable your snippet to work).

    Let me know if that helps.

    Have a great day!

    Geoff B.

    #1158134
    Valerie
    Participant

    Thanks for the idea. I’ll look into it.

    #1158579
    Geoff B.
    Member

    Good evening Valerie,

    Thank you for writing back and I hope it helps.

    You are welcome back on our support forums any time 🙂

    For now, I am going to close this thread.

    Have a great week!

    Geoff B.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘redirect single event "add to cart" button to another event page’ is closed to new replies.