Support

Home Forums Multiple Event Registration Add-on ONLY Hiding the Add to Cart link when viewing member events

ONLY Hiding the Add to Cart link when viewing member events

Posted: March 4, 2014 at 7:51 pm


Jeffrey Strickler

March 4, 2014 at 7:51 pm

Hello,
Below is a past topic I created and below that is a response from an EE staff. The topic is closed so I’m starting a new topic. My request is if someone could send the code to make the adjustments I’m needing. I did my research before purchasing this product and knew I needed a member only capability with the a way for staff to register for multiple courses (multiple event registration). Since the plugin claimed it could do this I purchased.
All I’m really needing is when someone goes to the event it shows the event title and details, but does not show the “Add to cart” link until they are logged in. That’s it. If there is an easier way to do this without using the “member” plugin and hard coding the Add to cart link I’m all for it.
Thanks,
Jeff

——————-

When I set events to be “Member Only” I receive the message that I must be logged in.
1) Is there a way I can modify this message?
2) Is there some way I could have it still show the description, but not the “Add to Cart” button (within the description)? Note: I’m using this rather than the register button so they can register for multiple events… [ESPRESSO_CART_LINK anchor=”Add to cart” direct_to_cart=1 moving_to_cart=”Redirecting to cart…”]

——————-

Hi,

1) Either via the language files ( https://eventespresso.com/wiki/how-to-change-wording-with-poedit/ ) or via editing a core file (not recommended) – member_functions.php in the espresso-members plugin.

2) Yes but you will need to edit the registration_page_display.php template to both allow the description to show and most likely embed the add to cart shortcode directly there so you can do a check to see if members only (it will be harder to check and show/hide it if it is in the description).

If PHP isn’t your thing, we have a list of recommended developers here – https://eventespresso.com/developers/event-espresso-pros/


Dean

March 5, 2014 at 6:12 am

Hi,

I drafted something up here – https://gist.github.com/Apina/2b513fff0d801b9c98e5

It can replace the entirety of the registration_page.php file (copy the registration_page.php and registration_page_display.php files FROM event-espresso/templates/ TO wp-content/uploads/espresso/templates and then repalce the file content there).

This is based on version 3.1.3.64

You will need the WP User Integration (Members) plugin active and the event needs to be marked as Members only.

You will then see this on the Event List – http://take.ms/moaLP

and this on the registration page http://take.ms/NZpk1


Jeffrey Strickler

March 5, 2014 at 12:31 pm

I appreciate the help with this. I’ve noticed 3 things.
1) When I try to login to WP it just gives me the white screen. It is logging me in, but I must put in a direct URL to a backend page and then it will load.
2) I’ll need to remove the short code in the events description (see image). Is there an “Add to Cart” button that can be hard coded to all events on the registration page (if logged in)? I don’t care what it looks like if I can restyle it.
3) The text is falling on top of each-other.
Not Logged in…
http://www.tagacademyomaha.com/wp-content/uploads/2014/03/notloggedin.png
Logged in…
http://www.tagacademyomaha.com/wp-content/uploads/2014/03/notloggedin.png

I am on Version 3.1.36.4.P


Jeffrey Strickler

March 5, 2014 at 12:32 pm

Sorry, this is the Logged in image…
http://www.tagacademyomaha.com/wp-content/uploads/2014/03/loggedin.png


Josh

  • Support Staff

March 6, 2014 at 9:53 am

Hi Jeffrey,

I’ll try to follow up with each of these below:

1) When I try to login to WP it just gives me the white screen. It is logging me in, but I must put in a direct URL to a backend page and then it will load.

Does this happen if you remove the code modifications? You might get an error message to display in you enable WP_DEBUG that can clue us in on what’s going on.

2) I’ll need to remove the short code in the events description (see image). Is there an “Add to Cart” button that can be hard coded to all events on the registration page (if logged in)? I don’t care what it looks like if I can restyle it.

Yes it can. One way to do this is copy over the add to cart code from event_list_display.php over to registration_page_display.php

3) The text is falling on top of each-other.

This looks like a float isn’t getting cleared in one case, and possibly and unclosed div. Can you post a link to the page so we can examine the source of the page?


Jeffrey Strickler

