jamie Developer Od Hungary Użytkownik od lip 2017 jamie 4 paź 2021 12:15 Hello! The code below is on the wiki page. return array( 'title' => $this->name, 'options' => array( array( 'id' => 'option_1', 'icon' => $this->settings['icon'], 'name' => 'Option 1', 'description' => 'This is the description for option 1', 'fields' => '<input type="text" name="foo" value="'. @$this->userdata['foo'] .'" />' . PHP_EOL . '<input type="text" name="bar" value="'. @$this->userdata['bar'] .'" />', 'cost' => $this->settings['fee_1'], 'tax_class_id' => $this->settings['tax_class_id'], 'exclude_cheapest' => false, ), ), ); }``` The custom field appears on the checkout page and can be filled out. But how do I see this on the orders page? How can I record this so I can see it when editing my order?
tim Founder Od Sweden Użytkownik od maj 2013 tim 4 paź 2021 14:40 The next version 3.0 will save the shipping user data to the order. But for 2.x you would need to process this data yourself in the module. You should be able to access the data using $_POST['myvar'] in select() and after_process().
jamie Developer Od Hungary Użytkownik od lip 2017 jamie 4 paź 2021 14:52 Thanks Tim! Not showing the current version 3.0 yet? I do not see the completed field when ordering.
tim Founder Od Sweden Użytkownik od maj 2013 tim 5 paź 2021 02:38 I am working hard to get a public beta out for 3.0. Maybe within weeks. Did you try something like this? $order->data['comments'][] = [ 'text' => 'Value of myvar:' . $_POST['myvar'], ]; $order->save(); }
jamie Developer Od Hungary Użytkownik od lip 2017 jamie 5 paź 2021 12:50 Yes I tried and this too but it doesn't go through. database::query( 'UPDATE '.DB_TABLE_ORDERS." SET `foo` = '". database::input($this->userdata['foo']) ."', `bar` = '". database::input($this->userdata['bar']) ."' WHERE id = '". (int)$order->data['id'] ."' LIMIT 1;" ); }```
tim Founder Od Sweden Użytkownik od maj 2013 tim 9 paź 2021 18:10 Did you get an error or did it just simply not set any data? What does this show?: var_dump($this->userdata); exit;
jamie Developer Od Hungary Użytkownik od lip 2017 jamie 11 paź 2021 08:43 So far nothing has been shown, now there is an error message: Fatal error: 1054 - Unknown column 'foo' in 'field list' UPDATE lite4.lc_orders SET foo = 'test1', bar = 'test2' WHERE id = '6' LIMIT 1; in ~/includes/library/lib_database.inc.php (Line 260)
tim Founder Od Sweden Użytkownik od maj 2013 tim 11 paź 2021 23:46 Oh wait.. you can't actually input 'foo' and 'bar' as column names. That's a dummy example 😆. Create the column and put the real name in.