Created
July 14, 2017 14:35
-
-
Save xlplugins/45e91010e5ee18ddf16c5a2d76af65f6 to your computer and use it in GitHub Desktop.
Change action hook position of shop loop function and hook in Finale countdown timer or counter bar
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 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment