My ajax retrieves the following response in the console:
PHP
$checkout_session_data = json_encode(['id' => $checkout_session->id]);
wp_send_json_success( $checkout_session_data );
// this is then retuend to the JS ajax function.
data: "{\"id\":\"cs_test_a1SOgBGIPsRrECu5pP8TDCW16JYMMHnGnmfh7Lp6qf8bvwTk3hK97sI7e7\"}"
success: true
I'm unclear how to get the ID value from the response from within the .done part of my ajax function.
.done( function(response) {
if( response.success == true ) {
console.log(response);
}
Attempts:
console.log(response.data.id);
console.log(response[0].id);