Home Forums WoodMart support forum Product extra fields

Product extra fields

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #180722

    [email protected]
    Participant

    Hi,

    I am trying to add extra files on the products.
    In the web we use to have we have the Name of the product, and 2 other fields: place and GPS coordinates (find a picture attached).
    These info is added when we create a product and it is visible in the front under the product name.
    With your theme, is it possible to create extra fields, or only one extra field or something where I can writte what I want, and see it under the product name?

    Thank you!

    Attachments:
    You must be logged in to view attached files.
    #180735

    Artem Temos
    Keymaster

    Hello,

    There is no such mechanism in WooCommerce by default. You will need to perform some additional customization and it is not in our theme support scope. Here is a solution that may help you https://stackoverflow.com/questions/48444564/add-a-custom-field-value-below-product-title-in-woocommerce-archives-pages

    Kind Regards

    #180749

    [email protected]
    Participant

    HI, thank you!

    I don’t understand some things, where do I have to paste this code? On css general at Theme Settings?
    I have to paste the first one or the updated code or all of them?

    This is the first one:

    // Display Fields
    add_action(‘woocommerce_product_options_general_product_data’, ‘woocommerce_product_custom_fields’);

    // Save Fields
    add_action(‘woocommerce_process_product_meta’, ‘woocommerce_product_custom_fields_save’);

    function woocommerce_product_custom_fields()
    {
    global $woocommerce, $post;
    echo ‘<div class=”product_custom_field”>’;
    // Custom Product Text Field
    woocommerce_wp_text_input(
    array(
    ‘id’ => ‘_custom_product_text_field’,
    ‘placeholder’ => ‘Custom Product Text Field’,
    ‘label’ => __(‘Custom Product Text Field’, ‘woocommerce’),
    ‘desc_tip’ => ‘true’
    )
    );

    }

    function woocommerce_product_custom_fields_save($post_id)
    {
    // Custom Product Text Field
    $woocommerce_custom_product_text_field = $_POST[‘_custom_product_text_field’];
    if (!empty($woocommerce_custom_product_text_field))
    update_post_meta($post_id, ‘_custom_product_text_field’, esc_attr($woocommerce_custom_product_text_field));
    }

    And this is an update, as they say:

    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘custom_field_display_below_title’, 2 );
    function custom_field_display_below_title(){
    global $product;

    // Get the custom field value
    $custom_field = get_post_meta( $product->get_id(), ‘_custom_product_text_field’, true );

    // Display
    if( ! empty($custom_field) ){
    echo ‘<p class=”my-custom-field”>’.$custom_field.'</p>’;
    }
    }

    Thank you!

    #180757

    Artem Temos
    Keymaster

    It is a PHP code and you can put to the functions.php file in the child theme. Note that we are not responsible for any third-party customizations. If you have any difficulties with additional work like this, we suggest you to hire a developer for help.

    #180770

    [email protected]
    Participant

    Ok, thank you

    #180857

    Artem Temos
    Keymaster

    You are welcome.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Product extra fields’ is closed to new replies.