Home › Forums › Calendar Products › Events Calendar PRO › list-widget ..sold out / on sale
- This topic has 6 replies, 2 voices, and was last updated 10 years, 9 months ago by
Brian.
-
AuthorPosts
-
July 18, 2015 at 10:42 am #987584
John Paul
Participanthttps://theeventscalendar.com/knowledgebase/adding-sold-out-notices-in-list-view/
Hi,, a few days ago I successfully created “sold out” and “On sale” notices in the list view.
I have now tried to do the same for the widget view and am struggling.
I created a directory wp-content/themes/my-child-theme/widgets/list-widget.php
and copied the code from the link above into the list-widget.php file now in my child theme. But I do not see any sold out or on sales notices. Here is the code in the file
}
// Retrieves the posts used in the List Widget loop.
$posts = tribe_get_list_widget_events();// The URL for this widget’s “View More” link.
$link_to_all = tribe_events_get_list_widget_view_all_link( $instance );// Check if any posts were found.
if ( isset( $posts ) && $posts ) :foreach ( $posts as $post ) :
setup_postdata( $post );
do_action( ‘tribe_events_widget_list_inside_before_loop’ ); ?><!– Event –>
<div class=”<?php tribe_events_event_classes() ?>”>
<?php tribe_get_template_part( ‘pro/widgets/modules/single-event’, null, $instance ) ?>
</div><!– .hentry .vevent –><?php do_action( ‘tribe_events_widget_list_inside_after_loop’ ) ?>
<?php endforeach ?>
<p class=”tribe-events-widget-link”>
” rel=”bookmark”>
<?php _e( ‘View More…’, ‘tribe-events-calendar-pro’ ) ?>
<?php if ( tribe_events_has_soldout() ): ?>
<span class=”tickets-sold-out”>
Sold out!
</span>
<?php elseif ( tribe_events_has_tickets() ): ?>
<span class=”tickets-in-stock”>
On sale!
</span>
<?php endif ?
</p><?php
// No Events were found.
else:
?>
<p><?php printf( __( ‘There are no upcoming %s at this time.’, ‘tribe-events-calendar’ ), strtolower( tribe_get_event_label_plural() ) ); ?></p>
<?php
endif;// Cleanup. Do not remove this.
wp_reset_postdata();perhaps I am putting the new code in the wrong place??? can you advise….
July 20, 2015 at 7:05 am #987787Brian
MemberHi,
Thanks for using our plugins.
I can help out here.
Since you are using Pro you want to move and edit this file instead:
events-calendar-pro\src\views\pro\widgets\modules\single-event.php
As that file replaces the core list widget display.
I tried in that file myself with this coding and got it to work:
<p>
<?php if ( tribe_events_has_soldout() ): ?>
<span class='tickets-sold-out'>
Sold out!
</span>
<?php elseif ( tribe_events_has_tickets() ): ?>
<span class='tickets-in-stock'>
On sale!
</span>
<?php endif; ?>
</p>Let me know how that works out for you.
Cheers
July 20, 2015 at 7:16 am #987799John Paul
Participantthanks Brian, I will give this a try…I want to be able to then do the single post view as well, so as I am using pro..which file should I target?
July 20, 2015 at 7:59 am #987827Brian
MemberHi,
The single event template is still controlled by core in this file:
the-events-calendar\src\views\single-event.php
Also look in the modules directory there for different parts of the single event template to find the one you would like to add the message too.
Thanks
July 20, 2015 at 8:23 am #987848John Paul
Participantthanks , for the widget and single event views, does it matter what directory structure I use in my child theme? or could I just put the new files directly under …/child-theme/tribe-events/
July 20, 2015 at 8:31 am #987853John Paul
Participantsorry to be a pain…just to be clear , when I open an event I get a view where the below the venue details there is the heading “Tickets” . I want to be able to put the number of tickets left for sale to the right of this heading and to say “sold out” if true. Which file do I target to do this?? as I guess Wooticket is not part of the core
July 20, 2015 at 1:51 pm #988127Brian
MemberHi,
The directory structure needs to be the same as in the plugin itself. Instead of /views/ being the base /tribe-events/ replaces views and is the base directory.
This is the function that shows the title in the single template:
<?php the_title( '<h2 class="tribe-events-single-event-title summary entry-title">', '</h2>' ); ?>
The list view single event title is this:<?php the_title() ?>You may have to play around with it to get it to display how you like, but this is about as much as I can help on a customization.
Cheers.
-
AuthorPosts
- The topic ‘list-widget ..sold out / on sale’ is closed to new replies.
