| | |
| | | 'type' => 'text', |
| | | 'label' => 'Short Description', |
| | | ]; |
| | | $fields['post_id'] = [ |
| | | $fields['ID'] = [ |
| | | 'type' => 'text', |
| | | 'label' => 'ID', |
| | | ]; |
| | |
| | | |
| | | |
| | | $product = wc_get_product($id); |
| | | |
| | | $fields['sku'] = [ |
| | | 'type' => 'text', |
| | | 'label' => 'SKU', |
| | |
| | | $value = ''; |
| | | if ($this->type === 'option') { |
| | | $value = get_option(BASE . $fieldName, $config['default'] ?? ''); |
| | | } else if ($this->wpObject && $this->wpObject->post_type === 'product') { |
| | | if (property_exists($this->wpObject, $fieldName)) { |
| | | $value = $this->wpObject->$fieldName; |
| | | } else { |
| | | $product = wc_get_product($this->wpObject->ID); |
| | | $value = match ($fieldName) { |
| | | 'sku' => $product->get_sku(), |
| | | '_price' => $product->get_price(), |
| | | 'description'=> $product->get_short_description(), |
| | | 'sale' => $product->get_sale_price(), |
| | | 'img' => $product->get_image_id(), |
| | | '_stock' => $product->get_stock_quantity(), |
| | | '_stock_status' => $product->get_stock_status(), |
| | | default => '', |
| | | }; |
| | | } |
| | | |
| | | } else if ( |
| | | ($this->wpObject && property_exists($this->wpObject, $fieldName)) |
| | | || ($type === 'user' && $this->wpObject && property_exists($this->wpObject->data, $fieldName))) { |