Skip to content

Commit

Permalink
IMPROVED: removed unnecessary code
Browse files Browse the repository at this point in the history
Fixed: license was not showing registered domains or devices in my account page
  • Loading branch information
michelve committed Mar 31, 2020
1 parent 07efc0c commit da00a42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 49 deletions.
2 changes: 2 additions & 0 deletions includes/slm-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,5 +458,7 @@ static function get_lic_activity($license_key){





}

62 changes: 13 additions & 49 deletions public/slm-add-menu-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public function __construct()
// Actions used to insert a new endpoint in the WordPress.
add_action('init', array($this, 'add_endpoints'));
add_filter('query_vars', array($this, 'add_query_vars'), 0);

// Change the My Accout page title.
add_filter('the_title', array($this, 'endpoint_title'));

// Insering your new tab/page into the My Account page.
add_filter('woocommerce_account_menu_items', array($this, 'slm_woo_menu_list'));
add_action('woocommerce_account_' . self::$endpoint . '_endpoint', array($this, 'endpoint_content'));
Expand Down Expand Up @@ -83,16 +85,10 @@ public function endpoint_content()

// if wp billing is empty
if ($wc_billing_email == '') {
$get_user_info = get_userdata(get_current_user_id());
$wc_billing_email = $get_user_info->user_email;
$wc_billing_email = get_userdata(get_current_user_id())->user_email;
}

$result = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE email LIKE '%" . SLM_Woo_Account::getActiveUser('email') . "%' OR email LIKE '%" . $wc_billing_email . "%' ORDER BY `email` DESC LIMIT 0,1000");

$result_array = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE email LIKE '%" . SLM_Woo_Account::getActiveUser('email') . "%' OR email LIKE '%" . $wc_billing_email . "%' ORDER BY `email` DESC LIMIT 0,1000", ARRAY_A);

$get_subscription = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "postmeta WHERE meta_value = '273' LIMIT 0,1000", ARRAY_A);
$lic_order_id = array();
$result = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE email='" . $wc_billing_email . "' ORDER BY `email` DESC LIMIT 0,1000");

?>

Expand All @@ -112,11 +108,6 @@ public function endpoint_content()
global $wp_query;

foreach ($result as $license_info) : ?>
<?php
global $wpdb;

$get_subscription = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "postmeta WHERE `meta_value` = '" . $license_info->purchase_id_ . "' LIMIT 0,1000;", ARRAY_A);
?>

<tr data-toggle="collapse" data-target=".demo<?php echo $class_++; ?>" class="woocommerce-orders-table__row woocommerce-orders-table__row--status-completed order">
<td class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-number slm-order"><a href="<?php echo get_site_url() . '/my-account/view-order/' . $license_info->purchase_id_; ?>">#<?php echo $license_info->purchase_id_; ?></a></td>
Expand All @@ -138,7 +129,7 @@ public function endpoint_content()

$detailed_license_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_key_tbl WHERE `license_key` = '" . $license_info->license_key . "' ORDER BY `id` LIMIT 0,1000;", ARRAY_A);

$detailed_domain_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_reg_domain_tbl WHERE `lic_key` = '" . $license_info->license_key . "' ORDER BY `lic_key_id` LIMIT 0,1000;", ARRAY_A);
$detailed_domain_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_reg_domain_tbl WHERE `lic_key` = '" . $license_info->license_key . "' ORDER BY `lic_key_id` LIMIT 0,1000;", ARRAY_A);

$detailed_devices_info = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "lic_reg_devices_tbl WHERE `lic_key` = '" . $license_info->license_key . "' ORDER BY `lic_key_id` LIMIT 0,1000;", ARRAY_A);
?>
Expand All @@ -148,18 +139,12 @@ public function endpoint_content()
<h5>Domain(s)</h5>
<ul class="list-unstyled">
<?php
// var_dump($detailed_domain_info);
// var_dump($detailed_devices_info);
if (count($detailed_domain_info) == 0) {
echo "<li>no data available</li>";
} else {
foreach ($detailed_domain_info as $domain_info) {

if (isset($domain_info["lic_key"]) && !empty($domain_info["lic_key"])) {
echo '<li> <a href="http://' . $domain_info["registered_domain"] . '" target="_blank">' . $domain_info["registered_domain"] . '</a></li>';
} else {
echo "<li>no data available</li>";
}
foreach ($detailed_domain_info as $domain_info) {

if (isset($domain_info["lic_key"]) && !empty($domain_info["lic_key"])) {
echo '<li> <a href="http://' . $domain_info["registered_domain"] . '" target="_blank">' . $domain_info["registered_domain"] . '</a></li>';
} else {
echo "<li>no data available</li>";
}
}
$out = array_values($detailed_license_info);
Expand All @@ -173,17 +158,13 @@ public function endpoint_content()
<h5>Device(s)</h5>
<ul class="list-unstyled">
<?php
if (count($detailed_domain_info) == 0) {
echo "<li>no data available</li>";
} else {
foreach ($detailed_devices_info as $devices_info) {
foreach ($detailed_devices_info as $devices_info) {
if (isset($devices_info["lic_key"]) && !empty($devices_info["lic_key"])) {
echo '<li>' . $devices_info["registered_devices"] . '</li>';
} else {
echo "<li>no data available</li>";
}
}
}
?>
</ul>
</div>
Expand Down Expand Up @@ -225,33 +206,16 @@ public function endpoint_content()
</div>
</td>
</tr>

<?php endforeach;
?>
</tbody>
</table>
</div>
<?php

$licenses_status_array = array();
foreach ($result_array as $license_is_active) {
$licenses_status_array[] = $license_is_active["lic_status"];
}




if (null !== SLM_Helper_Class::slm_get_option('slm_dl_manager') && SLM_Helper_Class::slm_get_option('slm_dl_manager') == 1) {
//print_r($licenses_status_array);
// check if Download Manager is active
if (function_exists('add_wdm_settings_tab')) {
if (in_array("pending", $licenses_status_array) || in_array("active", $licenses_status_array)) {
echo ' <div class="clear"></div> <header class="entry-header"> <h2 class="entry-title" itemprop="name">My Downloads</h2> </header>';
echo do_shortcode('[wpdm_all_packages]');
} else {
echo " <p> No active subscriptions found. Renew or reactivate your subscription. </p> ";
}
}
}
}

/**
Expand Down

0 comments on commit da00a42

Please sign in to comment.