• henkzuurbier

    (@henkzuurbier)


    Hi,

    We use your WooCommerce Product Input Fields option on our productpage.
    How can I get the value of this inside my functions.php?

    I try to load the following code and want to include the value of WooCommerce Product Input Fields:

    add_action('woocommerce_payment_complete', 'custom_process_order', 10, 1);
    function custom_process_order($order_id) {
        $order = new WC_Order( $order_id );
        $myuser_id = (int)$order->user_id;
        $user_info = get_userdata($myuser_id);
        $items = $order->get_items();
        foreach ($items as $item) {
            if ($item['product_id']==24) {
              // Do something
            }
        }
        return $order_id;
    }
Viewing 1 replies (of 1 total)
  • Algoritmika

    (@algoritmika)

    Hi @henkzuurbier,

    I didn’t test it, but please try adding something like this in your “Do something”:

    
    $product_input_fields = array();
    foreach ( $item->get_meta_data() as $value ) {
    	if ( false !== strpos( $value->key, 'wcj_product_input_fields_' ) ) {
    		$product_input_fields[ $value->key ] = $value->value;
    	}
    }
    

    Hope that helps.

    Best regards,
    Tom

Viewing 1 replies (of 1 total)
  • The topic ‘Get WooCommerce Product Input Fields in functions.php’ is closed to new replies.