Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter rossfabio

    (@rossfabio)

    Thank you very much!

    • This reply was modified 1 month, 2 weeks ago by rossfabio.
    Thread Starter rossfabio

    (@rossfabio)

    Hi, i’m really sorry…i went back to double check settings. Turns out i was using _order_total <> 0.00 to filter orders and apparently HPOS removes that custom field entirely, if i switch back to legacy order storage it gets used and works

    I momentarily solved by removing this filter, but it would be nice to be able to filter orders by total amount among the settings, i couldn’t find a way to do it…maybe there already is one?

    Many thanks!

    Thread Starter rossfabio

    (@rossfabio)

    Grandissimo! Grazie mille!

    Thread Starter rossfabio

    (@rossfabio)

    Hi @rainafarai , thank you very much for your response and for the work you’ve put into this plugin! Yes the thing that was bugging me was the autoload more than the database space, thank you also for the snippet!

    I took a look at the plugin files and there appear to be a delete option function already, but for some reason it is not doing its job properly, maybe it fires before the option gets registered on the database?

    In the meantime I have been using this other snippet which i find more direct, it doesn’t seem to interfere with new notifications and can run on a regular basis, and i run it every time i open the admin panel (a bit overkill, but i have other cleanup queries built into this function as well)

    function wr24_remove_unwanted_options() {
    global $wpdb;
    $options_table = $wpdb->prefix . 'options';

    $wpdb->query(
    "DELETE FROM $options_table WHERE
    option_name LIKE 'nftb_new_order_id_for_notification_%'"
    );
    }
    add_action('admin_init', 'wr24_remove_unwanted_options');

    cheers,
    Fabio

    Thread Starter rossfabio

    (@rossfabio)

    Hi Daniyal thank you for taking the time to answer,

    in /includes/classes/class.query-leaderboard.php on line 108 there is the following code to cope with multiple references separated by a comma

    if ( $based_on != 'balance' ) {
    
    $references = array();
    if ( ! empty( $args['based_on'] ) ) {
    	foreach ( explode( ',', $based_on ) as $ref ) {
    
    		$ref = sanitize_key( $ref );
    		if ( strlen( $ref ) == 0 ) continue;
    		$references[] = $ref;
    
    	}
    }
    $this->references = $references;
    
    $based_on = 'references';
    
    }
    
    $this->args['based_on']     = $based_on;

    then on line 402

    $reference_is      = 'l.ref = %s';
    $reference_values  = $this->references[0];
    
    if ( count( $this->references ) > 1 ) {
    
    $reference_is     = 'l.ref IN ( %s' . str_repeat( ', %s', ( count( $this->references ) - 1 ) ) . ' )';
    $reference_values = $this->references;
    
    }

    and the query on line 426 is

    if ( mycred_centralize_log() ) {
    
    $query = $wpdb->prepare( "
    SELECT DISTINCT l.user_id AS ID, SUM( l.creds ) AS cred 
    FROM {$mycred_log_table} l 
    WHERE {$reference_is} AND {$point_type_is} 
    {$time_filter}
    {$exclude_user_filter}
    GROUP BY l.user_id 
    ORDER BY SUM( l.creds ) {$this->order}, l.user_id ASC 
    {$this->limit};", $reference_values, $point_type_values );
    
    }

    so if the shortcode doesn’t parse multiple references queries there should be a function to call that does, can you point me in the right direction?

    What i’m trying to do is filtering the points of a point type with different filters without having to create a thousand point types

    For example, i organize events in different venues and users get points for attending, i need to be able to filter the points gained by event venue, type of event or both combined type and venue.

    Thread Starter rossfabio

    (@rossfabio)

    my pleasure, I have been tailoring the plugin to my needs for quite some time and thought I’d help by sharing some of my progress that can be useful to others ??

    if that’s ok I’ll post other snippets of code every now and then (I’ll open a new thread when I have a piece of new code that I think it’s worth sharing)

    cheers ??

    Hi @lukemv

    You can improve the display with some custom coding by modifying this template: wp-content/plugins/event-tickets/src/views/v2/tickets/item/extra/available/quantity.php

    To do so copy it to [your-theme]/tribe/tickets/v2/tickets/item/extra/available/quantity.php and apply the modifications you need

    My code right now looks like this, i made it so that instead of showing the number of tickets left, it shows “High”, “Medium” or “Low” availability until it reaches the threshold, then it switches to # of tickets left (this is just plain, it requires some more coding in css for styling)

    $capacita = tribe_tickets_get_capacity( $ticket ); 
    $threshold_media = 0.8*$capacita;
    $threshold_bassa = 0.5*$capacita;
    
    
    if (
    	( 0 !== $threshold && $threshold < $available_count )
    	|| $is_unlimited
    ) {
    	if ($available_count > $threshold_media) {
    	echo wp_kses_post(
    	sprintf(
    	// Translators: 1: opening span. 2: the number of remaining tickets to buy. 3: Closing span.
    		_x(
    			'Disponibilità: <span class="disponibilealta">Alta</span>',
    			'Tickets available',
    			'event-tickets'
    		),
    	)
    );
    return;
    }
    
    if ( $available_count > $threshold_bassa ) {
    echo wp_kses_post(
    	sprintf(
    	// Translators: 1: opening span. 2: the number of remaining tickets to buy. 3: Closing span.
    		_x(
    			'Disponibilità: <span class="disponibilemedia">Media</span>',
    			'Tickets available',
    			'event-tickets'
    		),
    	)
    );
    return;
    }
    
    if ( $available_count < $threshold_bassa || $available_count == $threshold_bassa ) {
    echo wp_kses_post(
    	sprintf(
    	// Translators: 1: opening span. 2: the number of remaining tickets to buy. 3: Closing span.
    		_x(
    			'Disponibilità: <span class="disponibilebassa">Bassa</span>',
    			'Tickets available',
    			'event-tickets'
    		),
    	)
    );
    }
    return;
    }
    
    if ($available_count == 0) {
    echo wp_kses_post(
    	sprintf(
    	// Translators: 1: opening span. 2: the number of remaining tickets to buy. 3: Closing span.
    		_x(
    			'%1$s %2$s %3$s disponibili',
    			'Tickets available',
    			'event-tickets'
    		),
            '<span class="tribe-tickets__tickets-item-extra-available-quantity">',
    		$available_count,
    		'</span>'
    	)
    );
    return;}
    
    
    
    echo wp_kses_post(
    	sprintf(
    	// Translators: 1: opening span. 2: the number of remaining tickets to buy. 3: Closing span.
    		_x(
    			'<span class="testodisponibilita">Disponibilità: </span><span class="personalizzadisponibili">%1$s %2$s %3$s disponibili</span>',
    			'Tickets available',
    			'event-tickets'
    		),
            '<span class="tribe-tickets__tickets-item-extra-available-quantity personalizzanumerodisponibili">',
    		$available_count,
    		'</span>'
    	)
    );

    hope it helped ??

    Thread Starter rossfabio

    (@rossfabio)

    thanks again juan, unfortunately this time i couldn’t get your code to work, but it brought me to the right path.

    modifying the template of the cost block wasn’t working for me (it only works if you create the event from the block editor, but that’s not my case), so i proceeded by modifying directly the single event template.

    i found something in the wordpress get post meta reference page and stylized it a bit accordingly. I inserted it into wp-content/themes/[my-theme]/tribe-events/single-event.php as suggested and it works fine

    i removed the if condition in the end, it wasn’t working for some reason and i anyways thought that if there is no text in the custom field to begin with, it’s not gonna show anything anyways.

    <?php $meta_print_value=get_post_meta(get_the_ID(),'my_custom_description',true); ?>
    <span class="tribe-block__event-price__description customcostdesc"><i><?php echo($meta_print_value); ?></i></span>
    
    <style>.customcostdesc {order: 5;}</style>

    Thanks again for all the help, you’ve been precious! I’ll leave a review right now ??

    Thread Starter rossfabio

    (@rossfabio)

    Hi Juan, sorry for the late reply and you’re right i should have specified a bit more what i needed to do.

    Currently yes, i was adding the price description through block editor, although i would prefer to switch to classic editor because the other people working on the backend are used to that.

    i played around a bit by modifying this file like so: the-events-calendar/src/views/blocks/event-price.php

    <?php if ( $post->my_custom_description ) : ?>
    		<span class="tribe-block__event-price__description"><?php echo esc_html( $post->my_custom_description );?></span>
    	<?php endif ?>

    which works great if i first set a price description from blocks editor and then i fill in the custom field in the classic editor, but if i skip the first step then nothing shows up, is there a way to work around that? maybe i should remove the if condition?

    again, thank you so much for the help!

    Thread Starter rossfabio

    (@rossfabio)

    Sorry to bother again Juan, is there a way to do the same with the price description? This way i can just have both the cost and the cost description in the same area of the editor, so that my colleagues have it easier to fill in

    Thread Starter rossfabio

    (@rossfabio)

    Thank you so much Juan, you are the man! Solved in 2 minutes thanks to you, worked great!

    I made only one change by removing the _ :

    
    add_filter( 'tribe_get_cost', 'tec_my_custom_get_cost', 10, 3 );
    
    function tec_my_custom_get_cost( $cost, $post_id, $with_currency_symbol ) {
    	$my_custom_cost = get_post_meta( $post_id, 'my_custom_cost', true );
    
    	return $my_custom_cost;
    }

    and custom field “my_custom_cost”

    thanks again!

    • This reply was modified 2 years, 12 months ago by rossfabio.
Viewing 11 replies - 1 through 11 (of 11 total)