php WooCommerce旧单产品定位钩 - 用于销售触发(由XLplugins提供)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WooCommerce旧单产品定位钩 - 用于销售触发(由XLplugins提供)相关的知识,希望对你有一定的参考价值。
<?php
/**
* Add following snippet in active theme (child if available) functions.php
* This modifies the WooCommerce Single Product positions gven by XL WooCommerce Sales Trigger plugin.
* https://xlplugins.com/woocommerce-sales-triggers/
*/
/** unhook all existing Sales Trigger Positions */
add_action( 'wp', 'wcst_themename_helper_wp', 98 );
if ( ! function_exists( 'wcst_themename_helper_wp' ) ) {
function wcst_themename_helper_wp() {
if ( ! class_exists( 'WCST_Core' ) ) {
return;
}
$wcst_core = WCST_Core::get_instance();
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_above_title' ), 2.2 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_title' ), 9.2 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_review' ), 11 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_price' ), 17.2 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_short_desc' ), 21.2 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_add_cart' ), 39.2 );
remove_action( 'woocommerce_single_product_summary', array( $wcst_core, 'wcst_position_below_meta' ), 41.2 );
remove_action( 'woocommerce_after_single_product_summary', array( $wcst_core, 'wcst_position_above_tab_area' ), 9.8 );
remove_action( 'woocommerce_after_single_product_summary', array( $wcst_core, 'wcst_position_below_related_products' ), 21.2 );
}
}
/** Hooking 'above title & tabs' position */
add_action( 'woocommerce_before_template_part', 'wcst_themename_helper_before_template_part', 98 );
if ( ! function_exists( 'wcst_themename_helper_before_template_part' ) ) {
function wcst_themename_helper_before_template_part( $template_name = '', $template_path = '', $located = '', $args = array() ) {
if ( ! class_exists( 'WCST_Core' ) ) {
return;
}
$wcst_core = WCST_Core::get_instance();
if ( empty( $template_name ) ) {
return '';
}
if ( $template_name == 'single-product/title.php' ) {
echo $wcst_core->wcst_position_above_title();
} elseif ( $template_name == 'single-product/tabs/tabs.php' ) {
echo $wcst_core->wcst_position_above_tab_area();
}
}
}
/** Hooking 'below title, price, review, short description, meta & related products' position */
add_action( 'woocommerce_after_template_part', 'wcst_themename_helper_after_template_part', 98 );
if ( ! function_exists( 'wcst_themename_helper_after_template_part' ) ) {
function wcst_themename_helper_after_template_part( $template_name = '', $template_path = '', $located = '', $args = array() ) {
if ( ! class_exists( 'WCST_Core' ) ) {
return;
}
$wcst_core = WCST_Core::get_instance();
if ( empty( $template_name ) ) {
return '';
}
if ( $template_name == 'single-product/title.php' ) {
echo $wcst_core->wcst_position_below_title();
} elseif ( $template_name == 'single-product/short-description.php' ) {
echo $wcst_core->wcst_position_below_short_desc();
} elseif ( $template_name == 'single-product/rating.php' ) {
echo $wcst_core->wcst_position_below_review();
} elseif ( $template_name == 'single-product/price.php' ) {
echo $wcst_core->wcst_position_below_price();
} elseif ( $template_name == 'single-product/meta.php' ) {
echo $wcst_core->wcst_position_below_meta();
} elseif ( $template_name == 'single-product/related.php' ) {
echo $wcst_core->wcst_position_below_related_products();
}
}
}
/** Hooking 'below add to cart' position */
add_action( 'woocommerce_after_add_to_cart_form', 'wcst_themename_after_add_to_cart_template', 98 );
if ( ! function_exists( 'wcst_themename_after_add_to_cart_template' ) ) {
function wcst_themename_after_add_to_cart_template() {
if ( ! class_exists( 'WCST_Core' ) ) {
return;
}
$wcst_core = WCST_Core::get_instance();
$output = "";
ob_start();
echo $wcst_core->wcst_position_below_add_cart();
$output = ob_get_clean();
if ( $output !== "" ) {
echo '<div class="wcst_clear" style="height: 15px;"></div>';
}
echo $output;
}
}
以上是关于php WooCommerce旧单产品定位钩 - 用于销售触发(由XLplugins提供)的主要内容,如果未能解决你的问题,请参考以下文章
在 Shop 中的 Woocommerce 产品循环中放置自定义徽章的最佳方式是啥
避免访问基于 WooCommerce 地理定位国家/地区的特定产品