5th Year Anniversary Super Sale! Save Upto 50% OFF*

Custom Fields to Product page

By
2 Reviews ( 5 )

Adding a custom fields with aliexpress, etsy, ebay, themeforest, amazon clones is not a difficult.

To add a “Text Box” field in post product page, Add following code in product-edit.php template

 

WCVendors_Pro_Form_Helper::textarea( array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_ingredients',
'label' => __( 'Ingredients', 'wcvendors-pro' ),
'placeholder' => __( 'Ingredients', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'The product ingredients', 'wcvendors-pro' ),
) );

 

To add a “Text Area” field in post product page, Add following code in product-edit.php template

 

WCVendors_Pro_Form_Helper::input( array(
'type' => 'text',
'post_id' => $object_id,
'id' => 'wcv_custom_product_ingredients',
'label' => __( 'Ingredients', 'wcvendors-pro' ),
'placeholder' => __( 'Ingredients', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'The product ingredients', 'wcvendors-pro' ),
) );

 

—- Following code will display the values on the single product page. Add this code to your themes functions.php file —-

 

add_action('woocommerce_product_meta_start', 'wcv_ingredients', 2);
function wcv_ingredients() {
$output = get_post_meta( get_the_ID(), 'wcv_custom_product_ingredients', true );
// Change wcv_custom_product_ingredients to your meta key
echo 'Ingredients: ' . $output . '
';
}

Show Buttons
Hide Buttons