Created
October 7, 2022 13:47
-
-
Save yuliyang/7ef9b13a3404612750ae630fd448667a to your computer and use it in GitHub Desktop.
[ WooCommerce ] Single Product - add new/rename product info tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// single product - add new tab | |
add_filter( 'woocommerce_product_tabs', 'dejavu_woo_new_tab' ); | |
function dejavu_woo_new_tab( $tabs ) { | |
// rename default product tabs | |
$tabs[ 'description' ][ 'title' ] = '內容簡介'; | |
$tabs[ 'additional_information' ][ 'title' ] = '其他資訊'; | |
// display only when ACF custom fields is presented | |
if( is_singular('product') && get_field('my-field') ) : | |
$tabs['other_tabs'] = array( | |
'title' => __( '目錄', 'woocommerce' ), | |
'priority' => 1, | |
'callback' => 'dejavu_woo_new_tab_content' | |
); | |
endif; | |
return $tabs; | |
} | |
function dejavu_woo_new_tab_content() { | |
echo $variable = get_field('my-field'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment