From a9780640925b344e045a8d9a98b2d10d9cb6b6ef Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 1 Jul 2019 11:23:55 +0530 Subject: [PATCH 1/3] Subscription Renewal Fetal Error, PFWMA-52 --- ...ommerce-multi-account-management-admin.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php index 21d40f8..8d8cffd 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php @@ -778,6 +778,8 @@ public function is_angelleye_multi_account_used($order_id) { $_multi_account_api_username = get_post_meta($order_id, '_multi_account_api_username', true); if (!empty($_multi_account_api_username)) { return true; + } else { + return false; } } if (!class_exists('WooCommerce') || WC()->session == null) { @@ -1214,7 +1216,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; - WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + } return; } } elseif (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal_express') { @@ -1222,7 +1226,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_sandbox_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_sandbox_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_sandbox_api_signature']; - WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + } return; } } @@ -1232,7 +1238,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature']; - WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + } return; } } elseif (!empty($gateway_setting->id) && $gateway_setting->id == 'paypal_express') { @@ -1240,7 +1248,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature']; - WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->api_username); + } return; } } @@ -1280,7 +1290,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; - WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + } return; } } else { @@ -1289,7 +1301,9 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; - WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + if (class_exists('WooCommerce') && WC()->session ) { + WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); + } return; } } From 23847ab322c3756e0a962a537e04cde9329bccd7 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 2 Jul 2019 11:46:27 +0530 Subject: [PATCH 2/3] ERROR with Payflow Authorization Options, PFWMA-54 --- ...ommerce-multi-account-management-admin.php | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php index 8d8cffd..db81dde 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php @@ -1216,6 +1216,12 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + if(isset($request->paypal_user)) { + $request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_user']; + $request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; + $request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; + $request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); } @@ -1226,6 +1232,11 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_sandbox_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_sandbox_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_sandbox_api_signature']; + if(isset($request->api_username)) { + $request->api_username = $microprocessing_value['woocommerce_paypal_express_sandbox_api_username']; + $request->api_password = $microprocessing_value['woocommerce_paypal_express_sandbox_api_password']; + $request->api_signature = $microprocessing_value['woocommerce_paypal_express_sandbox_api_signature']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->api_username); } @@ -1238,6 +1249,12 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature']; + if(isset($request->paypal_user)) { + $request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_user']; + $request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password']; + $request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor']; + $request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->api_username); } @@ -1248,6 +1265,11 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres $gateway_setting->api_username = $microprocessing_value['woocommerce_paypal_express_api_username']; $gateway_setting->api_password = $microprocessing_value['woocommerce_paypal_express_api_password']; $gateway_setting->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature']; + if(isset($request->api_username)) { + $request->api_username = $microprocessing_value['woocommerce_paypal_express_api_username']; + $request->api_password = $microprocessing_value['woocommerce_paypal_express_api_password']; + $request->api_signature = $microprocessing_value['woocommerce_paypal_express_api_signature']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->api_username); } @@ -1261,8 +1283,11 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_expres public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflow($gateways, $request = null, $order_id = null) { if ($request == null) { $gateway_setting = $gateways; + } elseif($gateways == null) { + $gateways = $request; + $gateway_setting = $gateways; } else { - $gateway_setting = $request; + $gateway_setting = $gateways; } if ($order_id == null) { @@ -1290,6 +1315,12 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + if(isset($request->paypal_user)) { + $request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_user']; + $request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_password']; + $request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_vendor']; + $request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); } @@ -1301,6 +1332,12 @@ public function angelleye_paypal_for_woocommerce_multi_account_api_paypal_payflo $gateway_setting->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password']; $gateway_setting->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor']; $gateway_setting->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + if(isset($request->paypal_user)) { + $request->paypal_user = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_user']; + $request->paypal_password = $microprocessing_value['woocommerce_paypal_pro_payflow_api_password']; + $request->paypal_vendor = $microprocessing_value['woocommerce_paypal_pro_payflow_api_paypal_vendor']; + $request->paypal_partner = $microprocessing_value['woocommerce_paypal_pro_payflow_sandbox_api_paypal_partner']; + } if (class_exists('WooCommerce') && WC()->session ) { WC()->session->set('multi_account_api_username', $gateway_setting->paypal_user); } From 41f33eb1f9c4619f4720b8f74403a9ca8961dadf Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 2 Jul 2019 12:38:53 +0530 Subject: [PATCH 3/3] Subscription Renewal Fetal Error, PFWMA-54 --- ...ommerce-multi-account-management-admin.php | 90 +++++++++++++------ 1 file changed, 63 insertions(+), 27 deletions(-) diff --git a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php index db81dde..0d6b3c4 100644 --- a/admin/class-paypal-for-woocommerce-multi-account-management-admin.php +++ b/admin/class-paypal-for-woocommerce-multi-account-management-admin.php @@ -981,38 +981,74 @@ public function angelleye_get_multi_account_by_order_total_latest($gateways, $ga } } } - foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { - $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key); - $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); - // Categories - $woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids')); - $product_categories = get_post_meta($value->ID, 'product_categories', true); - if (!empty($product_categories)) { - if (!array_intersect($product_categories, $woo_product_categories)) { - unset($result[$key]); - unset($passed_rules); - continue; + if (is_null(WC()->cart) && WC()->cart->is_empty()) { + foreach ($order->get_items() as $cart_item_key => $values) { + $product = $order->get_product_from_item($values); + $product_id = $product->get_id(); + // Categories + $woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids')); + $product_categories = get_post_meta($value->ID, 'product_categories', true); + if (!empty($product_categories)) { + if (!array_intersect($product_categories, $woo_product_categories)) { + unset($result[$key]); + unset($passed_rules); + continue; + } } - } - // Tags - $woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids')); - $product_tags = get_post_meta($value->ID, 'product_tags', true); - if (!empty($product_tags)) { - if (!array_intersect($product_tags, $woo_product_tag)) { - unset($result[$key]); - unset($passed_rules); - continue; + // Tags + $woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids')); + $product_tags = get_post_meta($value->ID, 'product_tags', true); + if (!empty($product_tags)) { + if (!array_intersect($product_tags, $woo_product_tag)) { + unset($result[$key]); + unset($passed_rules); + continue; + } } - } - $product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true); - if (!empty($product_ids)) { - if (!array_intersect((array) $product_id, $product_ids)) { - unset($result[$key]); - unset($passed_rules); - continue; + $product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true); + if (!empty($product_ids)) { + if (!array_intersect((array) $product_id, $product_ids)) { + unset($result[$key]); + unset($passed_rules); + continue; + } + } + } + } else { + foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { + $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); + // Categories + $woo_product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids')); + $product_categories = get_post_meta($value->ID, 'product_categories', true); + if (!empty($product_categories)) { + if (!array_intersect($product_categories, $woo_product_categories)) { + unset($result[$key]); + unset($passed_rules); + continue; + } + } + // Tags + $woo_product_tag = wp_get_post_terms($product_id, 'product_tag', array('fields' => 'ids')); + $product_tags = get_post_meta($value->ID, 'product_tags', true); + if (!empty($product_tags)) { + if (!array_intersect($product_tags, $woo_product_tag)) { + unset($result[$key]); + unset($passed_rules); + continue; + } + } + $product_ids = get_post_meta($value->ID, 'woocommerce_paypal_express_api_product_ids', true); + if (!empty($product_ids)) { + if (!array_intersect((array) $product_id, $product_ids)) { + unset($result[$key]); + unset($passed_rules); + continue; + } } } } + + } unset($passed_rules); }