ProductCondition.php
69 lines
| 1 | <?php |
| 2 | namespace SureCart\Integrations\Elementor\Conditions; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; // Exit if accessed directly. |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Elementor SureCart Product Condition |
| 10 | */ |
| 11 | class ProductCondition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base { |
| 12 | |
| 13 | /** |
| 14 | * Get the type of the condition. |
| 15 | * |
| 16 | * @return string |
| 17 | */ |
| 18 | public static function get_type() { |
| 19 | return 'surecart-product'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Get the name. |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | public function get_name() { |
| 28 | return 'surecart-product'; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the label. |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | public function get_label() { |
| 37 | return esc_html__( 'Product', 'elementor-pro' ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Get the all label. |
| 42 | * |
| 43 | * @return string |
| 44 | */ |
| 45 | public function get_all_label() { |
| 46 | return esc_html__( 'All Products', 'elementor-pro' ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Register sub conditions. |
| 51 | * |
| 52 | * @return void |
| 53 | */ |
| 54 | public function register_sub_conditions() { |
| 55 | $this->register_sub_condition( new ProductSingle() ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Check condition. |
| 60 | * |
| 61 | * @param array $args The arguments. |
| 62 | * |
| 63 | * @return bool |
| 64 | */ |
| 65 | public function check( $args ) { |
| 66 | return get_query_var( 'surecart_current_product' ); |
| 67 | } |
| 68 | } |
| 69 |