← All changes
|
includes/Extensions/WooCommerce/WooCommerceSalesInline.php
+47
-0
3.2.13
→
3.3.3
View file →
| @@ -6,8 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace NotificationX\Extensions\WooCommerce; |
| 9 | 9 | |
| 10 | +use NotificationX\Core\Modules; | |
| 11 | + | |
| 10 | 12 | /** |
| 11 | 13 | * WooCommerce Extension Class |
| 12 | 14 | * @method static WooCommerce get_instance($args = null) |
| 13 | 15 | */ |
| @@ -115,8 +117,35 @@ | ||
| 115 | 117 | 'custom_fifth_param' => __( 'on our site!', 'notificationx' ), |
| 116 | 118 | ], |
| 117 | 119 | ), |
| 118 | 120 | ]; |
| 121 | + // Google Analytics live-viewer design. Only offered when the Google | |
| 122 | + // Analytics module is switched on — the number comes from a connected | |
| 123 | + // GA4 property, so without it the design could never render anything. | |
| 124 | + if ( Modules::get_instance()->is_enabled( 'modules_google_analytics' ) ) { | |
| 125 | + $this->themes['live-viewers'] = array( | |
| 126 | + 'is_pro' => true, | |
| 127 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/ga-live-viewers.jpg', | |
| 128 | + 'image_shape' => 'rounded', | |
| 129 | + 'inline_location' => [ 'woocommerce_before_add_to_cart_form' ], | |
| 130 | + 'template' => [ | |
| 131 | + 'first_param' => 'tag_live_viewers', | |
| 132 | + 'second_param' => __( 'people are viewing', 'notificationx' ), | |
| 133 | + 'third_param' => 'tag_product_title', | |
| 134 | + 'custom_third_param' => ' ', | |
| 135 | + // A real tag rather than `tag_custom`: `custom_fourth_param` | |
| 136 | + // is one text field shared by every design, so seeding it is | |
| 137 | + // not reliable — switching in from the sales-count design can | |
| 138 | + // leave its "in last {{day:7}}" text behind. The tag renders | |
| 139 | + // from `fallback_data()` and cannot go stale; merchants who | |
| 140 | + // want their own wording pick "Custom" in the select, which | |
| 141 | + // seeds from `custom_fourth_param` below. | |
| 142 | + 'fourth_param' => 'tag_right_now', | |
| 143 | + 'custom_fourth_param' => __( 'right now', 'notificationx' ), | |
| 144 | + ], | |
| 145 | + ); | |
| 146 | + } | |
| 147 | + | |
| 119 | 148 | $this->templates = [ |
| 120 | 149 | 'woo_template_sales_count' => [ |
| 121 | 150 | 'first_param' => [ |
| 122 | 151 | 'tag_sales_count' => __( 'Sales Count', 'notificationx' ), |
| @@ -150,8 +179,26 @@ | ||
| 150 | 179 | "{$this->id}_stock-theme-two", |
| 151 | 180 | ], |
| 152 | 181 | ], |
| 153 | 182 | ]; |
| 183 | + | |
| 184 | + if ( Modules::get_instance()->is_enabled( 'modules_google_analytics' ) ) { | |
| 185 | + $this->templates['woo_live_viewers_template'] = [ | |
| 186 | + 'first_param' => [ | |
| 187 | + 'tag_live_viewers' => __( 'Live Product Viewers', 'notificationx' ), | |
| 188 | + ], | |
| 189 | + 'third_param' => [ | |
| 190 | + 'tag_product_title' => __( 'Product Title', 'notificationx' ), | |
| 191 | + ], | |
| 192 | + 'fourth_param' => [ | |
| 193 | + 'tag_right_now' => __( 'right now', 'notificationx' ), | |
| 194 | + ], | |
| 195 | + '_themes' => [ | |
| 196 | + "{$this->id}_live-viewers", | |
| 197 | + ], | |
| 198 | + ]; | |
| 199 | + } | |
| 200 | + | |
| 154 | 201 | $this->popup = [ |
| 155 | 202 | "denyButtonText" => __("<a href='https://notificationx.com/growth-alert/' target='_blank'>More Info</a>", "notificationx"), |
| 156 | 203 | "confirmButtonText" => __("<a href='https://notificationx.com/#pricing' target='_blank'>Upgrade to PRO</a>", "notificationx"), |
| 157 | 204 | "html"=> __(' |