Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xlplugins/c74f35e48eee0d0ca0223911f4c84a9c to your computer and use it in GitHub Desktop.
Save xlplugins/c74f35e48eee0d0ca0223911f4c84a9c to your computer and use it in GitHub Desktop.
Modify Best Seller Badge Content.
/**
* Modify best seller badge HTML contact to reorder Elements
*/
add_filter('wcst_best_seller_badge_display_content', 'wcst_best_seller_badge_display_content_modify', 10, 6);
/**
* @hooked into `wcst_best_seller_badge_display_content`
* Reorder HTML elements for Xl sales triggers's best seller badge
* @param string $wcst_best_sellers_badge Existing HTML
* @param WP_Term $wcst_pro_cats_raw Choosen Term
* @param string $template_output Generated html
* @param XL_WCST_Product $productInfo Product
* @param integer $trigger_ID Trigger ID
* @param array $best_seller_badge_settings Configurations
* @return string
*/
function wcst_best_seller_badge_display_content_modify($wcst_best_sellers_badge, $wcst_pro_cats_raw, $template_output, $productInfo, $trigger_ID, $best_seller_badge_settings)
{
$hard_text_array = WCST_Common::get_hard_text();
$display_cat_name = $display_cat_name = apply_filters('wcst_best_seller_badge_display_cat_name', 1);
$best_seller_cat_prefix = '';
$best_seller_cat_suffix = '';
if ($best_seller_badge_settings['hyperlink_category'] == 'yes') {
$best_seller_cat_prefix = '<a href="' . get_term_link($wcst_pro_cats_raw->term_id, 'product_cat') . '">';
$best_seller_cat_suffix = '</a>';
}
ob_start();
?>
<div
class="wcst_best_sellers_badge wcst_best_sellers_badge_key_<?php echo $productInfo->product->get_id() ?>_<?php echo $trigger_ID ?> wcst_best_sellers_badge_<?php echo $best_seller_badge_settings['badge_style'] ?>">
<?php
if ($display_cat_name) {
echo ' ' . $best_seller_cat_prefix . $wcst_pro_cats_raw->name . $best_seller_cat_suffix;
echo ' ' . $hard_text_array['in'];
}
?>
<span class="wcst_best_sellers_badge_span_one"> <span><?php echo $template_output; ?></span></span>
</div>
<?php
$wcst_best_sellers_badge = ob_get_clean();
return $wcst_best_sellers_badge;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment