JSON tweak from 1.6

This commit is contained in:
Mike Jolley 2012-12-13 14:57:31 +00:00
parent 78d25ff557
commit dda8b8afbe
3 changed files with 9 additions and 5 deletions

View File

@ -245,7 +245,11 @@ jQuery(document).ready(function($) {
data: $form.serialize(),
success: function( code ) {
try {
result = $.parseJSON( code );
// Get the valid JSON only
var code = code.split("<!--WC_END-->")[0];
// Parse
var result = $.parseJSON( code );
if (result.result=='success') {

File diff suppressed because one or more lines are too long

View File

@ -654,7 +654,7 @@ class WC_Checkout {
$result = apply_filters('woocommerce_payment_successful_result', $result );
if ( is_ajax() ) {
echo json_encode( $result );
echo json_encode( $result ) . '<!--WC_END-->';
exit;
} else {
wp_redirect( $result['redirect'] );
@ -685,7 +685,7 @@ class WC_Checkout {
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $return_url, $order)
)
);
) . '<!--WC_END-->';
exit;
} else {
wp_safe_redirect(
@ -718,7 +718,7 @@ class WC_Checkout {
'messages' => $messages,
'refresh' => isset( $woocommerce->session->refresh_totals ) ? 'true' : 'false'
)
);
) . '<!--WC_END-->';
unset( $woocommerce->session->refresh_totals );
exit;