| 1 |
<?php |
| 2 |
/** |
| 3 |
* WooCommerce Cart Peek Extension (Free stub). |
| 4 |
* |
| 5 |
* The Free plugin registers the Cart Peek source so the Add New modal can |
| 6 |
* render it as a locked / Pro-badged card. All behaviour lives in the Pro |
| 7 |
* override at `NotificationXPro\Extensions\WooCommerce\WooCommerceCartPeek`; |
| 8 |
* see WooCommerceSales.php for the same namespace-swap pattern. |
| 9 |
* |
| 10 |
* @package NotificationX\Extensions |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace NotificationX\Extensions\WooCommerce; |
| 14 |
|
| 15 |
/** |
| 16 |
* WooCommerce Cart Peek Extension Class |
| 17 |
* @method static WooCommerceCartPeek get_instance($args = null) |
| 18 |
*/ |
| 19 |
class WooCommerceCartPeek extends WooCommerce { |
| 20 |
/** |
| 21 |
* Instance of WooCommerceCartPeek |
| 22 |
* |
| 23 |
* @var WooCommerceCartPeek |
| 24 |
*/ |
| 25 |
protected static $instance = null; |
| 26 |
public $priority = 6; |
| 27 |
public $id = 'woocommerce_cart_peek'; |
| 28 |
public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/woocommerce.png'; |
| 29 |
public $doc_link = 'https://notificationx.com/docs/how-to-create-a-cart-peek-notification/'; |
| 30 |
public $types = 'woocommerce_cart_peek'; |
| 31 |
public $module = 'modules_woocommerce'; |
| 32 |
public $module_priority = 3; |
| 33 |
public $class = '\WooCommerce'; |
| 34 |
public $default_theme = 'woocommerce_cart_peek_conv-theme-fourteen'; |
| 35 |
public $is_pro = true; |
| 36 |
|
| 37 |
/** |
| 38 |
* Get the instance of called class. |
| 39 |
* |
| 40 |
* @return WooCommerceCartPeek |
| 41 |
*/ |
| 42 |
public static function get_instance($args = null) { |
| 43 |
if ( is_null( static::$instance ) || ! static::$instance instanceof self ) { |
| 44 |
$class = __CLASS__; |
| 45 |
if ( strpos( $class, 'NotificationX\\' ) === 0 ) { |
| 46 |
$pro_class = str_replace( 'NotificationX\\', 'NotificationXPro\\', $class ); |
| 47 |
if ( class_exists( $pro_class ) ) { |
| 48 |
$class = $pro_class; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
if ( ! empty( $args ) ) { |
| 53 |
static::$instance = new $class( $args ); |
| 54 |
} else { |
| 55 |
static::$instance = new $class; |
| 56 |
} |
| 57 |
} |
| 58 |
return static::$instance; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Initially Invoked when initialized. |
| 63 |
*/ |
| 64 |
public function __construct() { |
| 65 |
parent::__construct(); |
| 66 |
} |
| 67 |
|
| 68 |
public function init_extension() { |
| 69 |
// The source is the WooCommerce store (shown with the WooCommerce icon in |
| 70 |
// the Source tab); the "Cart Peek" identity lives on the notification type. |
| 71 |
$this->title = __( 'WooCommerce', 'notificationx' ); |
| 72 |
$this->module_title = __( 'Cart Peek', 'notificationx' ); |
| 73 |
} |
| 74 |
|
| 75 |
public function doc() { |
| 76 |
/* translators: %1$s: WooCommerce install link, %2$s: Cart Peek documentation link */ |
| 77 |
return sprintf( |
| 78 |
__( '<p>Show shoppers how many others have this product in their cart right now — a live social-proof signal that fires at the highest-value hesitation moment on the PDP.</p> |
| 79 |
<p>Requires an active NotificationX Pro licence and <a target="_blank" href="%1$s">WooCommerce installed & activated</a>.</p> |
| 80 |
<p>📚 <a target="_blank" href="%2$s">Documentation</a></p>', 'notificationx' ), |
| 81 |
'https://wordpress.org/plugins/woocommerce/', |
| 82 |
'https://notificationx.com/docs/how-to-create-a-cart-peek-notification/' |
| 83 |
); |
| 84 |
} |
| 85 |
} |
| 86 |
|