Sitesao Support
  • Home
  • Themes
  • Plugins
  • Support

Support Forums

Home/Forums/
  • Profile
  • Topics Started
  • Replies Created
  • Favorites

Forum Replies Created

  • 8 years, 7 months ago Boboo
    Participant
    Post count: 4

    I’m sorry but i don’t understand your answer?

    I am not using default WordPress advance custom field, I’m using the above code I have share.


    in reply to: How to display custom field on single product page?
    8 years, 8 months ago Boboo
    Participant
    Post count: 4

    I’m sorry but i don’t have skype or teamviewer account.

    Here is the code I’m using on my function child theme, it’s working fine, how can i use a short-code to display the information on front end.

    // Display Fields using WooCommerce Action Hook
    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' => '_text_field', 
          'label' => __( 'Custom Text Field', 'woocommerce' ), 
          'placeholder' => 'Custom text field',
          'desc_tip' => 'true',
          'description' => __( 'Enter the custom value here.', 'woocommerce' ) 
        )
      );
    
      // Number Field
      woocommerce_wp_text_input( 
        array( 
          'id' => '_number_field', 
          'label' => __( 'Custom Number Field', 'woocommerce' ), 
          'placeholder' => '', 
          'description' => __( 'Enter the custom value here.', 'woocommerce' ),
          'type' => 'number', 
          'custom_attributes' => array(
             'step' => 'any',
             'min' => '15'
          ) 
        )
      );
    
      // Checkbox
      woocommerce_wp_checkbox( 
        array( 
          'id' => '_checkbox', 
          'label' => __('Custom Checkbox Field', 'woocommerce' ), 
          'description' => __( 'Check me!', 'woocommerce' ) 
        )
      ); 
    
      // Select
      woocommerce_wp_select( 
        array( 
          'id' => '_select', 
          'label' => __( 'Custom Select Field', 'woocommerce' ), 
          'options' => array(
             'one' => __( 'Custom Option 1', 'woocommerce' ),
             'two' => __( 'Custom Option 2', 'woocommerce' ),
            'three' => __( 'Custom Option 3', 'woocommerce' )
          )
        )
      );
    
      // Textarea
      woocommerce_wp_textarea_input( 
         array( 
           'id' => '_textarea', 
           'label' => __( 'Custom Textarea', 'woocommerce' ), 
           'placeholder' => '', 
           'description' => __( 'Enter the custom value here.', 'woocommerce' ) 
         )
     );
    
    }
    
    
    // Hook to save the data value from the custom fields add_action( 'woocommerce_process_product_meta', 'woocom_save_general_proddata_custom_field' );
    
    /** Hook callback function to save custom fields information */
    function woocom_save_general_proddata_custom_field( $post_id ) {
      // Save Text Field
      $text_field = $_POST['_text_field'];
      if( ! empty( $text_field ) ) {
         update_post_meta( $post_id, '_text_field', esc_attr( $text_field ) );
      }
      
      // Save Number Field
      $number_field = $_POST['_number_field'];
      if( ! empty( $number_field ) ) {
         update_post_meta( $post_id, '_number_field', esc_attr( $number_field ) );
      }
      // Save Textarea
      $textarea = $_POST['_textarea'];
      if( ! empty( $textarea ) ) {
         update_post_meta( $post_id, '_textarea', esc_html( $textarea ) );
      }
      
      // Save Select
      $select = $_POST['_select'];
      if( ! empty( $select ) ) {
         update_post_meta( $post_id, '_select', esc_attr( $select ) );
      }
      
      // Save Checkbox
      $checkbox = isset( $_POST['_checkbox'] ) ? 'yes' : 'no';
      update_post_meta( $post_id, '_checkbox', $checkbox );
      
      // Save Hidden field
      $hidden = $_POST['_hidden_field'];
      if( ! empty( $hidden ) ) {
         update_post_meta( $post_id, '_hidden_field', esc_attr( $hidden ) );
      }
    }
    

    Thank you


    in reply to: How to display custom field on single product page?
    8 years, 8 months ago Boboo
    Participant
    Post count: 4

    Well it has been 3 days still waiting for a answer. You seem to be more active here wouldn’t you mind Please checking the Forum support and get back to me.

    I have created extra meta data Custom Field coded on the Function Theme
    These fields are showing on backend Woo-commerce When creating new product are working fine. My only problem is how to display them on the front-end page when view the product pages

    Can we do it with a Short-Cod if so can you please provide a example so i can follow up.

    I can Provide you the code I’m using if is needed.

    Thank you


    in reply to: How to display custom field on single product page?
    8 years, 8 months ago Boboo
    Participant
    Post count: 4

    You clearly didn’t read my message or understood my question, Please do not drag this..

    1. I’m working on Localhost.

    2. I have already provided you the source code I have used Following this Tutorial URL link below
    http://www.remicorson.com/mastering-woocommerce-products-custom-fields/

    3. My Original Question was how can I display Custom field information on front end using your plugin. For example can we do it with the Short-Code if so how is this done?


    in reply to: How to display custom field on single product page?
Viewing 4 posts - 1 through 4 (of 4 total)
© Copyright Sitesao.com - Support Policy