Hello, I want to create additional tabs that will contain information in all products, but I did not find how to do this in this menu, can you tell me?
I did this via woocommerce hooks. And this was not displayed in the product card when viewing it, but if you opened the product in the admin panel, you could see the additional tab and the information written in it. How can I display it in your constructor?
So if you want to modify files and don't know how, you should contact your web developer. Item Policy says:
Item support does not include services to modify or extend the item beyond the original features, style, and functionality described on the item page. For customization services that will help you tailor the item to your specific requirements, we recommend contacting the author to see if they privately offer paid customization services or checking out the great service providers on Envato Studio.
Comments
Following the example of the “description” field - a text block in which I can set the basic text, but I can also edit it for each product separately.
Hi,
There is no setting for that, and you would have to use an external plugin to create additional tabs for products.
Best regards
I did this via woocommerce hooks. And this was not displayed in the product card when viewing it, but if you opened the product in the admin panel, you could see the additional tab and the information written in it. How can I display it in your constructor?
// Добавляем вкладку "Дополнительная информация"
function add_custom_product_tab( $tabs ) {
$tabs['custom_tab'] = array(
'label' => __( 'Дополнительная информация', 'mytheme' ),
'target' => 'custom_tab_content',
'class' => array( 'custom-tab' ),
'priority' => 50,
);
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'add_custom_product_tab' );
// Добавляем поле мета-товара для дополнительной информации
function add_custom_meta_field() {
$args = array(
'id' => 'custom_tab_content',
'label' => __( 'Дополнительная информация', 'mytheme' ),
'type' => 'textarea',
'description' => __( 'Введите дополнительную информацию о товаре', 'mytheme' ),
);
woocommerce_wp_textarea_input( $args );
}
function save_custom_meta_field( $post_id ) {
$custom_tab_content = $_POST['custom_tab_content'];
update_post_meta( $post_id, 'custom_tab_content', $custom_tab_content );
}
add_action( 'woocommerce_product_options_general_product_data', 'add_custom_meta_field' );
add_action( 'woocommerce_process_product_meta', 'save_custom_meta_field' );
// Добавляем текст по умолчанию для дополнительной информации
function add_default_custom_tab_content() {
$default_content = '<p>В этом разделе вы можете найти дополнительную информацию о товаре.</p>';
foreach (get_posts(array('post_type' => 'product')) as $product) {
if (!get_post_meta($product->ID, 'custom_tab_content', true)) {
add_post_meta($product->ID, 'custom_tab_content', $default_content, true);
}
}
}
add_action( 'woocommerce_init', 'add_default_custom_tab_content' );
// Отображаем контент вкладки "Дополнительная информация"
function custom_tab_content() {
$post_id = get_the_ID();
$custom_tab_content = get_post_meta( $post_id, 'custom_tab_content', true );
echo '<p>'. $custom_tab_content. '</p>';
}
What you ask for requires file customization, which, in reference to the Item Support Policy, is not allowed. http://themeforest.net/page/item_support_policy
So if you want to modify files and don't know how, you should contact your web developer. Item Policy says:
Item support does not include services to modify or extend the item beyond the original features, style, and functionality described on the item page. For customization services that will help you tailor the item to your specific requirements, we recommend contacting the author to see if they privately offer paid customization services or checking out the great service providers on Envato Studio.
Thanks