Support » Plugin: WooCommerce Admin » I need to change wc_print_notices() message as json formate

  • Resolved kannu

    (@kannu)


    Hello Team

    Im using apply coupon service for my mobile app and it response like html outpot. but in my ionic app its trigger error, can you please let me know how to change html response of wc_print_notices() in to json formate.

    Thank you,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    Hello there,
    The wc_print_notices function is from the WooCommerce core package: https://github.com/woocommerce/woocommerce/blob/master/includes/wc-notice-functions.php#L134

    As you can see from the code, changing this to return JSON formatted data would require a rewrite of the function which is not a pluggable one.

    We DO NOT recommend changing the code of WooCommerce since that could cause unexpected issues and it would also be lost with every update.

    Hi. Could you at least provide an example of how we could retrieve the format in something else than raw HTML? Perhaps a $errors array or similar? Makes much more sense in my head, than returning raw HTML.

    @kannu this might be what you’re looking for:

    $notices = WC()->session->get(‘wc_notices’);
    json_encode($notices);

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I need to change wc_print_notices() message as json formate’ is closed to new replies.