' . sprintf('When User ID is %s', $condition_user) . '
';
+ $user = get_user_by( 'id', $condition_user );
+ $user_string = sprintf(
+ esc_html__( '%1$s (#%2$s %3$s)', 'woocommerce' ),
+ $user->display_name,
+ absint( $user->ID ),
+ $user->user_email
+ );
+ $user_info = '' . sprintf('When Author is %s', $user_string) . '
';
}
}
$other_condition = '';
@@ -76,7 +83,7 @@ function column_default($item, $column_name) {
add_thickbox();
$product_text = '';
- if (!empty($product_ids)) {
+ if (!empty($product_ids) && is_array($product_ids)) {
$products = $product_ids;
$product_text .= '';
@@ -116,7 +123,7 @@ function column_default($item, $column_name) {
}
function column_title($item) {
- $edit_params = array('page' => $_REQUEST['page'], 'action' => 'edit', 'ID' => $item['ID']);
+ $edit_params = array('section' => 'add_edit_account', 'page' => $_REQUEST['page'], 'action' => 'edit', 'ID' => $item['ID']);
$delete_params = array('page' => $_REQUEST['page'], 'action' => 'delete', 'ID' => $item['ID']);
$actions = array(
'edit' => sprintf('
Edit', esc_url(add_query_arg($edit_params))),
@@ -169,11 +176,13 @@ function process_bulk_action() {
}
$redirect_url = remove_query_arg(array('action', 'ID'));
wp_redirect(add_query_arg('deleted', true, $redirect_url));
+ $this->message = __('Account permanently deleted.', 'paypal-for-woocommerce-multi-account-management');
exit();
}
if (!empty($_GET['action']) && 'delete' == $_GET['action'] && !empty($_GET['ID'])) {
wp_delete_post($_GET['ID'], true);
$redirect_url = remove_query_arg(array('action', 'ID'));
+ $this->message = __('Account permanently deleted.', 'paypal-for-woocommerce-multi-account-management');
wp_redirect(add_query_arg('deleted', true, $redirect_url));
exit();
}
diff --git a/includes/class-paypal-for-woocommerce-multi-account-management-vendor.php b/includes/class-paypal-for-woocommerce-multi-account-management-vendor.php
new file mode 100644
index 0000000..e6ecda8
--- /dev/null
+++ b/includes/class-paypal-for-woocommerce-multi-account-management-vendor.php
@@ -0,0 +1,245 @@
+
+ */
+class Paypal_For_Woocommerce_Multi_Account_Management_Vendor {
+
+ private $plugin_name;
+ private $version;
+ public $testmode;
+
+ public function __construct($plugin_name, $version) {
+ $this->plugin_name = $plugin_name;
+ $this->version = $version;
+ $global_automatic_rule_creation_testmode = get_option('global_automatic_rule_creation_testmode', '');
+ if($global_automatic_rule_creation_testmode == 'on') {
+ $this->testmode = 'on';
+ } else {
+ $this->testmode = '';
+ }
+ }
+
+ public function angelleye_paypal_for_woocommerce_multi_account_rule_save_dokan($vendor_id) {
+ try {
+ if (function_exists('dokan')) {
+ if (!dokan_is_user_seller($vendor_id)) {
+ return;
+ }
+ $post_id = $this->angelleye_is_vendor_account_exist($vendor_id);
+ if ($post_id != false) {
+ $user = get_user_by('id', $vendor_id);
+ $dokan_profile_settings = get_user_meta($vendor_id, 'dokan_profile_settings', true);
+ if( !empty($dokan_profile_settings['payment']['paypal']['email'])) {
+ $email = $dokan_profile_settings['payment']['paypal']['email'];
+ }
+ if (empty($email)) {
+ $email = get_user_meta($vendor_id, 'billing_email', true);
+ }
+ if (empty($email)) {
+ $email = $user->user_email;
+ }
+ if (!empty($email)) {
+ update_post_meta($post_id, 'woocommerce_paypal_express_sandbox_email', $email);
+ update_post_meta($post_id, 'woocommerce_paypal_express_email', $email);
+ }
+ $user_string = sprintf(
+ esc_html__('%1$s (#%2$s %3$s)', 'woocommerce'), $user->display_name, absint($user->ID), $user->user_email
+ );
+ $woocommerce_paypal_express_account_name = get_post_meta($post_id, 'woocommerce_paypal_express_account_name', true);
+ if (empty($woocommerce_paypal_express_account_name)) {
+ update_post_meta($post_id, 'woocommerce_paypal_express_account_name', $user_string);
+ }
+ } else {
+ $user = get_user_by('id', $vendor_id);
+ $user_string = sprintf(
+ esc_html__('%1$s (#%2$s %3$s)', 'woocommerce'), $user->display_name, absint($user->ID), $user->user_email
+ );
+ $my_post = array(
+ 'post_title' => $user_string,
+ 'post_content' => '',
+ 'post_status' => 'publish',
+ 'post_author' => $vendor_id,
+ 'post_type' => 'microprocessing'
+ );
+ $post_id = wp_insert_post($my_post);
+ $email = get_user_meta($vendor_id, 'pv_paypal', true);
+ if (empty($email)) {
+ $email = get_user_meta($vendor_id, 'billing_email', true);
+ }
+ if (empty($email)) {
+ $user = get_user_by('id', $vendor_id);
+ $email = $user->user_email;
+ }
+ $microprocessing_key_array = array(
+ 'woocommerce_paypal_express_enable' => 'on',
+ 'woocommerce_paypal_express_testmode' => $this->testmode,
+ 'woocommerce_paypal_express_account_name' => $user_string,
+ 'woocommerce_paypal_express_sandbox_email' => $email,
+ 'woocommerce_paypal_express_sandbox_merchant_id' => '',
+ 'woocommerce_paypal_express_sandbox_api_username' => '',
+ 'woocommerce_paypal_express_sandbox_api_password' => '',
+ 'woocommerce_paypal_express_sandbox_api_signature' => '',
+ 'woocommerce_paypal_express_email' => $email,
+ 'woocommerce_paypal_express_merchant_id' => '',
+ 'woocommerce_paypal_express_api_username' => '',
+ 'woocommerce_paypal_express_api_password' => '',
+ 'woocommerce_paypal_express_api_signature' => '',
+ 'woocommerce_paypal_express_api_condition_field' => 'transaction_amount',
+ 'woocommerce_paypal_express_api_condition_sign' => 'greaterthan',
+ 'woocommerce_paypal_express_api_condition_value' => '0',
+ 'woocommerce_paypal_express_api_user_role' => 'all',
+ 'woocommerce_paypal_express_api_user' => $vendor_id,
+ 'woocommerce_paypal_express_api_product_ids' => 'a:0:{}',
+ 'product_categories' => '',
+ 'product_tags' => '',
+ 'buyer_countries' => '',
+ 'woocommerce_priority' => '',
+ 'angelleye_multi_account_choose_payment_gateway' => 'paypal_express',
+ 'store_countries' => '',
+ 'shipping_class' => 'all',
+ 'currency_code' => '',
+ 'ec_site_owner_commission' => '',
+ 'ec_site_owner_commission_label' => ''
+ );
+ foreach ($microprocessing_key_array as $key => $value) {
+ update_post_meta($post_id, $key, $value);
+ }
+ update_post_meta($post_id, 'vendor_id', $vendor_id);
+ }
+ }
+ } catch (Exception $ex) {
+
+ }
+ }
+
+ public function angelleye_paypal_for_woocommerce_multi_account_rule_save_wc_vendor($vendor_id) {
+ try {
+ if (class_exists('WCV_Vendors')) {
+ if (!WCV_Vendors::is_pending($vendor_id) && !WCV_Vendors::is_vendor($vendor_id)) {
+ return;
+ }
+ $post_id = $this->angelleye_is_vendor_account_exist($vendor_id);
+ if ($post_id != false) {
+ $user = get_user_by('id', $vendor_id);
+ $email = get_user_meta($vendor_id, 'pv_paypal', true);
+ if (empty($email)) {
+ $email = get_user_meta($vendor_id, 'billing_email', true);
+ }
+ if (empty($email)) {
+ $email = $user->user_email;
+ }
+ if (!empty($email)) {
+ update_post_meta($post_id, 'woocommerce_paypal_express_sandbox_email', $email);
+ update_post_meta($post_id, 'woocommerce_paypal_express_email', $email);
+ }
+ $user_string = sprintf(
+ esc_html__('%1$s (#%2$s %3$s)', 'woocommerce'), $user->display_name, absint($user->ID), $user->user_email
+ );
+ $woocommerce_paypal_express_account_name = get_post_meta($post_id, 'woocommerce_paypal_express_account_name', true);
+ if (empty($woocommerce_paypal_express_account_name)) {
+ update_post_meta($post_id, 'woocommerce_paypal_express_account_name', $user_string);
+ }
+ } else {
+ $user = get_user_by('id', $vendor_id);
+ $user_string = sprintf(
+ esc_html__('%1$s (#%2$s %3$s)', 'woocommerce'), $user->display_name, absint($user->ID), $user->user_email
+ );
+ $my_post = array(
+ 'post_title' => $user_string,
+ 'post_content' => '',
+ 'post_status' => 'publish',
+ 'post_author' => $vendor_id,
+ 'post_type' => 'microprocessing'
+ );
+ $post_id = wp_insert_post($my_post);
+ $email = get_user_meta($vendor_id, 'pv_paypal', true);
+ if (empty($email)) {
+ $email = get_user_meta($vendor_id, 'billing_email', true);
+ }
+ if (empty($email)) {
+ $user = get_user_by('id', $vendor_id);
+ $email = $user->user_email;
+ }
+ $microprocessing_key_array = array(
+ 'woocommerce_paypal_express_enable' => 'on',
+ 'woocommerce_paypal_express_testmode' => $this->testmode,
+ 'woocommerce_paypal_express_account_name' => $user_string,
+ 'woocommerce_paypal_express_sandbox_email' => $email,
+ 'woocommerce_paypal_express_sandbox_merchant_id' => '',
+ 'woocommerce_paypal_express_sandbox_api_username' => '',
+ 'woocommerce_paypal_express_sandbox_api_password' => '',
+ 'woocommerce_paypal_express_sandbox_api_signature' => '',
+ 'woocommerce_paypal_express_email' => $email,
+ 'woocommerce_paypal_express_merchant_id' => '',
+ 'woocommerce_paypal_express_api_username' => '',
+ 'woocommerce_paypal_express_api_password' => '',
+ 'woocommerce_paypal_express_api_signature' => '',
+ 'woocommerce_paypal_express_api_condition_field' => 'transaction_amount',
+ 'woocommerce_paypal_express_api_condition_sign' => 'greaterthan',
+ 'woocommerce_paypal_express_api_condition_value' => '0',
+ 'woocommerce_paypal_express_api_user_role' => 'all',
+ 'woocommerce_paypal_express_api_user' => $vendor_id,
+ 'woocommerce_paypal_express_api_product_ids' => 'a:0:{}',
+ 'product_categories' => '',
+ 'product_tags' => '',
+ 'buyer_countries' => '',
+ 'woocommerce_priority' => '',
+ 'angelleye_multi_account_choose_payment_gateway' => 'paypal_express',
+ 'store_countries' => '',
+ 'shipping_class' => 'all',
+ 'currency_code' => '',
+ 'ec_site_owner_commission' => '',
+ 'ec_site_owner_commission_label' => ''
+ );
+ foreach ($microprocessing_key_array as $key => $value) {
+ update_post_meta($post_id, $key, $value);
+ }
+ update_post_meta($post_id, 'vendor_id', $vendor_id);
+ }
+ }
+ } catch (Exception $ex) {
+
+ }
+ }
+
+ public function angelleye_paypal_for_woocommerce_multi_account_rule_save($vendor_id) {
+ try {
+ $dokan_profile_settings = get_user_meta($vendor_id, 'dokan_profile_settings', true);
+ if (!empty($dokan_profile_settings)) {
+ $this->angelleye_paypal_for_woocommerce_multi_account_rule_save_dokan($vendor_id);
+ } else {
+ $this->angelleye_paypal_for_woocommerce_multi_account_rule_save_wc_vendor($vendor_id);
+ }
+ } catch (Exception $ex) {
+
+ }
+ }
+
+ public function angelleye_is_vendor_account_exist($vendor_id) {
+ $args = array(
+ 'post_type' => 'microprocessing',
+ 'meta_query' => array(
+ array(
+ 'key' => 'vendor_id',
+ 'value' => $vendor_id
+ )
+ ),
+ 'fields' => 'ids'
+ );
+ $query = new WP_Query($args);
+ $duplicates = $query->posts;
+ if (!empty($duplicates)) {
+ if (!empty($query->posts[0])) {
+ return $query->posts[0];
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php b/includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php
index 8f1b5c1..3c777d9 100644
--- a/includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php
+++ b/includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php
@@ -790,7 +790,8 @@ protected function pagination( $which ) {
$this->screen->render_screen_reader_content( 'heading_pagination' );
}
- $output = '
' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '';
+ $output = '';
+ //$output = '
' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '';
$current = $this->get_pagenum();
$removable_query_args = wp_removable_query_args();
diff --git a/includes/class-paypal-for-woocommerce-multi-account-management.php b/includes/class-paypal-for-woocommerce-multi-account-management.php
index 685afae..a8759ee 100644
--- a/includes/class-paypal-for-woocommerce-multi-account-management.php
+++ b/includes/class-paypal-for-woocommerce-multi-account-management.php
@@ -45,6 +45,7 @@ class Paypal_For_Woocommerce_Multi_Account_Management {
protected $version;
protected $plugin_screen_hook_suffix = null;
public $plugin_admin;
+ public $message;
/**
* Define the core functionality of the plugin.
@@ -107,6 +108,7 @@ private function load_dependencies() {
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-wp-list-table.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-list-data.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/angelleye-multi-account-function.php';
+ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-paypal-for-woocommerce-multi-account-management-vendor.php';
@@ -117,6 +119,7 @@ private function load_dependencies() {
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-paypal-for-woocommerce-multi-account-management-admin-paypal-payflow.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-paypal-for-woocommerce-multi-account-management-admin-express-checkout.php';
//require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-paypal-for-woocommerce-multi-account-management-admin-paypal-standard.php';
+ require_once plugin_dir_path(dirname(__FILE__)) . '/template/sidebar-process.php';
$this->loader = new Paypal_For_Woocommerce_Multi_Account_Management_Loader();
}
@@ -163,7 +166,7 @@ private function define_admin_hooks() {
$this->loader->add_action('angelleye_set_multi_account', $plugin_admin, 'angelleye_set_multi_account', 10, 2);
$this->loader->add_filter('set-screen-option', $plugin_admin, 'angelleye_set_screen_option', 10, 3);
$this->loader->add_action('load-settings_page_paypal-for-woocommerce', $plugin_admin, 'angelleye_add_screen_option', 10);
-
+
$express_checkout = new Paypal_For_Woocommerce_Multi_Account_Management_Admin_Express_Checkout($this->get_plugin_name(), $this->get_version());
$paypal_payflow = new Paypal_For_Woocommerce_Multi_Account_Management_Admin_PayPal_Payflow($this->get_plugin_name(), $this->get_version());
@@ -181,8 +184,23 @@ private function define_admin_hooks() {
//$this->loader->add_filter('woocommerce_paypal_args', $paypal, 'angelleye_woocommerce_paypal_args', 10, 2);
$this->loader->add_action('woocommerce_create_refund', $express_checkout, 'own_woocommerce_create_refund', 10, 2);
$this->loader->add_filter('angelleye_multi_account_need_shipping', $express_checkout, 'own_angelleye_multi_account_need_shipping', 10, 3);
-
-
+ $global_automatic_rule_creation_enable = get_option('global_automatic_rule_creation_enable', '');
+ if( $global_automatic_rule_creation_enable == 'on' ) {
+ $vendor = new Paypal_For_Woocommerce_Multi_Account_Management_Vendor($this->get_plugin_name(), $this->get_version());
+ $this->loader->add_action('personal_options_update', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('edit_user_profile_update', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('user_register', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('profile_update', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('wcv_pro_store_settings_saved', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('dokan_new_seller_created', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ $this->loader->add_action('dokan_store_profile_saved', $vendor, 'angelleye_paypal_for_woocommerce_multi_account_rule_save');
+ }
+ $this->loader->add_action('wp_ajax_pfwma_disable_all_vendor_rules', $plugin_admin, 'angelleye_pfwma_disable_all_vendor_rules');
+ $this->loader->add_action('wp_ajax_pfwma_enable_all_vendor_rules', $plugin_admin, 'angelleye_pfwma_enable_all_vendor_rules');
+ $this->loader->add_action( 'admin_init', $plugin_admin, 'angelleye_pfwma_display_notice');
+ $this->loader->add_action( 'admin_footer', $plugin_admin, 'angelleye_pfwma_add_deactivation_form');
+ $this->loader->add_action( 'wp_ajax_angelleye_send_deactivation_pfwma', $plugin_admin, 'angelleye_pfwma_plugin_deactivation_request');
+
}
/**
@@ -263,9 +281,50 @@ public function display_plugin_admin_page() {
'title_li' => $title,
'hide_empty' => $empty
);
-
$product_cats = get_categories($args);
- $this->plugin_admin->angelleye_paypal_for_woocommerce_general_settings_tab_content();
+ $this->display_plugin_admin_page_submenu();
+ echo '';
+ $this->plugin_admin->display_admin_notice();
+ if (empty($_GET['section'])) {
+ $this->plugin_admin->angelleye_multi_account_list();
+ } elseif (!empty($_GET['section']) && $_GET['section'] === 'add_edit_account') {
+ $this->plugin_admin->angelleye_paypal_for_woocommerce_general_settings_tab_content();
+ } elseif (!empty($_GET['section']) && $_GET['section'] === 'settings') {
+ $this->plugin_admin->angelleye_multi_account_settings_fields();
+ }
+
+
+ }
+
+ public function display_plugin_admin_page_submenu() {
+ ?>
+
+
+
+
+ message)) {
+ echo '
' . esc_html($this->message) . '
';
+ }
+ ?>
+
+
+
+
diff --git a/template/sidebar-process.php b/template/sidebar-process.php
new file mode 100644
index 0000000..77a01d3
--- /dev/null
+++ b/template/sidebar-process.php
@@ -0,0 +1,64 @@
+request));
+ }
+ $url = 'https://sendy.angelleye.com/subscribe';
+ $response = wp_remote_post($url, array(
+ 'method' => 'POST',
+ 'timeout' => 45,
+ 'redirection' => 5,
+ 'httpversion' => '1.0',
+ 'blocking' => true,
+ 'headers' => array(),
+ 'body' => array('list' => 'pjFolYKqSdLe57i4uuUz0g',
+ 'boolean' => 'true',
+ 'email' => $_POST['email'],
+ 'gdpr' => 'true',
+ 'silent' => 'true',
+ 'api_key' => 'qFcoVlU2uG3AMYabNTrC',
+ 'referrer' => $current_url
+ ),
+ 'cookies' => array()
+ )
+ );
+ if (is_wp_error($response)) {
+ wp_send_json(wp_remote_retrieve_body($response));
+ } else {
+ $body = wp_remote_retrieve_body($response);
+ $apiResponse = strval($body);
+ switch ($apiResponse) {
+ case 'true':
+ case '1':
+ prepareResponse("true", 'Thank you for subscribing!');
+ case 'Already subscribed.':
+ prepareResponse("true", 'Already subscribed!');
+ default:
+ prepareResponse("false", $apiResponse);
+ }
+ }
+ }
+
+}
+
+if (!function_exists('prepareResponse')) {
+
+ function prepareResponse($status = false, $msg = 'Something went wrong!') {
+ $return = array(
+ 'result' => $status,
+ 'message' => $msg
+ );
+ wp_send_json($return);
+ }
+
+}
\ No newline at end of file