Created
July 7, 2016 15:25
-
-
Save oneblackcrayon/5cb191f462fb14a3510308da414775e2 to your computer and use it in GitHub Desktop.
Create own product tabs and fields for editable Tab content with plugin ACF
This file contains hidden or 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
/** | |
* Create own product tabs and fields for editable Tab content with plugin ACF | |
* @Link: https://gist.github.com/webonaut/85622efe2b818e2d1442 | |
*/ | |
/// CREATE TABS | |
add_filter( 'woocommerce_product_tabs', 'oxx_product_detail_tab', 97 ); | |
function oxx_product_detail_tab( $tabs ) { | |
// Adds the new tab "Details" | |
$tabs['oxx_details_tab'] = array( | |
'title' => __( 'Details', 'woocommerce' ), | |
'priority' => 30, | |
'callback' => 'oxx_product_detail_tab_content1' | |
); | |
// Adds the new tab "Dimensions and Capacity" | |
$tabs['oxx_dimensions_and_capacity_tab'] = array( | |
'title' => __( 'Dimensions and Capacity', 'woocommerce' ), | |
'priority' => 40, | |
'callback' => 'oxx_product_detail_tab_content2' | |
); | |
// Adds the new tab "Warranty" | |
$tabs['oxx_warranty_tab'] = array( | |
'title' => __( 'Warranty', 'woocommerce' ), | |
'priority' => 50, | |
'callback' => 'oxx_product_detail_tab_content3' | |
); | |
// Adds the new tab "Reviews" | |
$tabs['oxx_reviews_tab'] = array( | |
'title' => __( 'Reviews', 'woocommerce' ), | |
'priority' => 60, | |
'callback' => 'oxx_product_detail_tab_content4' | |
); | |
return $tabs; | |
} | |
// CREATE CONTENTS (with ACF-Plugin) | |
function oxx_product_detail_tab_content1() { | |
// The new tab content for tab "Details" | |
echo the_field('oxx_details_title'); | |
echo the_field('oxx_details_content'); | |
} | |
function oxx_product_detail_tab_content2() { | |
// The new tab content for tab "Dimensions and Capacity" | |
echo the_field('oxx_dimensions_and_capacity_title'); | |
echo the_field('oxx_dimensions_and_capacity_content'); | |
} | |
function oxx_product_detail_tab_content3() { | |
// The new tab content for tab "Warranty" | |
echo the_field('oxx_warranty_title'); | |
echo the_field('oxx_warranty_content'); | |
} | |
function oxx_product_detail_tab_content4() { | |
// The new tab content for tab "Reviews" | |
echo the_field('oxx_reviews_title'); | |
echo the_field('oxx_reviews_content'); | |
} | |
add_filter( 'woocommerce_product_tabs', 'remove_oxx_product_detail_tab', 98 ); | |
function remove_oxx_product_detail_tab( $tabs ) { | |
unset( $tabs['oxx_details_tab'] ); | |
unset( $tabs['oxx_dimensions_and_capacity_tab'] ); | |
unset( $tabs['oxx_warranty_tab'] ); | |
unset( $tabs['oxx_reviews_tab'] ); | |
return $tabs; | |
} | |
// Reset the newly added product details tabs | |
add_action( 'woocommerce_after_single_product_summary', 'oxx_product_detail_tab_content1', 40 ); | |
add_action( 'woocommerce_after_single_product_summary', 'oxx_product_detail_tab_content2', 40 ); | |
add_action( 'woocommerce_after_single_product_summary', 'oxx_product_detail_tab_content3', 40 ); | |
add_action( 'woocommerce_after_single_product_summary', 'oxx_product_detail_tab_content4', 40 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment