Support

Home Forums Event Espresso Premium Add to cart in Movie List custom template

Add to cart in Movie List custom template

Posted: July 10, 2013 at 5:27 am

Viewing 12 reply threads


aisling ward

July 10, 2013 at 5:27 am

Hello,

I have been messing around with the movie list template in the custom files add on.

I have been able to remove / add most of the things I wanted, but I am struggling to get the add to cart feature to actually link to the specific event.

When I click “add to cart” it doesn’t actually add anything

Link –> http://www.lotusfive.co.uk/our-services/studio/yoga/

I sent you some login details last night.

Many Thanks


Dean

July 10, 2013 at 5:49 am

One way to do it would be to use the Add to Cart shortcode and the Do Shortcode function

https://eventespresso.com/wiki/shortcodes-template-variables/#add-to-cart
http://codex.wordpress.org/Function_Reference/do_shortcode

e.g.

id . ‘” anchor=”Add to cart”]’); ?>


aisling ward

July 10, 2013 at 5:53 am

Hello,

That is the exact code I am using.

<code>          &lt;td class=&quot;padded&quot;&gt;
&lt;?php echo do_shortcode(&#039;[ESPRESSO_CART_LINK event_id=&quot;&#039;.$event_id.&#039;&quot; anchor=&quot;Add to Cart&quot;]&#039;); ?&gt;
          &lt;/td&gt;</code>

When I copy / paste the code you provided it doesn’t work.


Dean

July 10, 2013 at 5:58 am

Hi,

My code had a couple of typos, so sorry about that! Try from here https://gist.github.com/Apina/d536b3d9ce65d4178eec

If it is still not working, please can you post your code, to pastebin so I can see whats happening? Thanks.


aisling ward

July 10, 2013 at 6:05 am

Nothing shows within the boxes now.

This is my code,
<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”>
<tr class="gray">
<td class="padded">
<?php echo $event->event_name ?>
</td>
<td class="padded">
<?php echo event_date_display($event->start_date, $format = 'D') ?>
</td>
<td class="padded">
<?php echo event_date_display($event->start_date, $format = 'M d Y') ?>
</td>
<td class="padded">
<?php echo $event->start_time ?>
</td>
<td class="padded">
<?php echo $live_button ?>
</td>
<td class="padded">
<?php do_shortcode('[ESPRESSO_CART_LINK event_id="' . $event->id . '" anchor="Add to cart"]'); ?>
</td>
</tr>


aisling ward

July 10, 2013 at 6:07 am

Sorry the code on pastebin,

http://pastebin.com/iRVcXh2G


Dean

July 10, 2013 at 6:26 am

Edited the Gist to add an echo before the do_shortcode. I tested it and it seems to be working fine.


aisling ward

July 10, 2013 at 6:33 am

That’s great thankyou!

My cart is giving me a total of £20000020

Could this have something to do with cache?

Also, how can I add price?

I’ve tried

$event->event_price


Josh

  • Support Staff

July 10, 2013 at 8:13 am

It might be the session needs clearing. You can clear it by going to yoursite/registration-cancelled.

Prices are stored in the _events_price table, which isn’t queried in the movie list template, but you can use the [EVENT_PRICE] shortcode the same way you’re using the add to cart shortcode:

https://eventespresso.com/wiki/shortcodes-template-variables/#event-price


aisling ward

July 10, 2013 at 8:29 am

That’s great! I think everything is working just fine now 🙂

That code doesn’t work by the way…this does. I think there is a typo in it somewhere.

<pre class=”brush: php; gutter: true; first-line: 1; highlight: []; html-script: false”> <?php echo do_shortcode('[EVENT_PRICE event_id="' . $event->id . '" number="0"]');?>

Many Thanks!


Josh

  • Support Staff

July 10, 2013 at 8:44 am

It’s not really a typo. The code that’s in the documentation is for use with the newer template files where the event_id variable is $event_id. In some of the older templates (like the movie list) the event_id variable is $event->id. I’m sorry I forgot to mention it, but I’m glad you were able to figure that out.


aisling ward

July 10, 2013 at 8:56 am

Thanks Josh.

One last thing, how can I add the duration of an event in this movie list? I can’t find a shortcode for it.


Josh

  • Support Staff

July 10, 2013 at 9:32 am

I don’t believe duration is a field that gets entered into the event editor. You could add this as a custom field in the ee meta box -or- create a function that calculates the duration based on the event start and end times then display it in the table. In either case this will require some custom development.

Viewing 12 reply threads

The support post ‘Add to cart in Movie List custom template’ 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