Home / eCommerce / Custom Vendor Product Fields for HTS and Export Classification Number
Duplicate Snippet

Embed Snippet on Your Site

Custom Vendor Product Fields for HTS and Export Classification Number

Vendor Product Editor Backend Preview: https://snipboard.io/KszCjU.jpg
Vendor Product Page Frontend Preview: https://snipboard.io/FNGhHt.jpg

Code Preview
php
<?php
// Output the custom HTS Classification at the bottom of the General tab of Product Edit Page.
add_action( 'wcv_product_options_general_product_data', 'wcv_product_hts_classification' );
function wcv_product_hts_classification( $object_id ){
     WCVendors_Pro_Form_Helper::textarea( array(
      'post_id'			=> $object_id,
      'id' 				=> 'wcv_custom_product_hts_classification',
      'label' 			=> __( 'HTS Classification', 'wcvendors-pro' ),
      'placeholder' 		=> __( 'Enter the HTS Classification number of this product here', 'wcvendors-pro' ),
      'desc_tip' 			=> 'true',
      'description' 		=> __( 'The product HTS Classification number', 'wcvendors-pro' ),
    ) );
}
// Display the custom HTS Classification on the Single Product Page.
add_action('woocommerce_product_meta_start', 'wcv_hts_classification', 2);
function wcv_hts_classification() {
    $output = get_post_meta( get_the_ID(), 'wcv_custom_product_hts_classification', true ); // Change wcv_custom_product_hts_classification to your meta key
	if ( ! empty( $output ) ) {
        echo 'HTS Classification: ' . esc_html( $output ) . '<br>';
    }
}
// Output the custom Export Classification at the bottom of the General tab of Product Edit Page.
add_action( 'wcv_product_options_general_product_data', 'wcv_product_export_classification' );
function wcv_product_export_classification( $object_id ){
     WCVendors_Pro_Form_Helper::textarea( array(
      'post_id'			=> $object_id,
      'id' 				=> 'wcv_custom_product_export_classification',
      'label' 			=> __( 'Export Classification', 'wcvendors-pro' ),
      'placeholder' 		=> __( 'Enter the Export Classification number of this product here', 'wcvendors-pro' ),
      'desc_tip' 			=> 'true',
      'description' 		=> __( 'The product Export Classification number', 'wcvendors-pro' ),
    ) );
}
// Display the custom Export Classification on the Single Product Page.
add_action('woocommerce_product_meta_start', 'wcv_export_classification', 2);
function wcv_export_classification() {
    $output = get_post_meta( get_the_ID(), 'wcv_custom_product_export_classification', true ); // Change wcv_custom_product_export_classification to your meta key
	if ( ! empty( $output ) ) {
        echo 'Export Classification: ' . esc_html( $output ) . '<br>';
    }
}

Comments

Add a Comment