I’m working on a site that uses the Events Tickets plugin, and I need to get the price of a ticket (Woo product) by ID. I’m using wc_get_product( $ticketID )->get_price();
to to do this.
Adding the price to the page using the code below gives the correct price (e.g. 30):
echo '<input type="hidden" id="ticketpricetest" value="' . wc_get_product( 28612 )->get_price() . '">';
However, when I try and get the price using the same method within an Ajax call it returns 300:
function get_ticket_price() {
$ticketID = $_REQUEST['ticketID'];
echo wc_get_product( $ticketID )->get_price();
}
add_action( 'wp_ajax_get_ticket_price', 'get_ticket_price' );
add_action( 'wp_ajax_nopriv_get_ticket_price', 'get_ticket_price' );
I’ve also tried using get_regular_price
but that also returns 300.
Any ideas what’s going on here?