It’s important to exit the function when using the wp_ajax hooks. Hopefully this fixes it.
function get_ticket_price() {
$ticketID = $_REQUEST['ticketID'];
echo wc_get_product( $ticketID )->get_price();
// Don't forget to stop execution afterward.
wp_die();
}
add_action( 'wp_ajax_get_ticket_price', 'get_ticket_price' );
add_action( 'wp_ajax_nopriv_get_ticket_price', 'get_ticket_price' );
Related Posts:
- Update Multiple Post Meta for the Same Post In One call?
- How to pass JavaScript variable to PHP in wordpress widget?
- Errors while using ajax from external wordpress page
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Open Post Thumbnail in New Child Theme File in WordPress
- Using a custom plugin to capture input data via Ajax and PHP
- What are the specifics of WordPress development I need to know? [closed]
- Ajax call returning 0
- Redirect to another page using contact form 7? [closed]
- Asynchronous request in wordpress
- WordPress API functions not working at AJAX functions.php call
- can’t unzip file
- Rename a folder via HTML POST request
- How can I see $post object in frontend from functions.php?
- How to use Datatable with Ajax when creating plugin on WordPress?
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- How to get site homepage from plugin?
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Help me with my first very basic plugin
- How to create post comparison in wordpress
- What’s the preferred method of writing AJAX-enabled plugins?
- What are the differences between WPINC and ABSPATH?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Customizing subject in comment notification e-mails
- category_name not working (not showing up in sql query debug)
- Using require_once in a Plugin?
- How can I make my custom shortcode work in a Custom HTML Widget?
- What is the correct way for a theme to support plugin UIs?
- Adding a text domain to every __(), _e() and __n() gettext call without a plan to create own translations
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- How to remove an Ajax action
- WordPress plugin installation
- Display future posts?
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Having separate plugins and themes folder for multi-site setup
- Getting media library popup in custom plugin admin page
- Create or Update thousands of woocommerce products via PHP
- How can I get full attachment url from wp_get_attachment_metadata?
- How to add pagination to wpbakery grid?
- send_headers don’t work on wordpress multisite
- jQuery function didn’t work in my plugin
- unzip a folder on specific location and delete the zip file
- gallery option is not available in media upload box in costum theme option page
- Why is the Settings API is not saving my array of options
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- $wpdb working with ajax but showing ajax error instead of success
- How to integrate plugin in WordPress theme
- How do you remove plugin edit option?
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- Ajax gives 400 error
- Plugin exceeds memory limit
- Check if email address exists front end with AJAX in a plugin
- Write to / remove from default .htaccess file from plugin?
- Update Option Error: Notice: Undefined index
- WordPress Ajax Callback
- Plugin Development sqlite or WordPress’ database
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- How to trigger $_GET request within admin plugin page?
- How to generate video out of images via WordPress plugin
- How can I get WordPress to save comments in markdown format?
- How to ‘clone’ a wp plugin to make small changes
- How to use get_theme_mod in gutenberg editor wordpress?
- Shortcode button dosent work for all posts. Work for first post only
- Where should I save an API key of my user when installing my plugin?
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Self deactivate plugins after an action occurs
- How to get current post user id
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Simple ajax call not working in wordpress plugin
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- WP Post Template – Templates in own folder
- Avoid class name collision when using third party libraries in plugins?
- wordpress plugin is not activating from widget
- Edit Yoast SEO breadcrumbs output [closed]
- How to put JQuery/Ajax inside shortcode?
- AJAX search posts and pages
- How would I go about creating a user ranked post popularity page?
- __callStatic method handler passed to add_action causes bug in PHP
- Redirection of users away from wp-admin (but not administrators)
- Display post lists in 2nd paragraph
- Ajax contact form widget plugin data not insert in database
- code is working properly in Core PHP but writing coding in WordPress
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Image upload and download from front-end
- wp_remote_get() returns 403 while file_get_contents() does not
- How to output CMB2 select options from repeated groups select elements?