| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main FilterHooks class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Modules\Badges; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Traits\SingletonTrait; |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) || exit(); |
| 14 |
|
| 15 |
/** |
| 16 |
* Main FilterHooks class. |
| 17 |
*/ |
| 18 |
class Badges { |
| 19 |
/** |
| 20 |
* Singleton Trait. |
| 21 |
*/ |
| 22 |
use SingletonTrait; |
| 23 |
|
| 24 |
/** |
| 25 |
* @var array|mixed |
| 26 |
*/ |
| 27 |
private array $options; |
| 28 |
|
| 29 |
/** |
| 30 |
* Module Class Constructor. |
| 31 |
*/ |
| 32 |
private function __construct() { |
| 33 |
$this->options = Fns::get_options( 'modules', 'product_badges' ); |
| 34 |
$this->theme_support(); |
| 35 |
BadgesFrontEnd::instance(); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
private function theme_support() { |
| 42 |
// Astra Theme Support. |
| 43 |
if ( ! defined( 'ASTRA_EXT_VER' ) || ( defined( 'ASTRA_EXT_VER' ) && ! \Astra_Ext_Extension::is_active( 'woocommerce' ) ) ) { |
| 44 |
add_filter( 'astra_addon_shop_cards_buttons_html', [ $this, 'astra_flash_sale_html_remove' ], 50 ); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
/** |
| 50 |
* @param $html |
| 51 |
* |
| 52 |
* @return string |
| 53 |
*/ |
| 54 |
public function astra_flash_sale_html_remove( $html ) { |
| 55 |
$hide_default_badge = $this->options['hide_woocommerce_badge'] ?? false; |
| 56 |
|
| 57 |
if ( ! $hide_default_badge ) { |
| 58 |
return $html; |
| 59 |
} |
| 60 |
global $product; |
| 61 |
$hide_on_sale = ( $this->options['hide_on_sale'] ?? 'all_products' ); |
| 62 |
switch ( $hide_on_sale ) { |
| 63 |
case 'where_custom_badge_applied': |
| 64 |
if ( BadgesFns::is_allowed_badge_showing() ) { |
| 65 |
$html = ''; |
| 66 |
} |
| 67 |
break; |
| 68 |
case 'all_products': |
| 69 |
$html = ''; |
| 70 |
break; |
| 71 |
default: |
| 72 |
} |
| 73 |
return $html; |
| 74 |
} |
| 75 |
} |
| 76 |
|