Support

Home Forums Events Calendar Add-on add to cart in calendar

add to cart in calendar

Posted: May 31, 2013 at 11:32 am


Janis

May 31, 2013 at 11:32 am

Hi

I have added the following code to my event description:

[ESPRESSO_CART_LINK event_id=”2″ anchor=”Add to cart”]

I did this as I want an ‘add to cart’ facility when the user views the single event page.  This shows up fine when I view the event page.  When I go to my calendar page and hover over the event the link also shows up with the description but the text has changed to ‘Register’ instead of ‘Add to cart’ – is there any way I can change this back to ‘Add to cart’?

Did find this:

if (isset($espresso_calendar[‘show_tooltips’]) && $espresso_calendar[‘show_tooltips’] == true) {
$eventArray[‘description’] = espresso_format_content($event->event_desc);

in espresso-calendar.php but then can’t find the espresso_format_content function to change the display text.  Am I looking in the right place?  Many thanks.


Josh

  • Support Staff

May 31, 2013 at 12:20 pm

Hi Sue,

I would take a different approach and change the text string with the gettext filter.

If you add this to your theme’s functions.php file that should do the trick:

function mycustom_filter_gettext( $translated, $original, $domain ) {
 
    // This is an array of original strings
    // and what they should be replaced with
    $strings = array(
        'Register' => 'Add to Cart',
        // Add some more strings here
    );
 
    // See if the current string is in the $strings array
    // If so, replace it's translation
    if ( isset( $strings[$original] ) ) {
        // This accomplishes the same thing as __()
        // but without running it through the filter again
        $translations = &get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
 
    return $translated;
}
 
add_filter( 'gettext', 'mycustom_filter_gettext', 10, 3 );


Janis

June 1, 2013 at 5:14 am

You are a star, thank you so much.


Janis

June 1, 2013 at 5:28 am

Oh no – just noticed though that it then obviously changes the text on the ‘Register’ button on a single event page to say ‘Add to cart’ which isn’t what its doing – ditto on the event list page – I end up with a button saying ‘Add to cart’ followed by the text ‘or Add to cart’.  My aim on each screen is for my user to have both options of register or add to cart (which they do but the labels are now misleading.)

I only want to change what its displaying when you hover over the calendar – is it hard coded somewhere that its replacing my  ‘add to cart’ text from here ([ESPRESSO_CART_LINK event_id=”2″ anchor=”Add to cart”] ) with ‘register’ in this instance?

Thank you.


Josh

  • Support Staff

June 3, 2013 at 10:09 am

Would it be better to not display the add to cart text in the description excerpt? If that sounds like it will work for you, you can add the more tag just before the cart link shortcode like this:

<!--more-->
[ESPRESSO_CART_LINK event_id="2" anchor="Add to cart"]


Janis

June 4, 2013 at 7:51 am

Hi

As when you hover over the event in the calendar it gives you the option to register I just felt it would also be nice to have the option to ‘add to cart’ as well.  We have some popular teachers who come and do two or three consecutive days teaching – each of these are separate events in the system (as we have to control capacity) – so figured it would be nice when looking at the calendar if they could quickly add multiple dates to the cart from there.

I guess as it allowed me to put the add to cart in the excerpt but just showed the wrong text – I figured this must be easy to make it say add to cart instead of register.  (I say that with the full knowledge that I don’t know how your system is put together so it may be anything but easy.)

Are you suggesting it is a bad idea, from a functionality point of view, to put an ‘add to cart’ in the excerpt?


Jonathan Wilson

June 4, 2013 at 4:45 pm

Hi Sue,

I don’t believe this is something that is currently an option with the calendar. I will add this to our feature request list for our developers to look into..

The support post ‘add to cart in calendar’ 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