I am programming a payment plugin for WooCommerce. For the purposes of testing it, I need to print the values of $response. I have tried this withecho, print_r andvar_dump, but when I make the purchase process it does not print in any side.

What can I do to visualize this content when buying a product? (After entering the card details and making the purchase process I need to see those values)

Part of the plugin code:

    $payload = array(
      "key_id"  => $key_id,
      "hash" => $hash,
      "time" => $time,
      "amount" => $customer_order->order_total,
      "ccnumber" => str_replace( array(' ', '-' ), '', $_POST['bac_payment-card-number'] ),
      "ccexp" => str_replace( array( '/', ' '), '', $_POST['bac_payment-card-expiry'] ),
      "orderid" => $orderid,
      "cvv" => ( isset( $_POST['bac_payment-card-cvc'] ) ) ? $_POST['bac_payment-card-cvc'] : '',
      "type" => "auth",);
    // Send this payload to Authorize.net for processing
    $response = wp_remote_post( $environment_url, array(
      'method'    => 'POST',
      'body'      => http_build_query( $payload ),
      'timeout'   => 90,
      'sslverify' => false,
    ) );

//when I make a purchase I need to see these values


1 Answer 1


Those are values you'll need to write to the log in order to view them.

In order to do that, make sure you've got debugging turned on in your wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

Then, use the following utility function to write your values to the log. You could just use error_log( $value ), bu this utility will handle dealing with arrays/objects without having to worry about formatting arrays for the log file:

function write_log( $log )  {
    if ( is_array( $log ) || is_object( $log ) ) {
        error_log( print_r( $log, true ) );
    } else {
        error_log( $log );

Now instead of var_dump(), you can call write_log() to dump your result to /wp-content/error.log:


(There was a similar type of question yesterday, if you want to see some additional detail.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.