Last active
May 10, 2018 15:01
-
-
Save fervous/c423cbbf4e2d9ca5e0689f15eb9630d4 to your computer and use it in GitHub Desktop.
UPDATED add field to product add edit form; display value on product page wc vendors pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* add to your theme or child theme functions.php file to create a new field on the vendor add-edit product form */ | |
add_action( 'wcv_product_options_general_product_data', 'wcv_custom_product_msrp_price_field' ); | |
function wcv_custom_product_msrp_price_field ($post_id) { | |
WCVendors_Pro_Form_Helper::input( array( | |
'post_id' => $post_id, | |
'id' => '_wcv_custom_product_msrp_price', | |
'label' => __( 'MSRP Price', 'wcvendors-pro' ), | |
'placeholder' => __( 'MSRP Price', 'wcvendors-pro' ), | |
'desc_tip' => 'true', | |
'description' => __( 'Please specify MSRP Price', 'wcvendors-pro' ), | |
) | |
); | |
} | |
/* add to your theme or child theme functions.php to display the field entry on the product page for customer view */ | |
add_action('woocommerce_before_add_to_cart_form', 'wcv_custom_product_msrp_price_display'); | |
function wcv_custom_product_msrp_price_display() { | |
$output = get_post_meta(get_the_ID(), '_wcv_custom_product_msrp_price',true ); | |
echo '<p>'.'Retail Price: ' . $output . '</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment