Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from homescriptone/develop
Browse files Browse the repository at this point in the history
Update to version 1.9.9
  • Loading branch information
manutheblacker authored Feb 21, 2023
2 parents 94f94f8 + a75b993 commit a989e85
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 32 deletions.
19 changes: 16 additions & 3 deletions README.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== Ultimate SMS Notifications for WooCommerce ===
=== Ultimate SMS Notifications ===
Contributors: homescript , freemius
Tags: orders notifications, woocommerce whatsapp, whatsapp automations, woocommerce whatsapp marketing, woocommerce orders notifications, mobile notifications gdpr compliant, mobile notifications woocommerce, woocommerce, telesign, woocommerce india
Tags: Order notifications,sms notifications,WooCommerce SMS,Shipping notifications,woocommerce india,woocommerce uk,SMS shipping updates,SMS reminders,automation,events sms
Donate link: https://buymeacoffee.com/homescriptone/
Requires at least: 4.4
Tested up to: 6.1
Stable tag: 1.9.8.3
Stable tag: 1.9.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.txt

Expand Down Expand Up @@ -152,6 +152,19 @@ You can read this tutorial explaining how to do it <a href="https://ultimatesmsn
== Screenshots ==

== Changelog ==
<h4>1.9.9 - 21 February 2023</h4>
<ul>
<li>Give the ability to shop manager to send notifications on behalf of the administrator.</li>
<li>Improve the contact list feature.</li>
</ul>
<h4>1.9.8.3 - 19 December 2022</h4>
<ul>
<li>Fix minor bugs related to the subscribers module.</li>
</ul>
<h4>1.9.8.2 - 19 November 2022</h4>
<ul>
<li>Fix minor bugs.</li>
</ul>
<h4>1.9.8.2 - 19 November 2022</h4>
<ul>
<li>Comply with WordPress.org guidelines.</li>
Expand Down
2 changes: 1 addition & 1 deletion abstract/constants.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* All the constants related to the plugin are defined here.
*/
define( 'WOO_USN_VERSION', '1.9.8.3' );
define( 'WOO_USN_VERSION', '1.9.9' );
define( 'WOO_USN_PATH', plugin_dir_path( __FILE__ ) );
define( 'WOO_USN_URL', plugins_url( '/', __FILE__ ) );
define( 'WOO_USN_PLUGIN_ID', '6855' );
Expand Down
17 changes: 8 additions & 9 deletions admin/class-woo-usn-admin-menu.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function add_menus()
add_menu_page(
__( 'SMS Notifications', 'ultimate-sms-notifications' ),
__( 'SMS Notifications', 'ultimate-sms-notifications' ),
'manage_options',
'manage_woocommerce',
'ultimate-sms-notifications',
array( 'Woo_Usn_Admin_Settings', 'configure_woo_usn_settings' ),
plugins_url( 'img/usn.svg', __FILE__ ),
Expand All @@ -23,7 +23,7 @@ public static function add_menus()
'ultimate-sms-notifications',
__( 'Send a Quick SMS', 'ultimate-sms-notifications' ),
__( 'Send a Quick SMS', 'ultimate-sms-notifications' ),
'manage_options',
'manage_woocommerce',
'ultimate-sms-notifications-send-sms',
array( 'Woo_Usn_Admin_Settings', 'send_sms' )
);
Expand All @@ -33,28 +33,27 @@ public static function add_menus()
'ultimate-sms-notifications',
__( 'Contact Lists', 'ultimate-sms-notifications' ),
__( 'Contact Lists', 'ultimate-sms-notifications' ),
'manage_options',
'manage_woocommerce',
'edit.php?post_type=woo_usn-list',
false
);
$submenu['ultimate-sms-notifications'][11] = $submenu['ultimate-sms-notifications'][2];
unset( $submenu['ultimate-sms-notifications'][2] );
$submenu['ultimate-sms-notifications'][13] = array( '<div >' . __( 'WhatsApp Settings', 'ultimate-sms-notifications' ) . '</div>', 'manage_options', admin_url( 'admin.php?page=ultimate-sms-notifications&tab=whatsapp-api' ) );
$submenu['ultimate-sms-notifications'][13] = array( '<div >' . __( 'WhatsApp Settings', 'ultimate-sms-notifications' ) . '</div>', 'manage_woocommerce', admin_url( 'admin.php?page=ultimate-sms-notifications&tab=whatsapp-api' ) );
$sub_log_loader = new Woo_Usn_Subscribers_Loader();
$subhook = add_submenu_page(
'ultimate-sms-notifications',
__( 'Subscribers', 'ultimate-sms-notifications' ),
__( 'Subscribers', 'ultimate-sms-notifications' ),
'manage_options',
'manage_woocommerce',
'ultimate-sms-notifications-subscribers',
array( $sub_log_loader, 'plugin_settings_page' )
);
add_action( "load-{$subhook}", array( $sub_log_loader, 'screen_option' ) );
$submenu['ultimate-sms-notifications'][20] = array( '<div class="woo-usn-links">' . __( 'Documentations', 'ultimate-sms-notifications' ) . '</div>', 'manage_options', 'https://docs.ultimatesmsnotifications.com/?utm_source=' . get_site_url() );
$submenu['ultimate-sms-notifications'][22] = array( '<div class="woo-usn-links">' . __( 'Knowledge Base', 'ultimate-sms-notifications' ) . '</div>', 'manage_options', 'https://help.ultimatesmsnotifications.com/?utm_source=' . get_site_url() );
$submenu['ultimate-sms-notifications'][23] = array( '<div class="woo-usn-links">' . __( 'Contact us', 'ultimate-sms-notifications' ) . '</div>', 'manage_options', 'https://chatting.page/homescriptone?utm_source=' . get_site_url() );
$submenu['ultimate-sms-notifications'][20] = array( '<div class="woo-usn-links">' . __( 'Documentations', 'ultimate-sms-notifications' ) . '</div>', 'manage_woocommerce', 'https://docs.ultimatesmsnotifications.com/?utm_source=' . get_site_url() );
$submenu['ultimate-sms-notifications'][23] = array( '<div class="woo-usn-links">' . __( 'Contact us', 'ultimate-sms-notifications' ) . '</div>', 'manage_woocommerce', 'https://chatting.page/homescriptone?utm_source=' . get_site_url() );
$first_menu = $submenu['ultimate-sms-notifications'][0];
$new_menu = array( '<div>' . __( 'Logs', 'ultimate-sms-notifications' ) . '</div>', 'manage_options', admin_url( 'admin.php?page=ultimate-sms-notifications-pricing' ) );
$new_menu = array( '<div>' . __( 'Logs', 'ultimate-sms-notifications' ) . '</div>', 'manage_woocommerce', admin_url( 'admin.php?page=ultimate-sms-notifications-pricing' ) );
$bm = array( $first_menu, $new_menu );
$setting_menu = array_slice( $submenu['ultimate-sms-notifications'], 1 );
$submenu['ultimate-sms-notifications'] = array_merge_recursive( $bm, $setting_menu );
Expand Down
89 changes: 80 additions & 9 deletions admin/class-woo-usn-admin-subscribers.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,46 @@ function() {

}

/**
* Check if subscribers table exist or not.
*/
public static function check_if_table_exists() {
global $wpdb;
$sql = "SHOW TABLES LIKE '{$wpdb->prefix}_woousn_subscribers_list'";

$query = $wpdb->get_results( $sql, 'ARRAY_A' );
$table_name = $wpdb->prefix . '_woousn_subscribers_list';

if ( ! function_exists('dbDelta') ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
}


if ( count( $query ) < 1 ) {
global $woo_usn_db_subscribers_version;
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (id mediumint(20) NOT NULL AUTO_INCREMENT,customer_id mediumint(255) NOT NULL UNIQUE,customer_consent text NOT NULL,customer_registered_page text NOT NULL,date datetime DEFAULT '2022-12-12 00:00:00' NOT NULL,PRIMARY KEY (id)) $charset_collate;";
dbDelta( $sql );
add_option( 'woo_usn_subscribers_db_version', $woo_usn_db_subscribers_version );
}

$column_sql = "SHOW COLUMNS from `$table_name` LIKE 'customer_order_id';";
$query = $wpdb->get_results( $column_sql, 'ARRAY_A' );

if ( count( $query ) < 1 ) {
$sql = "ALTER TABLE `$table_name` ADD COLUMN customer_order_id VARCHAR(255) AFTER customer_registered_page;";
dbDelta( $sql );
}

$column_sql = "SHOW INDEX FROM `$table_name`";
$query = $wpdb->get_results( $column_sql, 'ARRAY_A' );

if ( in_array( 'customer_id', array_column( $query, 'Table' ) ) ) {
$sql = "ALTER TABLE `$table_name` DROP INDEX customer_id;";
dbDelta( $sql );
}
}


/**
* Retrieve customers data from the database.
Expand All @@ -48,15 +88,22 @@ public static function get_customers( $per_page = 5, $page_number = 1, $paginati

$sql .= " LIMIT $per_page";
$sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;

return $wpdb->get_results( $sql, 'ARRAY_A' );
}

public static function get_customer_choices( $choice = 'on' ) {

global $wpdb;

$sql = "SELECT customer_id FROM {$wpdb->prefix}_woousn_subscribers_list where customer_consent='$choice'";
$sql = "SELECT customer_id FROM {$wpdb->prefix}_woousn_subscribers_list where customer_consent LIKE '%" . $choice . "%'";

return $wpdb->get_results( $sql, 'ARRAY_A' );
}

public static function get_orders_ids( $choice = 'on' ) {
global $wpdb;

$sql = "SELECT customer_order_id FROM {$wpdb->prefix}_woousn_subscribers_list where customer_consent LIKE '%" . $choice . "%'";

return $wpdb->get_results( $sql, 'ARRAY_A' );
}
Expand Down Expand Up @@ -109,10 +156,22 @@ public function no_items() {
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'customer_id':
$customer_id = $item['customer_id'];
$customer = new WC_Customer( $customer_id );
$fname = $customer->get_billing_first_name() . ' ' . $customer->get_billing_last_name();
echo wp_kses_post( '<a href="' . admin_url( 'user-edit.php?user_id=' . $customer_id ) . '">' . $fname . '</a>' );
if ( $item['customer_id'] == 0 ) {
$order_id = $item['customer_order_id'];
if ( $order_id ) {
$order_obj = wc_get_order( $order_id );
$fname = $order_obj->get_billing_first_name() . ' ' . $order_obj->get_billing_last_name();
echo wp_kses_post( '<a href="' . admin_url( "post.php?post=$order_id&action=edit" ) . '">' . $fname . '</a>' );
} else {
echo "Guest Customer with missing details";
}
} else {
$customer_id = $item['customer_id'];
$customer = new WC_Customer( $customer_id );
$fname = $customer->get_billing_first_name() . ' ' . $customer->get_billing_last_name();
echo wp_kses_post( '<a href="' . admin_url( 'user-edit.php?user_id=' . $customer_id ) . '">' . $fname . '</a>' );
}

break;

case 'customer_registered_page':
Expand All @@ -122,13 +181,22 @@ public function column_default( $item, $column_name ) {
case 'customer_consent':
$consent = $item['customer_consent'];
if ( 'on' == $consent ) {
echo '<i class="fa fa-check" style="color:green;"></i>' . esc_html__( 'Subscribed', 'ultimate-sms-notifications' );
echo '' . esc_html__( 'Subscribed', 'ultimate-sms-notifications' );
} else {
echo '<i class="fa fa-times-circle" style="color:red;"></i> ' . esc_html__( 'Unsubscribed', 'ultimate-sms-notifications' );
echo '' . esc_html__( 'Unsubscribed', 'ultimate-sms-notifications' );
}

break;

case 'order_related':
$order_id = $item['customer_order_id'];
if ( $order_id ) {
$order_obj = wc_get_order( $order_id );
$fname = $order_obj->get_billing_first_name() . ' ' . $order_obj->get_billing_last_name();
echo wp_kses_post( '<a href="' . admin_url( "post.php?post=$order_id&action=edit" ) . '">' . $fname . '</a>' );
}
break;

case 'date':
echo wp_date( 'm/d/Y H:i:s', strtotime( $item['date'] ) );
break;
Expand Down Expand Up @@ -185,6 +253,7 @@ function get_columns() {
'customer_id' => __( 'Customer Name', 'ultimate-sms-notifications' ),
'customer_registered_page' => __( 'Customer Registration Page', 'ultimate-sms-notifications' ),
'customer_consent' => __( 'Customer consent', 'ultimate-sms-notifications' ),
'order_related' => __( 'Order Related', 'ultimate-sms-notifications' ),
'date' => __( 'Date', 'ultimate-sms-notifications' ),
);

Expand All @@ -211,6 +280,8 @@ public function get_bulk_actions() {
*/
public function prepare_items() {

self::check_if_table_exists();

$this->_column_headers = $this->get_column_info();

/** Process bulk action */
Expand All @@ -225,7 +296,7 @@ public function prepare_items() {
'total_items' => $total_items, // WE have to calculate the total number of items.
'per_page' => $per_page, // WE have to determine how many items to show on a page.
)
);
);

$this->items = self::get_customers( $per_page, $current_page, true );
}
Expand Down
20 changes: 19 additions & 1 deletion admin/js/woo-usn-admin-cl.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@
return html;
};

var hs_generate_guest_customers_select_operators = function() {
var html = "<select name='customer-consent'><option class='woo-usn-operators' value='guest-customers'>Guest Customer</option></select>"
return html;
}

var hs_generate_consent_select_operators = function() {
var html = "<select name='customer-consent'><option class='woo-usn-operators' value='accepted'>ACCEPTED</option></select>"
return html;
}

var hs_generate_consent_html_operators = function() {
var html;
for (var option_name in woo_usn_ajax_object.woo_usn_cl_operators_names['woo-usn-consent-operators']) {
html += "<option class='woo-usn-consent-operators' value='" + option_name + "'>" + woo_usn_ajax_object.woo_usn_cl_operators_names['woo-usn-consent-operators'][option_name] + "</option>";
}
return html;
}


