Answer the question
In order to leave comments, you need to log in
How to add "extra services" as a table in WP Wooccomerce?
Is there a plugin or maybe some kind of hack that can implement this?
Answer the question
In order to leave comments, you need to log in
Hello!
1) install the ACF Pro plugin to create custom fields or tabs.
2) Install the ACF Tables plugin to add tables.
3) create the necessary set of custom fields, namely:
Repeater for the ability to add multiple tables. And put ACF Tables in it.
Result:
View from the admin panel
View from the front (you can style it to your liking)
Code for functions.php
Add a new tab to WooCommerce
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
$tabs['params_tab'] = array(
'title' => __( 'Параметры', 'woocommerce' ),
'priority' => 60,
'callback' => 'params_tab'
);
return $tabs;
}
function params_tab() {
if( have_rows('wc_pr_params') ):
while ( have_rows('wc_pr_params') ) : the_row();
// начало таблицы
$table = get_sub_field( 'params_table' );
if ( $table ) {
echo '<table class="params_table" border="0">';
if ( $table['header'] ) {
echo '<thead>';
echo '<tr>';
foreach ( $table['header'] as $th ) {
echo '<th>';
echo $th['c'];
echo '</th>';
}
echo '</tr>';
echo '</thead>';
}
echo '<tbody>';
foreach ( $table['body'] as $tr ) {
echo '<tr>';
foreach ( $tr as $td ) {
echo '<td>';
echo $td['c'];
echo '</td>';
}
echo '</tr>';
}
echo '</tbody>';
echo '</table>'.'<br/>';
} // конец таблицы
endwhile;
else :
// no rows found
endif;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question