| 1 |
<?php |
| 2 |
|
| 3 |
namespace Templately\Builder\Conditions; |
| 4 |
|
| 5 |
use Templately\Builder\Conditions\Condition; |
| 6 |
|
| 7 |
class WooCommerce extends Condition { |
| 8 |
|
| 9 |
public function get_type(): string { |
| 10 |
return 'woocommerce'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_label(): string { |
| 14 |
return __( 'WooCommerce', 'templately' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_name(): string { |
| 18 |
return 'woocommerce'; |
| 19 |
} |
| 20 |
|
| 21 |
protected function register_sub_conditions() { |
| 22 |
if( ! class_exists( '\woocommerce' ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$product_archive_condition = new PostTypeArchive( [ |
| 27 |
'post_type' => 'product', |
| 28 |
] ); |
| 29 |
|
| 30 |
$single_product = new Post([ 'post_type' => 'product' ]); |
| 31 |
|
| 32 |
$this->register_sub_condition( $product_archive_condition ); |
| 33 |
$this->register_sub_condition( $single_product ); |
| 34 |
} |
| 35 |
} |