Get Regular Price & Sale Price

Home Forums Ticket Products Event Tickets Plus Get Regular Price & Sale Price

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #962810
    Joshua
    Participant

    I have events setup for a price of $50, with a sale price within WooCommerce that last a certain amount of time for $35 dollars.

    I have it setup on a single event to display the sale price while it exists. Once the calendar in WooCommerce products shuts off the sale price, it shows the regular price just fine.

    I have a custom loop on my home page. Using: <?php echo tribe_get_formatted_cost(); ?> allows me to get the price, but once the WooCommerce sale ends, the price remains at 35 on the home page only.

    I need it to show the price of $50 after the sale ends and when it’s on sale, I need to display ON SALE in front of the price.

    Thank you.

    #962870
    George
    Participant

    Hi Joshua,

    This is unfortunately a set of customizations that fall outside the scope of our support, but the good news is that there seem to be enough filters and such in place that you can concoct something pretty good here.

    What I mean by that is that the tribe_get_formatted_cost() function runs its output through the ‘tribe_get_formatted_cost’ filter. So, you could alter the display of the cost with custom code like this:

    
    add_filter( 'tribe_get_formatted_cost', 'joshua_example_filter_price_display' );
    
    function joshua_example_filter_price_display( $price ) {
        $event_id = get_the_ID();
        return 'On sale' . $event_id . $price;
    }
    

    This example is super simple, but shows storing the event ID in a variable called $event_id, and returning the filtered $price content. If an event with the ID of 123 had a price of $20, this example function would change the display from “$20” to “On sale 123 $20”.

    This example may seem useless, but if you use the principles of using the $event_id and then you can put together code to check if your event ID is an event that’s on sale, then alter the display based on whether it’s on sale or not, you should be able to get something working here.

    I’m sorry if any of this is unclear, let us know if it helps!

    — George

    #984160
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Get Regular Price & Sale Price’ is closed to new replies.