← All changes
|
includes/helpers/Woo_Builder/Abstract_Checkout_Widget.php
+34
-0
51.1.78
→
51.1.86
View file →
| @@ -26,8 +26,12 @@ | ||
| 26 | 26 | * @return bool |
| 27 | 27 | */ |
| 28 | 28 | protected function should_render(): bool |
| 29 | 29 | { |
| 30 | + if (!$this->can_use_builder_widgets()) { | |
| 31 | + return false; | |
| 32 | + } | |
| 33 | + | |
| 30 | 34 | // In editor mode editing checkout template |
| 31 | 35 | if (class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editing_template_type('checkout')) { |
| 32 | 36 | return true; |
| 33 | 37 | } |
| @@ -40,8 +44,18 @@ | ||
| 40 | 44 | return false; |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | /** |
| 48 | + * Cart / checkout / account builder widgets are a Pro feature. | |
| 49 | + * | |
| 50 | + * @return bool | |
| 51 | + */ | |
| 52 | + protected function can_use_builder_widgets(): bool | |
| 53 | + { | |
| 54 | + return function_exists('king_addons_can_use_pro') && king_addons_can_use_pro(); | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 44 | 58 | * Render placeholder when checkout context is missing. |
| 45 | 59 | * |
| 46 | 60 | * @return void |
| 47 | 61 | */ |
| @@ -50,8 +64,13 @@ | ||
| 50 | 64 | if (!class_exists('\Elementor\Plugin') || !\Elementor\Plugin::$instance->editor->is_edit_mode()) { |
| 51 | 65 | return; |
| 52 | 66 | } |
| 53 | 67 | |
| 68 | + if (!$this->can_use_builder_widgets()) { | |
| 69 | + $this->render_pro_required_notice(); | |
| 70 | + return; | |
| 71 | + } | |
| 72 | + | |
| 54 | 73 | // Check if we're editing a Checkout template |
| 55 | 74 | if (class_exists('King_Addons\\Woo_Builder\\Context') && Woo_Context::is_editing_template_type('checkout')) { |
| 56 | 75 | // Don't show notice - we're in the right template type |
| 57 | 76 | return; |
| @@ -57,8 +76,23 @@ | ||
| 57 | 76 | return; |
| 58 | 77 | } |
| 59 | 78 | |
| 60 | 79 | echo '<div class="king-addons-woo-builder-notice">' . esc_html__('This widget works only on the WooCommerce checkout page.', 'king-addons') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Editor-only upsell when the site cannot use Pro. | |
| 84 | + * | |
| 85 | + * @return void | |
| 86 | + */ | |
| 87 | + protected function render_pro_required_notice(): void | |
| 88 | + { | |
| 89 | + if (class_exists('King_Addons\\Core')) { | |
| 90 | + Core::renderEditorHint(esc_html__('Available in King Addons Pro.', 'king-addons')); | |
| 91 | + return; | |
| 92 | + } | |
| 93 | + | |
| 94 | + echo '<div class="king-addons-woo-builder-notice">' . esc_html__('Available in King Addons Pro.', 'king-addons') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 61 | 95 | } |
| 62 | 96 | } |
| 63 | 97 | |
| 64 | 98 | |