Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Dynamic Sidebar into plugin : PFWMA-116 #50

Merged
merged 13 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
473 changes: 337 additions & 136 deletions admin/class-paypal-for-woocommerce-multi-account-management-admin.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ select.smart_forwarding_field {
position: relative;
}

#angelleye_paypal_marketing_table table.fixed {
border-right: none;
}

@media screen and (max-width: 782px) {
.angelleye_multi_account_left {
max-width: 100% !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,52 @@ jQuery(document).off('click', '#angelleye-updater-notice .notice-dismiss').on('c
});
});
}
});
});
jQuery('.disable_all_vendor_rules').on('click', function (event) {
var r = confirm(pfwma_param.disable_all_vendor_rules_alert_message);
if (r == true) {
jQuery(".disable_all_vendor_rules").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});
var data = {
'action': 'pfwma_disable_all_vendor_rules'
};
jQuery.post(ajaxurl, data, function (response) {
if ('failed' !== response)
{
var redirectUrl = response;
top.location.replace(redirectUrl);
return true;
} else
{
alert('Error updating records.');
return false;
}
});
} else {
event.preventDefault();
return r;
}
});
jQuery('.enable_all_vendor_rules').on('click', function (event) {
var r = confirm(pfwma_param.enable_all_vendor_rules_alert_message);
if (r == true) {
jQuery(".enable_all_vendor_rules").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});
var data = {
'action': 'pfwma_enable_all_vendor_rules'
};
jQuery.post(ajaxurl, data, function (response) {
if ('failed' !== response)
{
var redirectUrl = response;
top.location.replace(redirectUrl);
return true;
} else
{
alert('Error updating records.');
return false;
}
});
} else {
event.preventDefault();
return r;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ function column_default($item, $column_name) {
$user_info = '';
if ($condition_user) {
if ($condition_user != 'all') {
$user_info = '<p class="description">' . sprintf('When User ID is %s', $condition_user) . '</p>';
$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 = '<p class="description">' . sprintf('When Author is %s', $user_string) . '</p>';
}
}
$other_condition = '';
Expand Down Expand Up @@ -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 .= '<a href="#TB_inline?width=600&height=550&inlineId=modal-window-' . esc_attr($item['ID']) . '" class="thickbox" title="Products added in Trigger Condition">Products</a>';
$product_text .= '<div id="modal-window-' . esc_attr($item['ID']) . '" style="display:none;">';
Expand Down Expand Up @@ -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('<a href="%s">Edit</a>', esc_url(add_query_arg($edit_params))),
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
<?php

/**
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.0.0
* @package Paypal_For_Woocommerce_Multi_Account_Management
* @subpackage Paypal_For_Woocommerce_Multi_Account_Management/includes
* @author Angell EYE <[email protected]>
*/
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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ protected function pagination( $which ) {
$this->screen->render_screen_reader_content( 'heading_pagination' );
}

$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
$output = '';
//$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';

$current = $this->get_pagenum();
$removable_query_args = wp_removable_query_args();
Expand Down
Loading