Home › Forums › Ticket Products › Event Tickets Plus › redirect single event "add to cart" button to another event page
- This topic has 6 replies, 3 voices, and was last updated 9 years, 8 months ago by
Valerie.
-
AuthorPosts
-
August 29, 2016 at 3:31 pm #1157310
Valerie
ParticipantThis 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' );August 29, 2016 at 10:12 pm #1157411Geoff B.
MemberGood 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.
August 30, 2016 at 2:03 am #1157466Valerie
ParticipantHi–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?
August 30, 2016 at 3:32 pm #1157854Geoff B.
MemberGood 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:
- 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
- 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.
August 31, 2016 at 8:05 am #1158134Valerie
ParticipantThanks for the idea. I’ll look into it.
August 31, 2016 at 10:39 pm #1158579Geoff B.
MemberGood 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.
-
AuthorPosts
- The topic ‘redirect single event "add to cart" button to another event page’ is closed to new replies.
