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
- How can I make my custom shortcode work in a Custom HTML Widget?
- WordPress widget / plugin….fields not appearing in my widget
- How to list the Hooks and order of execution in current loading page? [duplicate]
- How to make my plugin theme-independent?
- Execute a function using ajax
- Admin-ajax.php is dying “0” without processing function
- Custom Shipping method not showing in checkout
- Workflow and best practice for documentation [closed]
- How to remove an Ajax action
- Ajax gives 400 error
- Write to / remove from default .htaccess file from plugin?
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- How can I get WordPress to save comments in markdown format?
- How to use get_theme_mod in gutenberg editor wordpress?
- Programatically download a plugin
- Redirecting to home page after login as custom role WordPress
- How would I go about creating a user ranked post popularity page?
- Create a plugin from within WordPress
- Class variables not correct on page
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- Activate my plugins via FTP
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Call plugin with php function
- Why is my custom post type not being activated on plug-in activation?
- How to add apply_filter for a class property in plugin
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- How do I add $_SESSION[”] to my wordpress page?
- How to use the CSS of the WordPress core in the development of my administration page?
- output html on post or page from custom plugin [closed]
- Built a second plugin but it overwrote the first one
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- Way to send multiple values for column to MySQL?
- What’s the right way to implement functions in footer.php
- Calling a class method instantiated by ajax call in wordpress [closed]
- How do you create a re-useable HTML fragment in wordpress
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Widgets are not displaying in the admin panel
- Conditional delete metadata does not works
- How can I adjust my function so the page editor still loads in the backend?
- submit two file input fields in the same form
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- Error datatable whit ajax
- woocommerce: Customize email with item total count
- Calling PHP function with AJAX
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Submitting form to PHP
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- working code, not working – Plugin Dev
- Submit remote form to wordpress REST API and save data to custom post type
- WordPress plugin blog creation
- implement checkbox or toggle switch in plugin code
- Create a form and have custom menu display based on user answers?
- Change Jobs for WordPress templates
- submit form data to wordpress existing database table using my plugin
- register_activation_hook doesn’t fire at all
- Problem with conditional woocommerce custom checkout field
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- How can I use wp_ajax_response for front-end error reporting?
- How to copy data from user profile page (profile.php) to theme customizer
- display user input using ajax in wordpress
- Plugin Breaking WordPress Login
- Breadcrumb is not generating the correct post page url
- Response from Php File to Ajax is not getting sent
- How to fix ‘Call to undefined function do_settings()’ error?
- What is the source outline for a basic word press plugin?
- Submit posts in two different post types with the same form
- Load css classes after using ajax calls
- Integrating WordPress Content into a jQuery Slider
- Ajax button “Load more” is not loading correct language version posts for logged out users
- wp_handle_upload – specified file failed upload test
- how to make wordpress remember my choice
- Meta box not displaying on the plugin page
- How to make a Template page to show the information of different things Shop and Product page?
- wordpress admin-ajax bad request 400
- public custom posts not showing in my wordpress plugin