Plugin Directory

Changeset 3089753


Ignore:
Timestamp:
05/21/2024 01:54:43 AM (23 months ago)
Author:
inspireui
Message:

version 4.14.1

Location:
mstore-api
Files:
486 added
7 edited

Legend:

Unmodified
Added
Removed
  • mstore-api/trunk/controllers/flutter-notification.php

    r3076227 r3089753  
    7474        $user = get_user_by('email', $email);
    7575        $user_id = $user->ID;
    76         $status = false;
    7776        $is_onesignal = $params->is_onesignal;
    7877        if($is_onesignal){
     
    8180        }
    8281        if (isset($is_manager)) {
    83             if ($is_manager) {
    84                 $deviceToken = get_user_meta($user_id, 'mstore_manager_device_token', true);
    85                 if ($deviceToken) {
    86                     $status = pushNotification("Fluxstore", "Test push notification", $deviceToken);
    87                 }
    88             }
    89             return ["deviceToken" => $deviceToken, 'status' => $status];
     82            pushNotificationForVendor($user_id, "Fluxstore", "Test push notification");
     83        }else if (isset($is_delivery)) {
     84             pushNotificationForDeliveryBoy($user_id, "Fluxstore", "Test push notification");
     85        }else {
     86            pushNotificationForUser($user_id, "Fluxstore", "Test push notification");
    9087        }
    91         if (isset($is_delivery)) {
    92             if ($is_delivery) {
    93                 $deviceToken = get_user_meta($user_id, 'mstore_delivery_device_token', true);
    94                 if ($deviceToken) {
    95                     $status = pushNotification("Fluxstore", "Test push notification", $deviceToken);
    96                 }
    97             }
    98             return ["deviceToken" => $deviceToken, 'status' => $status];
    99         }
    100         $deviceToken = get_user_meta($user_id, 'mstore_device_token', true);
    101         if ($deviceToken) {
    102             $status = pushNotification("Fluxstore", "Test push notification", $deviceToken);
    103         }
    104         return ["deviceToken" => $deviceToken, 'status' => $status];
     88        return [];
    10589    }
    10690
  • mstore-api/trunk/controllers/flutter-user.php

    r3080638 r3089753  
    11541154        $message = $params['message'];
    11551155
    1156         $deviceToken = get_user_meta($receiver->ID, 'mstore_device_token', true);
    1157         $manager_device_token = get_user_meta($receiver->ID, 'mstore_manager_device_token', true);
    1158         pushNotification($sender_name, $message, $deviceToken);
    1159         pushNotification($sender_name, $message, $manager_device_token);
     1156        pushNotificationForUser($receiver->ID, $sender_name, $message);
     1157        if (!is_plugin_active('onesignal-free-web-push-notifications/onesignal.php')) {//fix duplicate notification if onesignal
     1158            pushNotificationForVendor($receiver->ID, $sender_name, $message);
     1159        }
    11601160    }
    11611161
  • mstore-api/trunk/controllers/helpers/vendor-admin-wcfm-helper.php

    r3076227 r3089753  
    29302930            }
    29312931
    2932 
    2933             $noti_message = 'You have assigned to order '.$order_id.' item '. get_the_title($product_id);
    2934             $deviceToken = get_user_meta($wcfm_delivery_boy, 'mstore_delivery_device_token', true);
    2935             $title= '';
    2936             if (isset($deviceToken) && $deviceToken != false) {
    2937                 pushNotification("You have new notification", $noti_message, $deviceToken);
    2938             }
    29392932            // Notification Update
    29402933
  • mstore-api/trunk/functions/index.php

    r3086463 r3089753  
    9999}
    100100
    101 function pushNotification($title, $message, $deviceToken)
    102 {
    103     return FirebaseMessageHelper::push_notification($title, $message, $deviceToken);
    104 }
    105 
    106101function sendNotificationToUser($userId, $orderId, $previous_status, $next_status)
    107102{
    108103    $user = get_userdata($userId);
    109     $deviceToken = get_user_meta($userId, 'mstore_device_token', true);
    110104    $title = get_option("mstore_status_order_title");
    111105    if (!isset($title) || $title == false) {
     
    126120    $message = str_replace("{{nextStatus}}", $next_status_label, $message);
    127121
    128     if (is_plugin_active('onesignal-free-web-push-notifications/onesignal.php')) {
    129         _pushNotificationOneSignal($userId, $title, $message);
    130     } else {
    131         if (isset($deviceToken) && $deviceToken != false) {
    132             _pushNotificationFirebase($userId,$title, $message, $deviceToken);
    133         }
    134     }
     122    pushNotificationForUser($userId,$title, $message);
    135123}
    136124
     
    142130    $status = $order->get_status();
    143131    sendNewOrderNotificationToDelivery($id, $status);
     132}
     133
     134function _pushNotification($user_id, $title, $message, $meta_key, ){
     135    if (is_plugin_active('onesignal-free-web-push-notifications/onesignal.php')) {
     136        _pushNotificationOneSignal($title,$message, $user_id);
     137    } else {
     138        $deviceToken = get_user_meta($user_id, $meta_key, true);
     139        if (isset($deviceToken) && $deviceToken != false) {
     140            _pushNotificationFirebase($user_id,$title, $message, $deviceToken);
     141        }
     142    }
     143}
     144
     145function pushNotificationForDeliveryBoy($user_id, $title, $message){
     146    _pushNotification($user_id, $title, $message, 'mstore_delivery_device_token');
     147}
     148
     149function pushNotificationForVendor($user_id, $title, $message){
     150    _pushNotification($user_id, $title, $message, 'mstore_manager_device_token');
     151}
     152
     153function pushNotificationForUser($user_id, $title, $message){
     154     _pushNotification($user_id, $title, $message, 'mstore_device_token');
    144155}
    145156
     
    161172
    162173            foreach ($result as $item) {
    163                 $deviceToken = get_user_meta($item->delivery_boy, 'mstore_delivery_device_token', true);
    164                 if (isset($deviceToken) && $deviceToken != false) {
    165                     _pushNotificationFirebase($item->delivery_boy,$title, $message, $deviceToken);
    166                 }
    167                 _pushNotificationOneSignal($title,$message, $item->delivery_boy);
     174                pushNotificationForDeliveryBoy($item->delivery_boy, $title, $message);
    168175            }
    169176        }
     
    190197            );";
    191198            maybe_create_table($table_name, $sql);
    192             $deviceToken = get_user_meta($driver_id, 'mstore_delivery_device_token', true);
    193             if (isset($deviceToken) && $deviceToken != false) {
    194                 _pushNotificationFirebase($driver_id,$title, $message, $deviceToken);
    195                 $wpdb->insert($table_name, array(
    196                     'message' => $message,
    197                     'order_id' => $order_id,
    198                     'delivery_boy' => $driver_id,
    199                     'created' => current_time('mysql')
    200                 ));
    201             }
     199            pushNotificationForDeliveryBoy($driver_id, $title, $message);
     200            $wpdb->insert($table_name, array(
     201                'message' => $message,
     202                'order_id' => $order_id,
     203                'delivery_boy' => $driver_id,
     204                'created' => current_time('mysql')
     205            ));
    202206        }
    203207    }
     
    216220    }
    217221    $message = str_replace("{{name}}", $user->display_name, $message);
    218     $deviceToken = get_user_meta($order_seller_id, 'mstore_device_token', true);
    219     if (isset($deviceToken) && $deviceToken != false) {
    220         _pushNotificationFirebase($order_seller_id,$title, $message, $deviceToken);
    221     }
    222     $managerDeviceToken = get_user_meta($order_seller_id, 'mstore_manager_device_token', true);
    223     if (isset($managerDeviceToken) && $managerDeviceToken != false) {
    224         _pushNotificationFirebase($order_seller_id,$title, $message, $managerDeviceToken);
    225         if (is_plugin_active('wc-multivendor-marketplace/wc-multivendor-marketplace.php')) {
    226             wcfm_message_on_new_order($order_id);
    227         }
    228     }
    229     _pushNotificationOneSignal($order_seller_id,$title, $message);
     222    pushNotificationForUser($order_seller_id, $title, $message);
     223    if (!is_plugin_active('onesignal-free-web-push-notifications/onesignal.php')) {//fix duplicate notification if onesignal
     224        pushNotificationForVendor($order_seller_id, $title, $message);
     225    }
     226    if (is_plugin_active('wc-multivendor-marketplace/wc-multivendor-marketplace.php')) {
     227        wcfm_message_on_new_order($order_id);
     228    }
    230229}
    231230
     
    783782        $message = str_replace("{{order}}", $order_id, $message);
    784783   
    785         $managerDeviceToken = get_user_meta($seller_id, 'mstore_manager_device_token', true);
    786         if (isset($managerDeviceToken) && $managerDeviceToken != false) {
    787             _pushNotificationFirebase($seller_id, $title, $message, $managerDeviceToken);
    788         }
    789         _pushNotificationOneSignal($seller_id,$title, $message);
     784        pushNotificationForVendor($seller_id, $title, $message);
    790785    }
    791786}
     
    794789    $is_on = isNotificationEnabled($user_id);
    795790    if($is_on){
    796         pushNotification($title, $message, $deviceToken);
     791        FirebaseMessageHelper::push_notification($title, $message, $deviceToken);
    797792    }
    798793}
     
    877872    $response = addQRCodeUrlToMetaResponse($response);
    878873
     874    if(function_exists( 'wcfm_is_order_delivered' ) ) {
     875        $is_order_delivered = wcfm_is_order_delivered( $response->data['id'] );
     876        $response->data['delivery_status'] = $is_order_delivered ? 'delivered' : 'pending';
     877    }
     878   
    879879    return $response;
    880880}
  • mstore-api/trunk/mstore-api.php

    r3086463 r3089753  
    44 * Plugin URI: https://github.com/inspireui/mstore-api
    55 * Description: The MStore API Plugin which is used for the FluxBuilder and FluxStore Mobile App
    6  * Version: 4.14.0
     6 * Version: 4.14.1
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    5656class MstoreCheckOut
    5757{
    58     public $version = '4.13.6';
     58    public $version = '4.14.1';
    5959
    6060    public function __construct()
     
    207207        add_action('woocommerce_rest_insert_shop_order_object', array($this, 'track_api_new_order'), 10, 4);
    208208
     209        //WCFM - WooCommerce Frontend Manager - Delivery
     210        //Handle listen to assign delivery boy on the website
     211        add_action( 'wcfmd_after_delivery_boy_assigned', array($this, 'track_delivery_boy_assigned'), 400, 6 );
     212
    209213        $path = get_template_directory() . "/templates";
    210214        if (!file_exists($path)) {
     
    362366            }
    363367        }
     368    }
     369
     370    function track_delivery_boy_assigned( $order_id, $order_item_id, $wcfm_tracking_data, $product_id, $wcfm_delivery_boy, $wcfm_messages ) {
     371        $notification_message = strip_tags($wcfm_messages);
     372        $title = "You have new notification";
     373        pushNotificationForDeliveryBoy($wcfm_delivery_boy, $title, $notification_message);
    364374    }
    365375
  • mstore-api/trunk/readme.txt

    r3086464 r3089753  
    44Requires at least: 4.4
    55Tested up to:      6.5.3
    6 Stable tag:        4.14.0
     6Stable tag:        4.14.1
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.14.1 =
     52  * Support to push notification to delivery boy when order is assigned
     53
    5154= 4.14.0 =
    5255  * Upgrade Filter function
  • mstore-api/trunk/templates/admin/mstore-api-admin-dashboard.php

    r3076227 r3089753  
    7777        <div class="form-group" style="margin-top:10px;margin-bottom:40px">
    7878            <input type="number" data-nonce="<?php echo wp_create_nonce('update_limit_product'); ?>" value="<?php echo (!isset($limit) || $limit == false) ? 10 : esc_attr($limit) ?>"
    79                    class="mstore-input-class">
     79                   class="mstore-input-class mstore-update-limit-product">
    8080        </div>
    8181    </form>
     
    135135        }
    136136        ?>
    137         <input type="text" class="mstore-input-class" placeholder="Title" data-nonce="<?php echo wp_create_nonce('update_new_order_title'); ?>" value="<?php echo esc_attr($newOrderTitle); ?>">
     137        <input type="text" class="mstore-input-class mstore-update-new-order-title" placeholder="Title" data-nonce="<?php echo wp_create_nonce('update_new_order_title'); ?>" value="<?php echo esc_attr($newOrderTitle); ?>">
    138138        <div class="form-group" style="margin-top:10px;margin-bottom:40px">
    139139            <textarea placeholder="Message" data-nonce="<?php echo wp_create_nonce('update_new_order_message'); ?>" class="mstore-update-new-order-message mstore-input-class"
Note: See TracChangeset for help on using the changeset viewer.