xlplugins
10/24/2017 - 1:35 PM

WooCommerce Old Single Product Positions Hook - For Finale (by XLplugins)

WooCommerce Old Single Product Positions Hook - For Finale (by XLplugins)

<?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;
	}
}