Home › Forums › WoodMart support forum › Product extra fields
Product extra fields
- This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by Artem Temos.
-
AuthorPosts
-
March 18, 2020 at 12:57 pm #180722
[email protected]ParticipantHi,
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.March 18, 2020 at 1:50 pm #180735
Artem TemosKeymasterHello,
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
March 18, 2020 at 2:35 pm #180749
[email protected]ParticipantHI, 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!
March 18, 2020 at 2:57 pm #180757
Artem TemosKeymasterIt 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.
March 18, 2020 at 3:33 pm #180770
[email protected]ParticipantOk, thank you
March 19, 2020 at 7:03 am #180857
Artem TemosKeymasterYou are welcome.
-
AuthorPosts
Tagged: product extra fields
The topic ‘Product extra fields’ is closed to new replies.
- You must be logged in to create new topics. Login / Register