You can try this… …rather than returning the value, send a JSON success message.
$response = new WP_REST_Response($final_price_return, 200);
wp_send_json_success( $response );
wp_die();
//you have to end the process, so if you're getting just a 0 returned in your JS success, it's because of this.
Then, in your JS/jQuery:
success: function (success, data) {
var res = success.data;
console.log(res)
$('#total_amount').html(res)
$('#totalbox').removeClass('d-none')
$('#email_form').removeClass('d-none')
},
It may even just be that your lack of wp_die()
or lack of exit()
at the end of your AJAX callback is the issue.
Related Posts:
- wc_get_template_part doesnt display the content [duplicate]
- What’s the preferred method of writing AJAX-enabled plugins?
- How to pass JavaScript variable to PHP in wordpress widget?
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Execute a function using ajax
- Errors while using ajax from external wordpress page
- Built in admin ajax hooks?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Why is my ajax call refreshing the page?
- Admin-ajax.php is dying “0” without processing function
- how to use ajax to display from database and load more in wordpress plugin
- REST-API: extend media-endpoint
- How to remove an Ajax action
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- $wpdb working with ajax but showing ajax error instead of success
- Ajax gives 400 error
- Check if email address exists front end with AJAX in a plugin
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- WooCommerce get_price returning wrong price when used via ajax
- Simple ajax call not working in wordpress plugin
- AJAX search posts and pages
- __callStatic method handler passed to add_action causes bug in PHP
- Using a custom plugin to capture input data via Ajax and PHP
- Ajax contact form widget plugin data not insert in database
- How to modify WCMP Rest API response?
- wp_remote_get() returns 403 while file_get_contents() does not
- Best place for if/else piece of code related to custom plugin?
- Ajax call returning 0
- Ajax with plugins returns 0
- how to do login using woocommerce rest api From android
- Create tabs in admin options page from custom post type loop
- What are the Best Practises When Using AJAX in Plugin Development?
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Submit Form data to another page via Ajax (WordPress Way)
- WordPress REST API Plugin Development – Add Custom Endpoint
- WordPress front end AJAX. Return 0 :?
- How to create WordPress custom end point with multiple parameters?
- Using WordPress to build membership Page
- Asynchronous request in wordpress
- Is there a better way of handling AJAX requests in WordPress?
- WordPress API functions not working at AJAX functions.php call
- Calling a class method instantiated by ajax call in wordpress [closed]
- Ajax request sends url rather than data
- best way to run a php script away from the template?
- Seperate plugin and theme files
- can’t unzip file
- wp_query ‘s’ parameter does not work with WC_AJAX
- Error datatable whit ajax
- How to use Datatable with Ajax when creating plugin on WordPress?
- Getting all woocommerce products from REST API call in plugin
- is it possible to fetch data from a remote api while admin is writing a new post?
- add tags to wordpress post using REST API
- How achive serving multiple concurrent Ajax / Rest calls in plugin?
- AJAX update fails for public/non-admin users
- Showing how many times is plugin activated or deactivated
- Can’t access 3rd party API, code works on local server but not on wordpress
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- ajax voting for custom post type
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Overwriting Plugin’s Ajax callback function from theme
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- wordpress ajax pagination object value does not change
- How can I use wp_ajax_response for front-end error reporting?
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- WordPress ajax not working in registration
- What’s the preferred method of writing AJAX-enabled plugins?
- Ajax, jQuery and WordPress
- How to get site homepage from plugin?
- Capturing POST data
- Extend WordPress REST API with Scheme Pro Plugin
- Help me with my first very basic plugin
- Load css classes after using ajax calls
- Jquery post responses 500 error after some time and lastly an 503 error
- How can I send api calls from my plugin?
- Inline AJAX script passing variables to PHP
- Is it possible to create post in wordpress using postman?
- wordpress admin-ajax bad request 400
- Accessing Correct Database to Create REST API Endpoint
- REST API – filters not working inside plugin class
- Ajax response from Media Selection does not update ALL information more than once
- Woocommerce plugin for minimum order and add-to-card-step
- Self deactivate plugins after an action occurs
- Custom REST API endpoint returns rest_no_route when called via wp-json permalink
- How to get current post user id
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Issue with adding count to “subsubsub” aka quick links on custom_post_type
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- How to slice an array using posts_per_page? [closed]
- White page on custom plugin option submit
- When to use action hooks and plugins
- Plugin version is not showing up in wordpress.org plugin directory
- Do action only on certain front end pages?
- Change plugin main file name (that is currently in the repo)
- Create dynamic page content from custom WordPress plugin page
- Plugin Options Not Saving to Database in WP 4.5