Posted: 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 |
|
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 e.g. id . ‘” anchor=”Add to cart”]’); ?> |
|
Hello, That is the exact code I am using. <code> <td class="padded"> <?php echo do_shortcode('[ESPRESSO_CART_LINK event_id="'.$event_id.'" anchor="Add to Cart"]'); ?> </td></code> When I copy / paste the code you provided it doesn’t work. |
|
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. |
|
Nothing shows within the boxes now. This is my code, |
|
Sorry the code on pastebin, |
|
Edited the Gist to add an echo before the do_shortcode. I tested it and it seems to be working fine. |
|
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 |
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 |
|
|
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! |
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. |
|
|
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. |
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. |
|
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.