php 改变商店循环功能的动作钩位置并在Finale倒数计时器或计数器栏中挂钩
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 改变商店循环功能的动作钩位置并在Finale倒数计时器或计数器栏中挂钩相关的知识,希望对你有一定的参考价值。
<?php
/**
* Add This whole code in working theme functions.php inside php tag to alter woocommerce shop loop native position
* Theme: X Store https://themeforest.net/item/xstore-responsive-woocommerce-theme/15780546
* Plugin: Finale - WooCommerce Sales Countdown Timer & Discount Plugin
*/
add_action('wp', 'wcct_xstore_modify_positions', 99);
if (!function_exists('wcct_xstore_modify_positions')) {
function wcct_xstore_modify_positions() {
if (function_exists('WCCT_Core')) {
$wcct_appearance_instance = WCCT_Core()->appearance;
// removing after shop loop hook
remove_action('woocommerce_after_shop_loop_item', array($wcct_appearance_instance, 'wcct_bar_timer_show_on_grid'), 9);
// hooking after shop loop function
add_action('woocommerce_after_shop_loop_item_title', array($wcct_appearance_instance, 'wcct_bar_timer_show_on_grid'), 20);
}
}
}
/**
* Call Counter Bar in product loop below product name using shortcode.
* This inherit product's bar settings and follow campaign rules.
*/
add_action('woocommerce_after_shop_loop_item_title', 'wcct_xstore_shop_loop_bar_display', 22);
if (!function_exists('wcct_xstore_shop_loop_bar_display')) {
function wcct_xstore_shop_loop_bar_display() {
echo do_shortcode('[finale_counter_bar skip_rules="no"]');
}
}
/**
* Call Counter Bar in product loop below product name using direct function.
* Here you can change params as per your need. i.e. modify styling/ text etc.
*/
add_filter("wcct_add_bar_to_grid", "wcct_xstore_add_bar_to_grid");
if (!function_exists('wcct_xstore_add_bar_to_grid')) {
function wcct_xstore_add_bar_to_grid($grid_bar){
$grid_bar = array(
'skin' => 'stripe_animate',
'edge' => 'smooth',
'orientation' => 'rtl',
'height' => '12',
'bg_color' => '#dddddd',
'active_color' => '#ee303c',
'display' => "Plus que <span>{{remaining_units}}</span> disponibles\n{{counter_bar}}",
'border_width' => '0',
'border_color' => '#444444',
'border_style' => 'solid',
'delay' => 'off',
'delay_items' => '1',
);
return $grid_bar;
}
/**
* Call Countdown Timer in product loop below product name using shortcode.
* This inherit product's timer settings and follow campaign rules.
*/
add_action('woocommerce_after_shop_loop_item_title', 'wcct_xstore_shop_loop_timer_display', 24);
if (!function_exists('wcct_xstore_shop_loop_timer_display')) {
function wcct_xstore_shop_loop_timer_display() {
echo do_shortcode('[finale_countdown_timer skip_rules="no"]');
}
}
/**
* Call Countdown Timer in product loop below product name using direct function.
* Here you can change params as per your need. i.e. modify styling/ text etc.
*/
add_filter("wcct_add_timer_to_grid", "wcct_xstore_add_timer_to_grid");
if (!function_exists('wcct_xstore_add_timer_to_grid')) {
function wcct_xstore_add_timer_to_grid($grid_timer){
$grid_timer = array(
'skin' => 'round_fill',
'bg_color' => '#666667',
'label_color' => '#ffffff',
'timer_font' => '15',
'label_font' => '12',
'display' => "{{countdown_timer}}",
'label_days' => 'jours',
'label_hrs' => 'hrs',
'label_mins' => 'mins',
'label_secs' => 'secs',
'border_width' => '0',
'border_color' => '#444444',
'border_style' => 'solid',
);
return $grid_timer;
}
}
以上是关于php 改变商店循环功能的动作钩位置并在Finale倒数计时器或计数器栏中挂钩的主要内容,如果未能解决你的问题,请参考以下文章