From 5ca65b4d0173e75f0b897fad074b1a6742f33ed1 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Wed, 5 Apr 2017 21:50:54 +0200 Subject: [PATCH] Fix warnings for WC 3.0 Work on issue #12 --- includes/admin/html/html-shipping-methods.php | 3 ++- includes/rules_shipping_framework_woocommerce.php | 6 ++++-- .../legacy-rules_shipping_framework_woocommerce.php | 2 +- woocommerce-shipping-by-rules.php | 7 ------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/includes/admin/html/html-shipping-methods.php b/includes/admin/html/html-shipping-methods.php index 357d84a..cb04512 100644 --- a/includes/admin/html/html-shipping-methods.php +++ b/includes/admin/html/html-shipping-methods.php @@ -30,9 +30,10 @@ $methods = array(); $globalzone['shipping_methods'] = $globalshippingzone->get_shipping_methods(); $zones[] = $globalzone; foreach ($zones as $zone) { + $zoneid = isset($zone['zone_id'])?$zone['zone_id']:$zone['id']; ?> <tr> - <td class="name"><a href="<?php echo admin_url(sprintf('admin.php?page=wc-settings&tab=shipping&zone_id=%d', $zone['zone_id'] )); ?>"><?php echo $zone['zone_name']; ?> (<?php echo $zone['formatted_zone_location']; ?>)</a></td> + <td class="name"><a href="<?php echo admin_url(sprintf('admin.php?page=wc-settings&tab=shipping&zone_id=%d', $zoneid )); ?>"><?php echo $zone['zone_name']; ?> (<?php echo $zone['formatted_zone_location']; ?>)</a></td> <td class="methods wc-shipping-zone-methods "> <ul> <?php diff --git a/includes/rules_shipping_framework_woocommerce.php b/includes/rules_shipping_framework_woocommerce.php index 7383310..ea13b4a 100644 --- a/includes/rules_shipping_framework_woocommerce.php +++ b/includes/rules_shipping_framework_woocommerce.php @@ -233,8 +233,10 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { $vendornames = array(); foreach ($data['vendorids'] as $v) { $vnd = get_user_by('id', $v); // Get user name by user id - $vendornames[] = $vnd->display_name; - $vendors[] = $vnd->user_login; + if (is_object($vnd)) { + $vendornames[] = $vnd->display_name; + $vendors[] = $vnd->user_login; + } } $data['vendornames'] = array_unique($vendornames); $data['vendors'] = array_unique($vendors); diff --git a/legacy-includes/legacy-rules_shipping_framework_woocommerce.php b/legacy-includes/legacy-rules_shipping_framework_woocommerce.php index 74c755c..86f03f0 100644 --- a/legacy-includes/legacy-rules_shipping_framework_woocommerce.php +++ b/legacy-includes/legacy-rules_shipping_framework_woocommerce.php @@ -32,7 +32,7 @@ class LegacyRulesShippingFrameworkWooCommerce extends RulesShippingFrameworkWooC } protected function parseMethodRules (&$method) { - $rulesets = Shipping_Rules_post_type::get_rulesets($method); + $rulesets = Legacy_Shipping_Rules_post_type::get_rulesets($method); foreach ($rulesets as $ruleset) { $this->parseMethodRule( /* Rules */ isset($ruleset['rules'])?$ruleset['rules']:'', diff --git a/woocommerce-shipping-by-rules.php b/woocommerce-shipping-by-rules.php index 99ab81f..0b79cf6 100644 --- a/woocommerce-shipping-by-rules.php +++ b/woocommerce-shipping-by-rules.php @@ -117,13 +117,6 @@ class WooCommerce_Shipping_By_Rules { } $this->helper = RulesShippingFrameworkWooCommerce::getHelper(); - // Shipping method post type definition: - // TODO: Legacy -// if (!class_exists("Shipping_Rules_post_type")) { -// // require_once plugin_dir_path( __FILE__ ) . 'includes/rules-shipping-post-type.php'; -// } -// $this->post_type = new Shipping_Rules_post_type($this->helper); - // Links to docs and config in the plugin page add_filter( 'plugin_row_meta', array( &$this, 'shippingbyrules_row_meta' ), 30, 2 ); add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), array( &$this, 'shippingbyrules_add_settings_link' ) ); -- GitLab