How to Add Filed in Single Product Page In WordPress

How to Add Filed in Single Product page In Wordpress

This code use for you can add files to your Single Product page, and this code adds your function.php file WordPress.

<?php
add_action( 'woocommerce_product_options_general_product_data', 'woocom_general_product_data_custom_field' );

function woocom_general_product_data_custom_field() {
  // Create a custom text field

  // Text Field
  woocommerce_wp_text_input(
    array(
      'id' => '_new_regular_price',
      'label' => __( 'New Regular Price', 'woocommerce' ),
      'placeholder' => 'New Regular Price',
      'desc_tip' => 'true',
      'description' => __( 'Regular Price', 'woocommerce' )
    )
  );
}
add_action( 'woocommerce_process_product_meta', 'woocom_save_general_proddata_custom_field' );

function woocom_save_general_proddata_custom_field( $post_id ) {
 $text_field = $_POST['_new_regular_price'];
 if( ! empty( $text_field ) ) {
  update_post_meta( $post_id, '_new_regular_price', esc_attr( $text_field ) );
 }
}
?>
Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us

Fill in the form below or give us a call and we'll contact you. We endeavour to answer all enquiries within 24 hours on business days.