Support – DawnThemes
  • Home
  • Portfolio
  • Support
  • Video Tutorials

Support Forums

Home/Forums/Plugins/WooCommerce Page Builder For Elementor/Woo Product Custom_Key

Woo Product Custom_Key

This topic is: not resolved
  • February 11, 2021 at 12:47 pm #33188

    romanice
    Participant

    Hello!

    I use 2 variation of add custom fields to woocommerce:

    1. I use this code in function.php

    // Добавляем текстовое поле с выходом блюда - https://www.proy.info/how-to-add-woocommerce-custom-fields/
    add_action( 'woocommerce_product_options_general_product_data', 'woocom_custom_field_product_amount' );
    function woocom_custom_field_product_amount() {
      // Create a custom text field
      // Text Field
      woocommerce_wp_text_input(
        array(
          'id' => 'product_amount',
          'label' => __( 'Количество', 'woocommerce' ),
          'placeholder' => '',
          'desc_tip' => 'false',
          // '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_custom_field_product_amount' );
    /** Hook callback function to save custom fields information */
    function woocom_save_custom_field_product_amount( $post_id ) {
      // Save Text Field
      $text_field = $_POST['product_amount'];
      if( ! empty( $text_field ) ) {
         update_post_meta( $post_id, 'product_amount', esc_attr( $text_field ) );
      }
    }
    // Display Custom Field Value
    echo get_post_meta( $post->ID, 'product_amount', true );

    2. I use plugin “WooCommerce Custom Fields” (https://codecanyon.net/item/woocommerce-custom-fields/11332742?s_rank=5)

    In first case (in Function.php) I made a custom field called ‘product_amount’.
    In second case (in plugin “WooCommerce Custom Fields”) I made a custom field called ‘serving_size’

    Then in Elementor I choose “Woo Product Custom_Key” and enter custom key. I tried and “product_amount” and “serving_size” (without quotation marks). And any custom fields are not showing


    Sorry, this forum is for verified users only. Please Login or Register to continue

Log In
Register Lost Password

Recent Topics

  • Some modules for WCFM are not available
  • Certains modules pour WCFM ne sont pas disponibles
  • WooCommerce Pagebuilder Plugin Install Failed
  • TICKET BOX THEME/DEMO IMPORT ASSISTANCE
  • Its not using my "Thank you" page

Knowledge Base

  • Do you provide customization service?
  • Register Envato Code
  • I can’t wait any longer! How can I quickly solve my problem?
  • How to get my Envato purchase code?
  • How to set as Private Reply over Support Forum

Recent Posts

  • Happy Lunar New Year 2021 – Holiday Break!

Featured Item

ThemeForest Items

CodeCanyon Items

Tags

#conflict avada cart cart page categories category checkout critical error CSS custom fields error Event page header images installation layout login membership menu mobile my account Page page builder page settings product product gallery product page product template refund Responsive shop page shortcode sidebar single product image Single Product Template template ticketbox Update Urgent video Viem Woocommerce WooCommerce Page Builder WPBakery wpml
© Copyright DawnThemes.com