• Hi all. I’m new to WP development, but experienced in other backend and web development.

    I’m trying to greatly simplify the user flow of Woocommerce, but I’ve hit a problem after Place Order is clicked.

    How can I trace what is happening?

    Because my site is very simple, and it is just selling a membership, I have the landing page automatically populate a cart with the only product (the membership). I also show the [woocommerce_checkout] at the bottom of the page.

    I see the correct checkout information, including my cart with 1 item. And to rule out any payment issues, I set “cash/cod” as my only payment method.

    I expect when the user clicks Place Order that an order will be created in the DB, and the user will be directed to a Thank You page (although no such page exists, yet, and I don’t see how to even configure that).

    What is actually happening is the user gets sent to the Cart page, and the cart is now empty.

    Why didn’t the order get created? Why didn’t the user get sent to an order complete page? And why, when it sent them back to the Cart, was the cart empty?

    Since I recognize that I don’t yet know much about WC, I’m hoping to be able to trace the process from the Place Order submit and onward.

    TIA.

Viewing 1 replies (of 1 total)
  • Thread Starter mteter

    (@mteter)

    Upon further testing, it seems that my programmatically populated cart must have some problem that causes it to be not accepted by Woocommerce on in the Checkout process.

    When I tested the standard user method of Add to Cart, then Checkout, after filling in my details and clicking Place Order, I was indeed sent to the Thank You page. So clearly that process works.

    Now the question is, why is my programmatically defined cart looking reasonable on the Checkout page, but obviously not good enough to pass the order creation phase?

    This is how I setup the cart:

    function foo_prepopulate_cart_action($post_object) {
      if (is_null(WC()) || is_null(WC()->cart)) {
        return;
      }
      $referrer = get_query_var('referrer', '');
      WC()->cart->empty_cart();
      $custom_data = array();
      $custom_data['custom_data']['referrer'] = sanitize_text_field($referrer);
      WC()->cart->add_to_cart(17, '1', '0', array(), $custom_data);
    }
Viewing 1 replies (of 1 total)
  • The topic ‘How to trace Place Order process’ is closed to new replies.