Skip to content

Commit

Permalink
Various small fixes to stop error messages from displaying in WooComm…
Browse files Browse the repository at this point in the history
…erce v3.9+
  • Loading branch information
stuartduff committed Feb 19, 2020
1 parent 6d28ef7 commit 84aea62
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ All support requests for this extension should be posted to the [WooCommerce Dyn

## Changelog

**1.0.6 - 19/02/20**
* Fix - Various small fixes to stop error messages from displaying in WooCommerce v3.9+

**1.0.5 - 05/09/16**
* Fix - Added check to prevent wc_add_notice() from trying to display on admin.

Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Below are the discounts that the plugin will currently display.

== Changelog ==

= 1.0.6 - 19/02/20 =
* Fix - Various small fixes to stop error messages from displaying in WooCommerce v3.9+

= 1.0.5 - 05/09/16 =
* Fix - Added check to prevent wc_add_notice() from trying to display on admin.

Expand Down
23 changes: 14 additions & 9 deletions woocommerce-dynamic-pricing-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
* Plugin Name: WooCommerce Dynamic Pricing Table
* Plugin URI: https://github.com/stuartduff/woocommerce-dynamic-pricing-table
* Description: Displays a pricing discount table on WooCommerce products, a user role discount message and a simple category discount message when using the WooCommerce Dynamic Pricing plugin.
* Version: 1.0.5
* Version: 1.0.6
* Author: Stuart Duff
* Author URI: http://stuartduff.com
* Requires at least: 4.6
* Tested up to: 4.6
* Requires at least: 5.3
* Tested up to: 5.3
*
* Text Domain: woocommerce-dynamic-pricing-table
* Domain Path: /languages/
*
* WC requires at least: 3.9
* WC tested up to: 4.0
*
* @package WC_Dynamic_Pricing_Table
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
Expand Down Expand Up @@ -332,7 +335,7 @@ public function role_discount_notification_message() {
foreach( $role_pricing_rule_sets as $role_rules ) {

// Gets the discount role of the user and the discount amount.
$user_discount_role = $role_rules['conditions'][0]['args']['roles'][0];
$user_discount_role = isset( $role_rules['conditions'][0]['args']['roles'][0] ) ? $role_rules['conditions'][0]['args']['roles'][0] : '';
$role_discount_amount = $role_rules['rules'][0]['amount'];

if ( is_woocommerce() && $current_user_role === $user_discount_role && null !== $user_discount_role ) {
Expand All @@ -349,12 +352,13 @@ public function role_discount_notification_message() {

}

// Output role discount message
wc_add_notice( $info_message, 'notice' );

}

}

wc_add_notice( $info_message, 'notice' );

}

/**
Expand All @@ -381,7 +385,7 @@ public function category_discount_notification_message() {
foreach( $category_pricing_rule_sets as $category_rules ) {

// Gets the discount category and the discount amount set for the category.
$discount_category = $category_rules['collector']['args']['cats'][0];
$discount_category = isset( $category_rules['collector']['args']['cats'][0] ) ? $category_rules['collector']['args']['cats'][0] : '';
$category_discount_amount = $category_rules['rules'][0]['amount'];


Expand All @@ -399,12 +403,13 @@ public function category_discount_notification_message() {

}

// Output category discount message
wc_add_notice( $info_message, 'notice' );

}

}

wc_add_notice( $info_message, 'notice' );

}

/**
Expand Down

0 comments on commit 84aea62

Please sign in to comment.