Skip to content

Instantly share code, notes, and snippets.

@fervous
Created June 7, 2018 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fervous/afa7cc2a4339ec02e2e1f8cc32dbbe43 to your computer and use it in GitHub Desktop.
Save fervous/afa7cc2a4339ec02e2e1f8cc32dbbe43 to your computer and use it in GitHub Desktop.
add field to product add edit form variations wc vendors pro
/* add to your theme or child theme functions.php file to create a new field for a variation on the vendor add-edit product form */
add_action( 'wcv_product_variation_after_pricing', 'wcv_custom_product_msrp_price_field_variation' );
function wcv_custom_product_msrp_price_field_variation ($post_id) {
WCVendors_Pro_Form_Helper::input( array(
'post_id' => $post_id,
'id' => '_wcv_custom_product_msrp_price_variation',
'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_variation_display');
function wcv_custom_product_msrp_price_variation_display() {
$output = get_post_meta(get_the_ID(), '_wcv_custom_product_msrp_price_variation',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