Skip to content

Instantly share code, notes, and snippets.

@fervous
Last active August 6, 2017 23:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fervous/048b04a4a73cde43fd77b34405917f54 to your computer and use it in GitHub Desktop.
Save fervous/048b04a4a73cde43fd77b34405917f54 to your computer and use it in GitHub Desktop.
select2 add form to product page and product-edit.php
/* Put the below code in your product-edit.php template where you wish it to show up */
/*I've chosen directly before the - Product Categories */
<?php
WCVendors_Pro_Form_Helper::select( array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_condition',
'class' => 'select2',
'label' => __( 'Product Condition', 'wcvendors-pro' ),
'placeholder' => __( 'Please specify if your product is NEW or USED', 'wcvendors-pro' ),
'wrapper_start' => '<div class="all-100">',
'wrapper_end' => '</div>',
'desc_tip' => 'true',
'description' => __( 'Is your Product New or Used?', 'wcvendors-pro' ),
'options' => array(
'new' => __( 'New' ),
'used' => __( 'Used'),
'nwot' => __( 'New Without Tags' ),
)
) );
?>
/* Now, put the code below in your theme/child theme functions.php */
add_action('woocommerce_product_meta_start', 'wcv_product_condition', 2);
function wcv_product_condition() {
$output = get_post_meta(get_the_ID(), 'wcv_custom_product_condition', true );
echo '<p>'.'Product Condition: ' . $output . '</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment