I'm sending a form from a woocommerce plugin. I've tweaked the thankyou.php page and added email sending functionality. However the $_POST array is empty.

Inspecting with Chrome Dev Tools I found that there is temporary redirect from the posted page:Chrome Dev Tools

The relevant form code: (in /woocommerce/templates/checkout/form-checkout.php)

  <form enctype="multipart/form-data" name="checkout" method="post"  id="checky" class="checky" action="http://pharma-job.shared6.lighthost.co.il/checkout/order-received">
<input type="hidden" name="admin_email" value="<?php echo get_option('admin_email'); ?>" />
    <?php if ( sizeof( $woocommerce_checkout->checkout_fields ) > 0 ) : ?>

        <?php do_action( 'woocommerce_checkout_before_customer_details'); ?>

        <div class="col2-set" id="customer_details">

            <div class="col-1">

                <?php do_action('woocommerce_checkout_billing'); ?>


            <div class="col-2">

                <?php do_action('woocommerce_checkout_shipping'); ?>


        <label for="cv_file">העלה קו"ח: </label>
  <input type="file" name="cv_file"> 
        <?php do_action( 'woocommerce_checkout_after_customer_details'); ?>

        <h3 id="order_review_heading"><?php _e('Your order', 'woocommerce'); ?></h3>

    <?php endif; ?>

    <?php do_action('woocommerce_checkout_order_review'); ?>


I looked at the generated HTML and found what appears to be the smoking gun:

<input type="hidden" name="_wp_http_referer" value="/checkout/" />

But what is the mechanism behind this redirect? How do I bypass it?


A brief background on the behavior of 3xx status codes

A 302 redirect is treated differently across browsers. Partially because of the variance of 302 in HTTP/1.0 and HTTP/1.1. HTTP 1.1 302 Found specifies that the request must not automatically be reprocessed at the returned location URI unless it can be confirmed by the user.

HTTP/1.0 were handled ambiguously prompting the creation of 303 and 307 for HTTP/1.1. 303 is to discard a POST where a 307 is to reprocess the request.

Data Flow

What is causing the redirect in this situation is unclear, but it is following a common behavior of resending the POST request as a GET request. I am assuming that all of the form processing is done elsewhere and sent to thankyou.php upon validation and a proper conversion. Based on this assumption there is likely a better place to tie in and implement the email functionality.

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.