diff --git a/includes/admin/class-wc-payment-discounts-admin.php b/includes/admin/class-wc-payment-discounts-admin.php
index 29ea31a..11c68b9 100644
--- a/includes/admin/class-wc-payment-discounts-admin.php
+++ b/includes/admin/class-wc-payment-discounts-admin.php
@@ -18,11 +18,6 @@ public function __construct() {
// Register plugin settings.
add_action( 'admin_init', array( $this, 'register_settings' ) );
- // Need update message.
- if ( defined( 'WOOCOMMERCE_VERSION' ) && ! version_compare( WOOCOMMERCE_VERSION, '2.0', '>=' ) ) {
- add_action( 'admin_notices', array( $this, 'woocommerce_need_update' ) );
- }
-
$this->maybe_update();
}
@@ -93,22 +88,11 @@ public function validate_settings( $options ) {
* @return string Settings page content.
*/
public function display_plugin_admin_page() {
- global $woocommerce;
-
$settings = get_option( 'woocommerce_payment_discounts' );
- $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
+ $payment_gateways = WC()->payment_gateways->payment_gateways();
include_once 'views/html-admin-settings.php';
}
-
- /**
- * WooCommerce need update.
- *
- * @return string Admin notice.
- */
- public function woocommerce_need_update() {
- echo '
' . __( 'WooCommerce Discounts Per Payment Method works only with WooCommerce 2.0 or higher, please, upgrade you WooCommerce!', 'woocommerce-payment-discounts' ) . '
';
- }
}
new WC_Payment_Discounts_Admin();
diff --git a/includes/class-wc-payment-discounts-add-discount.php b/includes/class-wc-payment-discounts-add-discount.php
index edcd767..3a95f2b 100644
--- a/includes/class-wc-payment-discounts-add-discount.php
+++ b/includes/class-wc-payment-discounts-add-discount.php
@@ -87,7 +87,7 @@ public function payment_method_title( $title, $id ) {
if ( strstr( $discount, '%' ) ) {
$value = $discount;
} else {
- $value = woocommerce_price( $discount );
+ $value = wc_price( $discount );
}
$title .= ' (' . sprintf( __( '%s off', 'woocommerce-payment-discounts' ), $value ) . ')';
@@ -106,20 +106,18 @@ public function add_discount( $cart ) {
return;
}
- global $woocommerce;
-
// Gets the settings.
$gateways = get_option( 'woocommerce_payment_discounts' );
- if ( isset( $gateways[ $woocommerce->session->chosen_payment_method ] ) ) {
+ if ( isset( $gateways[ WC()->session->chosen_payment_method ] ) ) {
// Gets the gateway discount.
- $value = $gateways[ $woocommerce->session->chosen_payment_method ];
+ $value = $gateways[ WC()->session->chosen_payment_method ];
if ( apply_filters( 'wc_payment_discounts_apply_discount', 0 < $value, $cart ) ) {
// Gets the gateway data.
- $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
- $gateway = $payment_gateways[ $woocommerce->session->chosen_payment_method ];
+ $payment_gateways = WC()->payment_gateways->payment_gateways();
+ $gateway = $payment_gateways[ WC()->session->chosen_payment_method ];
// Generate the discount amount and title.
$discount_name = $this->discount_name( $value, $gateway );
diff --git a/uninstall.php b/uninstall.php
index 7d292aa..c7608e3 100644
--- a/uninstall.php
+++ b/uninstall.php
@@ -4,10 +4,6 @@
exit;
}
-// Delete old options.
-delete_option( 'wcpaydisc_settings' );
-delete_option( 'wcpaydisc_gateways' );
-
// Delete plugin options.
delete_option( 'woocommerce_payment_discounts' );
delete_option( 'woocommerce_payment_discounts_version' );
diff --git a/woocommerce-payment-discounts.php b/woocommerce-payment-discounts.php
index 744f59b..34d0010 100644
--- a/woocommerce-payment-discounts.php
+++ b/woocommerce-payment-discounts.php
@@ -44,7 +44,7 @@ private function __construct() {
// Load plugin text domain.
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
- if ( function_exists( 'WC' ) ) {
+ if ( defined( 'WC_VERSION' ) && ! version_compare( WC_VERSION, '2.1', '>=' ) ) {
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
$this->admin_includes();
}
@@ -115,7 +115,7 @@ public function load_plugin_textdomain() {
* @return string Admin notice.
*/
public function woocommerce_is_missing_notice() {
- echo '';
+ echo '';
}
}