Last active
March 31, 2018 06:36
-
-
Save xlplugins/e37f4bbbcf629166a82900580dd24fdc to your computer and use it in GitHub Desktop.
WooCommerce Old Single Product Positions Hook - For Finale (by XLplugins)
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 | |
/** | |
* Add following snippet in active theme (child if available) functions.php | |
* This modifies the WooCommerce Single Product positions gven by Finale WooCommerce Countdown Timer plugin. | |
* https://xlplugins.com/finale-woocommerce-sales-countdown-timer-discount-plugin/ | |
*/ | |
/** unhook all existing Finale Positions */ | |
add_action( 'wp', 'wcct_themename_helper_wp', 99 ); | |
if ( ! function_exists( 'wcct_themename_helper_wp' ) ) { | |
function wcct_themename_helper_wp() { | |
if ( ! function_exists( 'WCCT_Core' ) ) { | |
return; | |
} | |
$wcct_core = WCCT_Core()->appearance; | |
// removing wcct action hooks on theme | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_above_title' ), 2.3 ); | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_below_title' ), 9.3 ); | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_below_review' ), 11.3 ); | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_below_price' ), 17.3 ); | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_below_short_desc' ), 21.3 ); | |
remove_action( 'woocommerce_single_product_summary', array( $wcct_core, 'wcct_position_below_add_cart' ), 39.3 ); | |
} | |
} | |
/** Hooking 'above title' position */ | |
add_action( 'woocommerce_before_template_part', 'wcct_themename_helper_before_template_part', 99 ); | |
if ( ! function_exists( 'wcct_themename_helper_before_template_part' ) ) { | |
function wcct_themename_helper_before_template_part( $template_name = '', $template_path = '', $located = '', $args = array() ) { | |
if ( ! function_exists( 'WCCT_Core' ) ) { | |
return; | |
} | |
$wcct_appearance = WCCT_Core()->appearance; | |
if ( empty( $template_name ) ) { | |
return ''; | |
} | |
if ( $template_name == 'single-product/title.php' ) { | |
echo $wcct_appearance->wcct_position_above_title(); | |
} | |
} | |
} | |
/** Hooking 'below title, price, review & short description' position */ | |
add_action( 'woocommerce_after_template_part', 'wcct_themename_helper_after_template_part', 99 ); | |
if ( ! function_exists( 'wcct_themename_helper_after_template_part' ) ) { | |
function wcct_themename_helper_after_template_part( $template_name = '', $template_path = '', $located = '', $args = array() ) { | |
if ( ! function_exists( 'WCCT_Core' ) ) { | |
return; | |
} | |
$wcct_appearance = WCCT_Core()->appearance; | |
if ( empty( $template_name ) ) { | |
return ''; | |
} | |
if ( $template_name == 'single-product/title.php' ) { | |
echo $wcct_appearance->wcct_position_below_title(); | |
} elseif ( $template_name == 'single-product/short-description.php' ) { | |
echo $wcct_appearance->wcct_position_below_short_desc(); | |
} elseif ( $template_name == 'single-product/rating.php' ) { | |
echo $wcct_appearance->wcct_position_below_review(); | |
} elseif ( $template_name == 'single-product/price.php' ) { | |
echo $wcct_appearance->wcct_position_below_price(); | |
} | |
} | |
} | |
/** Hooking 'below add to cart' position */ | |
add_action( 'woocommerce_after_add_to_cart_form', 'wcct_themename_after_add_to_cart_template', 99 ); | |
if ( ! function_exists( 'wcct_themename_after_add_to_cart_template' ) ) { | |
function wcct_themename_after_add_to_cart_template() { | |
if ( ! function_exists( 'WCCT_Core' ) ) { | |
return; | |
} | |
$wcct_appearance = WCCT_Core()->appearance; | |
$output = ""; | |
ob_start(); | |
echo $wcct_appearance->wcct_position_below_add_cart(); | |
$output = ob_get_clean(); | |
if ( $output !== "" ) { | |
echo '<div class="wcct_clear" style="height: 15px;"></div>'; | |
} | |
echo $output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment