Field.php
3 years ago
FieldInterface.php
3 years ago
Fields.php
3 years ago
FieldsInterface.php
3 years ago
Integrator.php
3 years ago
IntegratorIntegration.php
3 years ago
IntegratorInterface.php
3 years ago
Section.php
3 years ago
SectionInterface.php
3 years ago
Sections.php
3 years ago
SectionsInterface.php
3 years ago
Value.php
3 years ago
ValueInterface.php
3 years ago
Value.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FCF\Free\Integration; |
| 4 | |
| 5 | /** |
| 6 | * . |
| 7 | */ |
| 8 | class Value implements ValueInterface { |
| 9 | |
| 10 | /** |
| 11 | * Returns value of order field. |
| 12 | * |
| 13 | * @param string $field_key Field key. |
| 14 | * @param int $order_id ID of WC_Order. |
| 15 | * |
| 16 | * @return mixed Value of field, or null if not exists. |
| 17 | */ |
| 18 | public function get_field_value( string $field_key, int $order_id ) { |
| 19 | $order = wc_get_order( $order_id ); |
| 20 | if ( ! $order ) { |
| 21 | return null; |
| 22 | } |
| 23 | |
| 24 | $value = wpdesk_get_order_meta( $order, '_' . $field_key, true ); |
| 25 | $json = json_decode( $value, true ); |
| 26 | if ( $json ) { |
| 27 | return $json; |
| 28 | } else { |
| 29 | return $value; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 |