Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 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);
    }
    Thread Starter mteter

    (@mteter)

    I think I answered my own question.

    One Solution:
    – create a new menu
    – create custom links under that menu, where each custom link goes to #some_id
    – set the new menu as the header menu

Viewing 2 replies - 1 through 2 (of 2 total)