• Resolved zumajoe

    (@zumajoe)


    I’m trying to insert a value as custom meta for a WooCommerce order from a query string parameter the url e.g.: mystore.com/checkout?myparam=customvalue

    For some reason I cannot return any value from $_GET :

    add_action('woocommerce_checkout_create_order', 'before_checkout_create_order', 20, 2);
    
    function before_checkout_create_order( $order, $data ) {
    
         if ( isset( $_GET['myparam'] ) ) {
              $myvalue = $_GET['myparam'];
         }
    
         $order->update_meta_data( '_mymeta', $myvalue );
    
    }
    

    I’m confused because I believe woocommerce_checkout_create_order fires upon hitting submit for the checkout so I don’t understand why it wouldn’t be able to pull this from the current url.

    I’ve tested dummy values such as $myvalue = 'test'; to ensure the meta data is inserted and that works fine.

    • This topic was modified 3 years, 2 months ago by zumajoe.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @zumajoe,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thanks.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved for now.

    Hopefully, you were able to find a solution and the above resources for developers were helpful to you. If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WooCommerce: How to insert a value from $_GET into $order->update_meta_data’ is closed to new replies.