Posted: January 15, 2014 at 9:11 am
|
I want to replace the default “Add to Cart” link with my own custom link. I have reviewed the documentation “Selectively hide the Add to Cart link”. Will this remove ALL “Add to Cart” links or just on the Event Registration page. Further, will I be able to define my own “Add to Cart” links without them being hidden, too. I was planning on using |
|
OK, I have tried Method 1 from the article and it worked for me with the default Event Registration. Can I assume that I can do something similar with Finally, can I put non-core EE files (like plugins for MER) into the |
|
Further, to automate the setting of the first value of the event_id, I’d like to use a shortcode that calls the event_id of the current/active event. The second value is a constant. This is the code I was thinking: Is there such a shortcode. Lacking that, could I call it in the PHP. How would I structure that? |
|
I took my first stab at writing my own shortcode. <code>//Returns event_id value for the current record. //Best used nested with other shortcodes //[EVENT_ID] function event_id_func( $atts ){ <?php echo $event_id ?>; } add_shortcode('EVENT_ID', 'event_id_func');</code> but it broke the rendering of the Event Registration page. Thoughts on where I went wrong? |
Hi Michael,
It’s possible, although add-to-cart links aren’t standard in the espresso_table.php, but if you add them, they can be selectively hidden.
No, only templates are checked for in that location. Any other files will be ignored. If you want to override pluggable functions or add new functions, Event Espresso will look in /wp-content/uploads/espresso/custom_functions.php for these.
While there isn’t a shortcode that returns the current event’s event ID, you can use the $event_id variable. If the $event_id variable isn’t set, like in the case of espresso_table.php, something like $event->id will work.
the php tag cannot be used inside another php tag. |
|
|
The only problem I have had using the [ESPRESSO_CART_LINK] is the updated “View Cart” link reverts back to “Add to Cart” when you do a full page reload. This is not the case with the default “Add to Cart” link. Recommendations? |
It may help to see the code you are using within the context of where the cart link shortcode is being included. Or is this a case where the shortcode is being added directly to the page within a page editor? |
|
|
|
You can open up cart.php and change line 1072 from: if ( $view_cart || is_array( $events_in_session ) && isset( $events_in_session[ $event_id ] )) { to: if ( $view_cart || is_array( $events_in_session ) && isset( $events_in_session[ $this_event_id ] )) { Then when you click the add to cart link that’s generated by the add to cart shortcode, then reload the page, it will still say view cart. |
|
|
Awesome (and Easy). Is that now a code refinement for core as I see that the default View Cart still works? (Mine are turned off, so I tested). If so, it is cool to know that I’m helping the process along. |
I’m not sure, I’ll need to check with the Dev team on the intent of that check. |
|
The support post ‘Replacing Add to Cart Link’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.