| 1 |
<?php |
| 2 |
/** |
| 3 |
* WooCommerce Extension |
| 4 |
* |
| 5 |
* @package NotificationX\Extensions |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace NotificationX\Extensions\WooCommerce; |
| 9 |
|
| 10 |
use NotificationX\Core\Modules; |
| 11 |
|
| 12 |
/** |
| 13 |
* WooCommerce Extension Class |
| 14 |
* @method static WooCommerce get_instance($args = null) |
| 15 |
*/ |
| 16 |
class WooCommerceSalesInline extends WooInline { |
| 17 |
|
| 18 |
/** |
| 19 |
* Instance of WooInline |
| 20 |
* |
| 21 |
* @var WooInline |
| 22 |
*/ |
| 23 |
protected static $instance = null; |
| 24 |
public $priority = 15; |
| 25 |
public $id = 'woocommerce_sales_inline'; |
| 26 |
public $img = ''; |
| 27 |
public $doc_link = 'https://notificationx.com/docs/woocommerce-growth-alerts/'; |
| 28 |
public $types = 'woocommerce_sales'; |
| 29 |
public $module = 'modules_woocommerce'; |
| 30 |
public $module_priority = 3; |
| 31 |
public $class = '\WooCommerce'; |
| 32 |
public $is_pro = true; |
| 33 |
|
| 34 |
/** |
| 35 |
* Get the instance of called class. |
| 36 |
* |
| 37 |
* @return WooInline |
| 38 |
*/ |
| 39 |
public static function get_instance($args = null){ |
| 40 |
if ( is_null( static::$instance ) || ! static::$instance instanceof self ) { |
| 41 |
$class = __CLASS__; |
| 42 |
if(strpos($class, "NotificationX\\") === 0){ |
| 43 |
$pro_class = str_replace("NotificationX\\", "NotificationXPro\\", $class); |
| 44 |
if(class_exists($pro_class)){ |
| 45 |
$class = $pro_class; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
if(!empty($args)){ |
| 50 |
static::$instance = new $class($args); |
| 51 |
} |
| 52 |
else{ |
| 53 |
static::$instance = new $class; |
| 54 |
} |
| 55 |
} |
| 56 |
return static::$instance; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Initially Invoked when initialized. |
| 61 |
*/ |
| 62 |
public function __construct(){ |
| 63 |
parent::__construct(); |
| 64 |
} |
| 65 |
|
| 66 |
public function init_extension() |
| 67 |
{ |
| 68 |
$this->title = __('Growth Alert', 'notificationx'); |
| 69 |
$this->module_title = __('Growth Alert', 'notificationx'); |
| 70 |
$this->themes = [ |
| 71 |
'conv-theme-seven' => array( |
| 72 |
'is_pro' => true, |
| 73 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/woo-inline.jpg', |
| 74 |
'image_shape' => 'rounded', |
| 75 |
'inline_location' => [ 'woocommerce_before_add_to_cart_form' ], |
| 76 |
'template' => [ |
| 77 |
'first_param' => 'tag_sales_count', |
| 78 |
'custom_first_param' => __( '99', 'notificationx' ), |
| 79 |
'second_param' => __( 'people purchased', 'notificationx' ), |
| 80 |
'third_param' => 'tag_product_title', |
| 81 |
'custom_third_param' => ' ', |
| 82 |
'fourth_param' => 'tag_7days', |
| 83 |
'custom_fourth_param' => __( 'in last {{day:7}}', 'notificationx' ), |
| 84 |
], |
| 85 |
), |
| 86 |
'stock-theme-one' => array( |
| 87 |
'is_pro' => true, |
| 88 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/woo-inline-2.jpg', |
| 89 |
'image_shape' => 'rounded', |
| 90 |
'inline_location' => [ 'woocommerce_before_add_to_cart_form' ], |
| 91 |
'template' => [ |
| 92 |
// 'first_param' => 'tag_sales_count', |
| 93 |
// 'custom_first_param' => __( 'Someone', 'notificationx' ), |
| 94 |
'second_param' => __( 'Only', 'notificationx' ), |
| 95 |
'third_param' => 'tag_stock_count', |
| 96 |
'custom_third_param' => 10, |
| 97 |
'fourth_param' => 'tag_left_in_stock', |
| 98 |
'custom_fourth_param' => __( 'left in stock', 'notificationx' ), |
| 99 |
'fifth_param' => 'tag_order_soon', |
| 100 |
'custom_fifth_param' => __( '- order soon.', 'notificationx' ), |
| 101 |
], |
| 102 |
), |
| 103 |
'stock-theme-two' => array( |
| 104 |
'is_pro' => true, |
| 105 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/woo-inline-3.jpg', |
| 106 |
'image_shape' => 'rounded', |
| 107 |
'inline_location' => [ 'woocommerce_after_cart_item_name' ], |
| 108 |
'template' => [ |
| 109 |
// 'first_param' => 'tag_sales_count', |
| 110 |
// 'custom_first_param' => __( 'Someone', 'notificationx' ), |
| 111 |
'second_param' => __( 'In high demand - only', 'notificationx' ), |
| 112 |
'third_param' => 'tag_stock_count', |
| 113 |
'custom_third_param' => 10, |
| 114 |
'fourth_param' => 'tag_left', |
| 115 |
'custom_fourth_param' => __( 'left', 'notificationx' ), |
| 116 |
'fifth_param' => 'tag_on_our_site', |
| 117 |
'custom_fifth_param' => __( 'on our site!', 'notificationx' ), |
| 118 |
], |
| 119 |
), |
| 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 |
|
| 148 |
$this->templates = [ |
| 149 |
'woo_template_sales_count' => [ |
| 150 |
'first_param' => [ |
| 151 |
'tag_sales_count' => __( 'Sales Count', 'notificationx' ), |
| 152 |
], |
| 153 |
'third_param' => [ |
| 154 |
'tag_product_title' => __( 'Product Title', 'notificationx' ), |
| 155 |
], |
| 156 |
'fourth_param' => [ |
| 157 |
'tag_1day' => __( 'In last 1 day', 'notificationx' ), |
| 158 |
'tag_7days' => __( 'In last 7 days', 'notificationx' ), |
| 159 |
'tag_30days' => __( 'In last 30 days', 'notificationx' ), |
| 160 |
], |
| 161 |
'_themes' => [ |
| 162 |
"{$this->id}_conv-theme-seven", |
| 163 |
], |
| 164 |
], |
| 165 |
'inline_stock_template' => [ |
| 166 |
'third_param' => [ |
| 167 |
'tag_stock_count' => __( 'Stock Count', 'notificationx' ), |
| 168 |
], |
| 169 |
'fourth_param' => [ |
| 170 |
'tag_left_in_stock' => __( 'left in stock', 'notificationx' ), |
| 171 |
'tag_left' => __( 'left', 'notificationx' ), |
| 172 |
], |
| 173 |
'fifth_param' => [ |
| 174 |
'tag_order_soon' => __( 'order soon.', 'notificationx' ), |
| 175 |
'tag_on_our_site' => __( 'on our site!', 'notificationx' ), |
| 176 |
], |
| 177 |
'_themes' => [ |
| 178 |
"{$this->id}_stock-theme-one", |
| 179 |
"{$this->id}_stock-theme-two", |
| 180 |
], |
| 181 |
], |
| 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 |
|
| 201 |
$this->popup = [ |
| 202 |
"denyButtonText" => __("<a href='https://notificationx.com/growth-alert/' target='_blank'>More Info</a>", "notificationx"), |
| 203 |
"confirmButtonText" => __("<a href='https://notificationx.com/#pricing' target='_blank'>Upgrade to PRO</a>", "notificationx"), |
| 204 |
"html"=> __(' |
| 205 |
<span>Highlight your sales, low stock updates with inline growth alert to boost sales</span> |
| 206 |
<iframe id="email_subscription_video" type="text/html" allowfullscreen width="450" height="235" |
| 207 |
src="https://www.youtube.com/embed/vXMtBPvizDw"> |
| 208 |
</iframe> |
| 209 |
', 'notificationx') |
| 210 |
]; |
| 211 |
} |
| 212 |
|
| 213 |
public function doc(){ |
| 214 |
/* translators: %1$s: WooCommerce installed & activated link URL, %2$s: documentation link URL, %3$s: Watch video tutorial link URL, %4$s: Best FOMO and Social Proof Plugin link URL, %5$s: boost WooCommerce Sales link URL */ |
| 215 |
return sprintf(__('<p>Make sure that you have <a target="_blank" href="%1$s">WooCommerce installed & activated</a> to use this campaign. For further assistance, check out our step by step <a target="_blank" href="%2$s">documentation</a>.</p> |
| 216 |
<p>🎦 <a href="%3$s" target="_blank">Watch video tutorial</a> to learn quickly</p> |
| 217 |
<p>⭐ NotificationX Integration with WooCommerce</p> |
| 218 |
<p><strong>Recommended Blog:</strong></p> |
| 219 |
<p>🔥 Why NotificationX is The <a target="_blank" href="%4$s">Best FOMO and Social Proof Plugin</a> for WooCommerce?</p> |
| 220 |
<p>🚀 How to <a target="_blank" href="%5$s">boost WooCommerce Sales</a> Using NotificationX</p>', 'notificationx'), |
| 221 |
'https://wordpress.org/plugins/woocommerce/', |
| 222 |
'https://notificationx.com/docs/woocommerce-growth-alerts/', |
| 223 |
'https://www.youtube.com/watch?v=dVthd36hJ-E&t=1s', |
| 224 |
'https://notificationx.com/integrations/woocommerce/', |
| 225 |
'https://notificationx.com/blog/best-fomo-and-social-proof-plugin-for-woocommerce/' |
| 226 |
); |
| 227 |
} |
| 228 |
|
| 229 |
} |
| 230 |
|