| 1 |
<?php |
| 2 |
/** |
| 3 |
* WePOS. |
| 4 |
* |
| 5 |
* @package WCPOS\WooCommercePOS |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WCPOS\WooCommercePOS\Integrations; |
| 9 |
|
| 10 |
use const WCPOS\WooCommercePOS\PLUGIN_FILE; |
| 11 |
|
| 12 |
/** |
| 13 |
* WePOS Integration. |
| 14 |
* |
| 15 |
* WePOS alters the WC REST API response for variable products, it includes the full list of variations |
| 16 |
* instead of just the variation IDs. This breaks variations for WCPOS (and anyone else). |
| 17 |
*/ |
| 18 |
class WePOS { |
| 19 |
/** |
| 20 |
* Constructor. |
| 21 |
*/ |
| 22 |
public function __construct() { |
| 23 |
add_action( 'admin_init', array( $this, 'check_conflict' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Check for wePOS plugin conflict. |
| 28 |
*/ |
| 29 |
public function check_conflict(): void { |
| 30 |
// Check if wePOS is active. |
| 31 |
if ( is_plugin_active( 'wepos/wepos.php' ) ) { |
| 32 |
deactivate_plugins( PLUGIN_FILE ); |
| 33 |
add_action( 'admin_notices', array( $this, 'render_conflict_notice' ) ); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Render conflict admin notice. |
| 39 |
*/ |
| 40 |
public function render_conflict_notice(): void { |
| 41 |
echo '<div class="notice notice-error is-dismissible"> |
| 42 |
<p>' . esc_html__( 'WCPOS cannot run alongside the wePOS plugin due to compatibility issues. WCPOS has been deactivated.', 'woocommerce-pos' ) . '</p> |
| 43 |
</div>'; |
| 44 |
} |
| 45 |
} |
| 46 |
|