'[cf=_sale_price before="Sale price: "]', 'Add text after value:' => '[cf=_weight after="kg"]', ); public $display_name = 'Field'; public function getValue($post, $field) { if ('name' === $field['value']) { $field['value'] = 'post_title'; } if (in_array($field['value'], array('post_title', 'post_content', 'post_excerpt')) && !empty($post->post_parent)) { $post = get_post($post->post_parent); } if ('post_title_variation' === $field['value']) { $field['value'] = 'post_title'; } return isset($post->{$field['value']}) ? $post->{$field['value']} : ''; } public function getVariants() { return array( array( 'label' => __("Product Id", "a4-barcode-generator"), 'shortcode' => "[field value=ID]", ), array( 'label' => __("Name (of main product only)", "a4-barcode-generator"), 'shortcode' => "[field value=post_title]", ), array( 'label' => __("Name (of variation or main product)", "a4-barcode-generator"), 'shortcode' => "[field value=post_title_variation]", ), array( 'label' => __("Short Description", "a4-barcode-generator"), 'shortcode' => "[field value=post_excerpt]", ), ); } }