March 8, 2014 at 7:09 am

I’ll try to follow up with each of these below:

1) When I try to login to WP it just gives me the white screen. It is logging me in, but I must put in a direct URL to a backend page and then it will load.

Does this happen if you remove the code modifications? You might get an error message to display in you enable WP_DEBUG that can clue us in on what’s going on.

Yes, when the code modifications are gone (removing the two files from the uploads/espresso/templates directory) I do not get the white screen. When I set debug I see no error message.

2) I’ll need to remove the short code in the events description (see image). Is there an “Add to Cart” button that can be hard coded to all events on the registration page (if logged in)? I don’t care what it looks like if I can restyle it.

Yes it can. One way to do this is copy over the add to cart code from event_list_display.php over to registration_page_display.php

I’ve been having trouble getting the code to display the “add to cart” button. My variables in the events should be all correct. Is there just a simple line of code that would force the button on all events? If so, would you mind sending it?

3) The text is falling on top of each-other.

This looks like a float isn’t getting cleared in one case, and possibly and unclosed div. Can you post a link to the page so we can examine the source of the page?

I removed the class clearfix in a div and this is working now.


Jeffrey Strickler

March 8, 2014 at 7:42 am

Additional Info on #2: When I comment out multi_reg (see code below) the “add to cart” button appears. I have the “Multiple Event Reg” add on and enabled and it’s working great with the short code so I don’t know why it shows when this is removed.
if (/*$multi_reg && */event_espresso_get_status($event_id) == 'ACTIVE'...

Anyway, even though it now shows the button.. when clicked it does not re-direct to the cart like the short code does. It just shows the spinning circle forever.

Another thing.. When I click the Short code “add to cart” button that now just sits and spins as well. When I remove the two files out of the uploads/espresso/templates directory the short code button functions once again.


Jeffrey Strickler

March 8, 2014 at 8:21 am

Here are the two files…
http://bit.ly/1oAc5pc


Josh

  • Support Staff

March 10, 2014 at 10:57 am

Hi Jeffrey,

Have you tried doing a diff comparing the code that we ship with your customized code? Generally speaking we do not support customized template modifications. If your custom code is causing fatal errors, it’s outside of what we support.


Jeffrey Strickler

March 15, 2014 at 7:58 pm

I got close to figuring this out but anytime the add to cart link was clicked it just sat and spun in circles.

I did however find another work around so if anyone is desiring this functionality here it is…

I totally removed the member add-on and used a simple wp function to check to see if the user is logged in. Inside this I placed a wp shortcode function to place the add to cart shortcode. The below was placed in this file (registration_page_display.php).

<code>&lt;?php if (is_user_logged_in() ) { //only logged in user can see this ?&gt;
&lt;div&gt;&lt;br/&gt;
&lt;?php
echo do_shortcode(&quot;[ESPRESSO_CART_LINK anchor=&#039;Add to cart&#039; direct_to_cart=1 moving_to_cart=&#039;Redirecting to cart...&#039;]&quot;); 
?&gt;&lt;br/&gt;&lt;br/&gt;
&lt;/div&gt;
&lt;?php } else { ?&gt;
&lt;div&gt;&lt;br/&gt;
&lt;i&gt;You must be logged in to register.&lt;/i&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;/div&gt;
&lt;?php } ?&gt;
</code>


Jeffrey Strickler

March 15, 2014 at 8:01 pm

That last post didn’t display very well so here is it again. Hopefully it displays the code.

<?php if (is_user_logged_in() ) { //only logged in user can see this ?>
<div><br/>
<?php
echo do_shortcode(“[ESPRESSO_CART_LINK anchor=’Add to cart’ direct_to_cart=1 moving_to_cart=’Redirecting to cart…’]”);
?><br/><br/>
</div>
<?php } else { ?>
<div><br/>
<i>You must be logged in to register. Login on the right or see the eligibility page for details.</i>
<br/><br/>
</div>
<?php } ?>


Dean

March 18, 2014 at 5:30 am

Hi Jeffrey,

Glad that you got it figured out in the end and thanks for sharing your solution.

The support post ‘ONLY Hiding the Add to Cart link when viewing member events’ 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.

Event Espresso