var hs_hide_show_fields = function ( cl_type_mode ){
var usn_add_btn = $('input#woousn_add_custom_filters');
if ( cl_type_mode == "dynamic" ){
Expand Down Expand Up @@ -172,10 +185,15 @@
break;

case '_customer_mobile_marketing':
woo_usn_field_options.empty().append(hs_generate_html_operators());
case '_guest_customer_mobile_marketing':
woo_usn_field_options.empty().append(hs_generate_consent_html_operators());
woo_usn_field_values.empty().attr('name', 'customer-consent').append(hs_generate_consent_select_operators())
break;

case '_customer_role':
woo_usn_field_options.empty().append(hs_generate_consent_html_operators());
woo_usn_field_values.empty().attr('name', 'customer-consent').append(hs_generate_guest_customers_select_operators())

default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion core/class-woo-usn-activator.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function activate()
$table_name = $wpdb->prefix . '_woousn_subscribers_list';
$charset_collate = $wpdb->get_charset_collate();
$rid = rand( 0, 500 );
$sql = "CREATE TABLE {$table_name} (id mediumint(20) DEFAULT '{$rid}' NOT NULL AUTO_INCREMENT,customer_id mediumint(255) NOT NULL UNIQUE,customer_consent text NOT NULL,customer_registered_page text NOT NULL,date datetime DEFAULT '2022-12-12 00:00:00' NOT NULL,PRIMARY KEY (id)) {$charset_collate};";
$sql = "CREATE TABLE {$table_name} (id mediumint(20) DEFAULT '{$rid}' NOT NULL AUTO_INCREMENT,customer_id mediumint(255) NOT NULL,customer_consent text NOT NULL,customer_registered_page text NOT NULL,customer_order_id VARCHAR(255),date datetime DEFAULT '2022-12-12 00:00:00' NOT NULL,PRIMARY KEY (id)) {$charset_collate};";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
add_option( 'woo_usn_subscribers_db_version', $woo_usn_db_subscribers_version );
Expand Down
11 changes: 3 additions & 8 deletions public/class-woo-usn-public.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,16 @@ public function get_customer_consent()
public function store_customer_consent( WC_Order $customer )
{
$sent_consent = filter_input( INPUT_POST, 'woo_usn_sms_consent' );
$consent = 'off';
// $consent = 'off';
$customer_id = $customer->get_customer_id();

if ( 'on' === $sent_consent ) {
update_user_meta( $customer_id, 'woo_usn_allow_sms_sending', $sent_consent );
$consent = $sent_consent;
}

update_user_meta( $customer_id, 'woo_usn_allow_sms_sending', $sent_consent );
global $wpdb ;
$table_name = $wpdb->prefix . '_woousn_subscribers_list';
$timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
//phpcs:disable
$wpdb->insert( $table_name, array(
'customer_id' => $customer_id,
'customer_consent' => $consent,
'customer_consent' => $sent_consent,
'customer_registered_page' => 'checkout',
'date' => date_i18n( $timezone_format, false, true ),
) );
Expand Down
6 changes: 6 additions & 0 deletions ui/class-woo-usn-ui-fields.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Woo_Usn_UI_Fields {
*/
public static function get_cl_rules_names() {
$list = array(
'_customer_role' => __( 'If customer', 'ultimate-sms-notifications' ),
'_completed_date' => __( 'If completed date is', 'ultimate-sms-notifications' ),
'_paid_date' => __( 'If paid date is', 'ultimate-sms-notifications' ),
'_payment_method' => __( 'If payment methods used', 'ultimate-sms-notifications' ),
Expand All @@ -24,6 +25,7 @@ public static function get_cl_rules_names() {
'_order_shipping' => __( 'If shipping amount', 'ultimate-sms-notifications' ),
'_order_shipping_tax' => __( 'If shipping amount (inc taxes)', 'ultimate-sms-notifications' ),
'_customer_mobile_marketing' => __( 'If customer mobile marketing consent', 'ultimate-sms-notifications' ),
'_guest_customer_mobile_marketing' => __( 'If guest customer mobile marketing consent', 'ultimate-sms-notifications' ),
);

return apply_filters( 'woo_usn_cl_rules_names', $list );
Expand All @@ -48,6 +50,10 @@ public static function get_cl_operators_names() {
'in' => __( 'IN', 'ultimate-sms-notifications' ),
'not-in' => __( 'NOT IN', 'ultimate-sms-notifications' ),
),
'woo-usn-consent-operators' => array(
'on' => __( 'is', 'ultimate-sms-notifications' ),
'off' => __( 'is not', 'ultimate-sms-notifications' ),
),
);

return apply_filters( 'woo_usn_cl_operators_names', $list );
Expand Down

0 comments on commit a989e85

Please sign in to comment.