0

So I'm using some code from this post to make my orders show in Wordpress/Woocommerce using a shortcode.

function shortcode_my_orders( $atts ) {
    extract( shortcode_atts( array(
        'order_count' => -1
    ), $atts ) );

    ob_start();
    wc_get_template( 'myaccount/my-orders.php', array(
        'current_user'  => get_user_by( 'id', get_current_user_id() ),
        'order_count'   => $order_count
    ) );
    return ob_get_clean();
}
add_shortcode('my_orders', 'shortcode_my_orders');

The code does function, it is displaying info correctly when I use the shortcode. But I am getting a JSON Error.

When I put the code into JSON Parser online, it returns this

error: "SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data"

Is this an error with the particular code I'm using or something else?

Any help gratefully received.

DaFois
  • 2,197
  • 8
  • 26
  • 43
  • 2
    Show the JSON string, it's invalid. You can also use tools like https://jsonlint.com/ where you can paste the JSON text and the parser will tell you exactly which line is not compliant. – Shilly Nov 21 '18 at 12:25
  • I have tried your code and it just works perfectly without any error. So there is something else that is making that issue. – LoicTheAztec Nov 22 '18 at 01:24

0 Answers0