Plugin Directory

Changeset 3306788


Ignore:
Timestamp:
06/05/2025 02:10:03 AM (10 months ago)
Author:
inspireui
Message:

version 4.17.7

Location:
mstore-api
Files:
496 added
8 edited

Legend:

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

    r3246917 r3306788  
    127127                'methods' => "GET",
    128128                'callback' => array($this, 'flutter_get_reviews'),
     129                'permission_callback' => array($this, 'allow_permissions'),
     130            ),
     131        ));
     132
     133        register_rest_route($this->namespace, '/follow-vendor-status', array(
     134            array(
     135                'methods' => "POST",
     136                'callback' => array($this, 'follow_vendor_status'),
     137                'permission_callback' => array($this, 'allow_permissions'),
     138            ),
     139        ));
     140
     141        register_rest_route($this->namespace, '/toggle-follow-vendor', array(
     142            array(
     143                'methods' => "POST",
     144                'callback' => array($this, 'toggle_follow_vendor'),
    129145                'permission_callback' => array($this, 'allow_permissions'),
    130146            ),
     
    238254        return $vendor->flutter_get_reviews($request);
    239255    }
     256
     257    public function follow_vendor_status($request)
     258    {
     259        $request["cookie"] = get_header_user_cookie($request->get_header("User-Cookie"));
     260        $vendor = new FlutterWCFMHelper();
     261        return $vendor->follow_vendor_status($request);
     262    }
     263
     264    public function toggle_follow_vendor($request)
     265    {
     266        $request["cookie"] = get_header_user_cookie($request->get_header("User-Cookie"));
     267        $vendor = new FlutterWCFMHelper();
     268        return $vendor->toggle_follow_vendor($request);
     269    }
    240270}
    241271
  • mstore-api/trunk/controllers/flutter-user.php

    r3279132 r3306788  
    270270            ),
    271271        ));
    272        
     272
    273273        register_rest_route($this->namespace, '/digits/login', array(
    274274            array(
     
    411411            $wcfm_membership_application_status = $params['wcfm_membership_application_status'];
    412412        }
    413    
     413
    414414        $username = sanitize_user($usernameReq);
    415415        $email = sanitize_email($emailReq);
     
    572572        }
    573573        $is_driver_available = false;
    574         if(is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')){
    575             $is_driver_available = get_user_meta( $user->ID, 'ddwc_driver_availability', true );
    576         }else{
     574
     575        if(is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')){
     576            $is_driver_available = get_user_meta($user->ID, 'lddfw_driver_availability', true);
     577        }
     578        else if(is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') ||
     579                is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')){
     580            $is_driver_available = get_user_meta($user->ID, 'ddwc_driver_availability', true);
     581        }
     582        else{
    577583            $is_driver_available = in_array('administrator',$user->roles) || in_array('wcfm_delivery_boy',$user->roles);
    578584        }
     
    584590        if (is_plugin_active('dokan-lite/dokan.php') || is_plugin_active('dokan-pro/dokan-pro.php')) {
    585591            $dokan_settings = get_option('dokan_selling');
    586             $order_status_change = isset($dokan_settings['order_status_change']) ? 
     592            $order_status_change = isset($dokan_settings['order_status_change']) ?
    587593                filter_var($dokan_settings['order_status_change'], FILTER_VALIDATE_BOOLEAN) : false;
    588594        }
     
    593599            $order_status_change = $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability($user->ID, 'order_status_update');
    594600        }
    595        
     601
    596602        // If user is admin, always allow order status change
    597603        if (in_array('administrator', $user->roles)) {
     
    12831289                $_POST[$post_index] = '1';
    12841290            }
    1285            
     1291
    12861292        }
    12871293        $_REQUEST['json'] = 1;
     
    12941300    function digits_register_check()
    12951301    {
    1296         if(!function_exists('digits_create_user')) { 
     1302        if(!function_exists('digits_create_user')) {
    12971303            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    12981304        }
     
    13271333        if ($mobuser != null  || username_exists($mob)) {
    13281334            return parent::sendError("existed_mobile", 'Mobile Number already in use!', 400);
    1329         } 
     1335        }
    13301336
    13311337        return  true;
     
    13341340    function digits_register()
    13351341    {
    1336         if(!function_exists('digits_create_user')) { 
     1342        if(!function_exists('digits_create_user')) {
    13371343            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    13381344        }
     
    13661372    function digits_login_check()
    13671373    {
    1368         if(!function_exists('digits_create_user')) { 
     1374        if(!function_exists('digits_create_user')) {
    13691375            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    13701376        }
     
    13851391        if ($mobuser == null) {
    13861392            return parent::sendError("not_existed_mobile", 'Phone number is not registered!', 400);
    1387         } 
     1393        }
    13881394
    13891395        return  true;
     
    13921398    function digits_login()
    13931399    {
    1394         if(!function_exists('dig_validateMobileNumber')) { 
     1400        if(!function_exists('dig_validateMobileNumber')) {
    13951401            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    13961402        }
    13971403
    13981404        $this->mstore_digrest_set_variables();
    1399    
     1405
    14001406        $otp = $_POST['dig_otp'];
    14011407        $validateMob = dig_validateMobileNumber($_POST['digregcode'], $_POST['digits_reg_mail'], $otp, null, 1, null, false);
    1402    
     1408
    14031409        if ($validateMob['success'] === false) {
    14041410            return parent::sendError("invalid_data",$validateMob['msg'], 400);
    14051411        }
    1406    
     1412
    14071413        $user = getUserFromPhone($validateMob['countrycode'] . $validateMob['mobile']);
    14081414        $cookie = generateCookieByUserId($user->ID);
     
    14161422    function digits_send_otp()
    14171423    {
    1418         if(!function_exists('digits_create_user')) { 
     1424        if(!function_exists('digits_create_user')) {
    14191425            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    14201426        }
     
    14341440        $_REQUEST['mobileNo'] =  $params['mobile'];
    14351441        $_REQUEST['type'] =  $params['type'];
    1436    
     1442
    14371443        $this->mstore_digrest_set_variables();
    1438    
    1439    
     1444
     1445
    14401446        $_REQUEST['csrf'] = wp_create_nonce('dig_form');
    14411447        $_POST['csrf'] = wp_create_nonce('dig_form');
    1442    
     1448
    14431449        do_action('wp_ajax_nopriv_digits_check_mob');
    14441450    }
     
    14461452    function digits_resend_otp()
    14471453    {
    1448         if(!function_exists('digits_resendotp')) { 
     1454        if(!function_exists('digits_resendotp')) {
    14491455            return parent::sendError("plugin_not_found", "Please install  the  DIGITS: Wordpress Mobile Number Signup and Login  plugin", 400);
    14501456        }
     
    14641470        $_REQUEST['mobileNo'] =  $params['mobile'];
    14651471        $_REQUEST['type'] =  $params['type'];
    1466    
     1472
    14671473        $this->mstore_digrest_set_variables();
    1468    
    1469    
     1474
     1475
    14701476        $_REQUEST['csrf'] = wp_create_nonce('dig_form');
    14711477        $_POST['csrf'] = wp_create_nonce('dig_form');
    1472    
     1478
    14731479        digits_resendotp();
    14741480    }
    14751481
    1476    
     1482
    14771483    function custom_delete_item_permissions_check($request)
    14781484    {
  • mstore-api/trunk/controllers/flutter-vendor-admin.php

    r3277790 r3306788  
    275275                    ];
    276276                }
    277        
     277
    278278                return new WP_REST_Response(
    279279                    [
     
    301301                $order_id = sanitize_text_field($request["wcfm_tracking_order_id"]);
    302302                $delivery_boy = sanitize_text_field($request["wcfm_delivery_boy"]);
    303                 $meta_key   = 'ddwc_driver_id';
     303
     304                if (is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')) {
     305                    $meta_key = 'lddfw_driverid';
     306                }
     307                else if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
     308                    $meta_key = 'ddwc_driver_id';
     309                }
     310                else {
     311                    return parent::sendError("invalid_plugin", "No delivery plugin found", 400);
     312                }
    304313
    305314                // Update driver ID for order.
    306                 update_post_meta( $order_id, $meta_key, $delivery_boy );
     315                update_post_meta($order_id, $meta_key, $delivery_boy);
    307316
    308317                // Get order.
    309                 $order = new WC_Order( $order_id );
     318                $order = new WC_Order($order_id);
    310319                // Update order status.
    311                 $order->update_status( 'driver-assigned' );
     320                $order->update_status('driver-assigned');
    312321                return new WP_REST_Response(
    313322                    [
     
    577586                $data['default'] = true;
    578587                $attributes[] = $data;
    579                
     588
    580589            }
    581590        }
  • mstore-api/trunk/controllers/helpers/delivery-woo-helper.php

    r2989540 r3306788  
    5555        $total = 0;
    5656
    57         if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')) {
     57        if (is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')) {
     58            global $wpdb;
     59            $table_1 = "{$wpdb->prefix}posts";
     60            $table_2 = "{$wpdb->prefix}postmeta";
     61            $sql = "SELECT ID FROM {$table_1} INNER JOIN {$table_2} ON {$table_1}.ID = {$table_2}.post_id";
     62            $sql .= " WHERE `{$table_2}`.`meta_key` = 'lddfw_driverid' AND `{$table_2}`.`meta_value` = %s";
     63            $sql .= " AND `{$table_1}`.`post_type` = 'shop_order'";
     64
     65            $total = count($wpdb->get_results($wpdb->prepare($sql, $user_id)));
     66            $sql .= " AND {$table_1}.post_status = 'wc-completed'";
     67            $delivered_count = count($wpdb->get_results($wpdb->prepare($sql, $user_id)));
     68            $sql = "SELECT ID FROM {$table_1} INNER JOIN {$table_2} ON {$table_1}.ID = {$table_2}.post_id";
     69            $sql .= " WHERE `{$table_2}`.`meta_key` = 'lddfw_driverid' AND `{$table_2}`.`meta_value` = %s";
     70            $sql .= " AND `{$table_1}`.`post_type` = 'shop_order'";
     71            $sql .= " AND {$table_1}.post_status != 'wc-completed'";
     72            $pending_count = count($wpdb->get_results($wpdb->prepare($sql, $user_id)));
     73        }
     74        else if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
    5875            global $wpdb;
    5976            $table_1 = "{$wpdb->prefix}posts";
     
    89106            $order_id = sanitize_text_field($order_id);
    90107            if(is_numeric($order_id)){
    91                 if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')) {
     108                if (is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
    92109                    $order = wc_get_order($order_id);
    93110                    return new WP_REST_Response(array(
     
    132149        $api = new WC_REST_Orders_V1_Controller();
    133150        $results = [];
    134         if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')) {
     151        if (is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')) {
     152            $page = 1;
     153            $per_page = 10;
     154            if (isset($request['page'])) {
     155                $page = sanitize_text_field($request['page']);
     156                if(!is_numeric($page)){
     157                    $page = 1;
     158                }
     159            }
     160            if (isset($request['per_page'])) {
     161                $per_page = sanitize_text_field($request['per_page']);
     162                if(!is_numeric($per_page)){
     163                    $per_page = 10;
     164                }
     165            }
     166            $page = ($page - 1) * $per_page;
     167            global $wpdb;
     168
     169            $table_1 = "{$wpdb->prefix}posts";
     170            $table_2 = "{$wpdb->prefix}postmeta";
     171            $sql = "SELECT ID FROM {$table_1} INNER JOIN {$table_2} ON {$table_1}.ID = {$table_2}.post_id";
     172            $sql .= " WHERE `{$table_2}`.`meta_key` = 'lddfw_driverid' AND `{$table_2}`.`meta_value` = {$user_id}";
     173            if (isset($request['status']) && !empty($request['status'])) {
     174                $status = sanitize_text_field($request['status']);
     175                if ($status == 'pending') {
     176                    $sql .= " AND (`{$table_1}`.`post_status` = 'wc-driver-assigned' OR `{$table_1}`.`post_status` = 'wc-out-for-delivery' OR `{$table_1}`.`post_status` = 'wc-processing')";
     177                }
     178                if ($status == 'delivered') {
     179                    $sql .= " AND `{$table_1}`.`post_status` = 'wc-completed'";
     180                }
     181            } else {
     182                $sql .= " AND (`{$table_1}`.`post_status` = 'wc-driver-assigned' OR `{$table_1}`.`post_status` = 'wc-out-for-delivery' OR `{$table_1}`.`post_status` = 'wc-completed' OR `{$table_1}`.`post_status` = 'wc-processing')";
     183            }
     184            if (isset($request['search'])) {
     185                $order_search = sanitize_text_field($request['search']);
     186                $sql .= " AND $table_1.`ID` LIKE %s";
     187            }
     188            $sql .= " AND `{$table_1}`.`post_type` = 'shop_order'";
     189            $sql .= " GROUP BY $table_1.`ID` ORDER BY $table_1.`ID` DESC LIMIT %d OFFSET %d";
     190
     191            if(isset($order_search)){
     192                $sql = $wpdb->prepare($sql, '%'.$order_search.'%', $per_page, $page);
     193            }else{
     194                $sql = $wpdb->prepare($sql, $per_page, $page);
     195            }
     196
     197            $items = $wpdb->get_results($sql);
     198            foreach ($items as $item) {
     199                $order = wc_get_order($item);
     200                if (is_bool($order)) {
     201                    continue;
     202                }
     203                $response = $api->prepare_item_for_response($order, $request);
     204                $order = $response->get_data();
     205                $count = count($order['line_items']);
     206                $order['product_count'] = $count;
     207                for ($i = 0; $i < $count; $i++) {
     208                    $product_id = absint($order['line_items'][$i]['product_id']);
     209                    $image = wp_get_attachment_image_src(get_post_thumbnail_id($product_id));
     210                    if (!is_null($image[0])) {
     211                        $order['line_items'][$i]['featured_image'] = $image[0];
     212                    }
     213                }
     214                $order['delivery_status'] = 'delivered';
     215                if ($order['status'] != 'completed') {
     216                    $order['delivery_status'] = 'pending';
     217                }
     218                $results[] = $order;
     219            }
     220        }
     221        else if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
    135222            $page = 1;
    136223            $per_page = 10;
     
    177264                $sql = $wpdb->prepare($sql, $per_page, $page);
    178265            }
    179            
     266
    180267            $items = $wpdb->get_results($sql);
    181268            foreach ($items as $item) {
     
    314401
    315402
    316     function set_off_time($user_id, $is_available){
    317         if(is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')){
    318             $new_value = 'on';
    319             $old_value = '';
    320             if($is_available !== 'true'){
    321                 $new_value = '';
    322                 $old_value = 'on';
    323             }           
    324             // Update driver availability.
    325             update_user_meta( $user_id, 'ddwc_driver_availability', $new_value, $old_value );
    326             $meta_value = get_user_meta( $user_id, 'ddwc_driver_availability', true );
    327                 return new WP_REST_Response(array(
     403    function set_off_time($user_id, $is_available)
     404    {
     405        if(is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')) {
     406            $new_value = '1';  // Available
     407            $old_value = '0';
     408            if ($is_available !== 'true') {
     409                $new_value = '0';  // Unavailable
     410                $old_value = '1';
     411            }
     412            // Update driver availability.
     413            update_user_meta($user_id, 'lddfw_driver_availability', $new_value, $old_value);
     414
     415            // Clear any cached data
     416            lddfw_delete_cache('driver', $user_id);
     417
     418            $meta_value = get_user_meta($user_id, 'lddfw_driver_availability', true);
     419            return new WP_REST_Response(array(
    328420                'status' => 'success',
    329421                'response' => $meta_value,
    330422            ), 200);
    331         }
     423        } else if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
     424            $new_value = 'on';
     425            $old_value = '';
     426            if($is_available !== 'true'){
     427                $new_value = '';
     428                $old_value = 'on';
     429            }
     430            // Update driver availability.
     431            update_user_meta($user_id, 'ddwc_driver_availability', $new_value, $old_value);
     432            $meta_value = get_user_meta($user_id, 'ddwc_driver_availability', true);
     433            return new WP_REST_Response(array(
     434                'status' => 'success',
     435                'response' => $meta_value,
     436            ), 200);
     437        }
    332438        return new WP_REST_Response(array(
    333439            'status' => 'unknown-error',
    334             'response' => '',       
     440            'response' => '',
    335441        ), 400);
    336     }
     442    }
    337443}
    338    
     444
  • mstore-api/trunk/controllers/helpers/vendor-wcfm.php

    r3132501 r3306788  
    266266
    267267        $wcfm_vendors_json_arr['shop_url'] = wcfmmp_get_store_url($vendor_id);
     268
     269        $wcfm_min_order_amt = get_user_meta($vendor_id, '_wcfm_min_order_amt', true);
     270        if ($wcfm_min_order_amt) {
     271            $wcfm_vendors_json_arr['min_order_amt'] = $wcfm_min_order_amt;
     272        }
     273
     274        // Live Chat module
     275        if (class_exists('WCFM_Dependencies')) {
     276            $wcfm_vendors_json_arr['enable_chat'] = WCFM_Dependencies::wcfmu_plugin_active_check() // WCFM Marketplace Ultimate plugin check
     277                && apply_filters('wcfm_is_allow_chatbox', true) // Capability Settings
     278                && apply_filters('wcfm_is_pref_chatbox', true) // Module Controller
     279                && $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability($vendor_id, 'chatbox'); // Vendor Capability
     280        }
    268281
    269282        return $wcfm_vendors_json_arr;
     
    12571270        return $data;
    12581271    }
     1272
     1273    public function follow_vendor_status($request)
     1274    {
     1275        if (!is_plugin_active('wc-frontend-manager-ultimate/wc_frontend_manager_ultimate.php')) {
     1276            return new WP_Error("invalid_plugin", "You need to install WCFM Ultimate plugin to use this api", array('status' => 403));
     1277        }
     1278
     1279        $cookie = $request["cookie"];
     1280        if (isset($request["token"])) {
     1281            $cookie = urldecode(base64_decode($request["token"]));
     1282        }
     1283
     1284        $user_id = validateCookieLogin($cookie);
     1285        if (is_wp_error($user_id)) {
     1286            return $user_id;
     1287        }
     1288
     1289        $vendor_id = $request['vendor_id'];
     1290
     1291        $is_following       = false;
     1292        $user_following_arr = get_user_meta($user_id, '_wcfm_following_list', true);
     1293        if ($user_id == $vendor_id) {
     1294            $is_following = true;
     1295        }
     1296
     1297        if ($user_following_arr && is_array($user_following_arr) && in_array($vendor_id, $user_following_arr)) {
     1298            $is_following = true;
     1299        }
     1300
     1301        return $is_following;
     1302    }
     1303
     1304    public function toggle_follow_vendor($request)
     1305    {
     1306        if (!is_plugin_active('wc-frontend-manager-ultimate/wc_frontend_manager_ultimate.php')) {
     1307            return new WP_Error("invalid_plugin", "You need to install WCFM Ultimate plugin to use this api", array('status' => 403));
     1308        }
     1309
     1310        global $WCFMu;
     1311
     1312        $cookie = $request["cookie"];
     1313        if (isset($request["token"])) {
     1314            $cookie = urldecode(base64_decode($request["token"]));
     1315        }
     1316
     1317        $user_id = validateCookieLogin($cookie);
     1318        if (is_wp_error($user_id)) {
     1319            return $user_id;
     1320        }
     1321
     1322        $_REQUEST['wcfm_ajax_nonce'] = wp_create_nonce('wcfm_ajax_nonce');
     1323
     1324        $is_following = $this->follow_vendor_status($request);
     1325        if ($is_following) {
     1326            $_POST["followersid"] = $user_id;
     1327            $_POST["userid"] = $request['vendor_id'];
     1328            $WCFMu->wcfmu_vendor_followers->wcfmu_vendors_followings_delete();
     1329        } else {
     1330            $_POST["user_id"] = $user_id;
     1331            $_POST["vendor_id"] = $request['vendor_id'];
     1332            $WCFMu->wcfmu_vendor_followers->wcfmu_vendors_followers_update();
     1333        }
     1334    }
    12591335}
  • mstore-api/trunk/functions/index.php

    r3293669 r3306788  
    3333    $body = json_decode($body, true);
    3434
    35     delete_option('mstore_purchase_code'); // remove old key to  fix duplicate re-verify 
     35    delete_option('mstore_purchase_code'); // remove old key to  fix duplicate re-verify
    3636
    3737    if ($success) {
     
    4040        update_option("mstore_purchase_code_key", $code);
    4141    } else {
    42         delete_option('mstore_purchase_code_key'); // remove old key to  fix duplicate re-verify 
     42        delete_option('mstore_purchase_code_key'); // remove old key to  fix duplicate re-verify
    4343        return $body["message"] ??  $body["error"];
    4444    }
     
    4747
    4848
    49 function one_signal_push_notification($title = '', $message = '', $user_ids = array()) {   
     49function one_signal_push_notification($title = '', $message = '', $user_ids = array()) {
    5050    if(!is_plugin_active('onesignal-free-web-push-notifications/onesignal.php')){
    5151        return false;
     
    6666        "en" => $title
    6767    );
    68    
     68
    6969    $external_ids = array();
    7070    foreach($user_ids as $id){
     
    112112    $previous_status_label = wc_get_order_status_name( $previous_status );
    113113    $next_status_label = wc_get_order_status_name( $next_status );
    114    
     114
    115115    if($user && $user->display_name){
    116116        $message = str_replace("{{name}}", $user->display_name, $message);
     
    176176            }
    177177        }
    178 
    179     }
    180 
    181     if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php')) {
     178    }
     179
     180    if (is_plugin_active('local-delivery-drivers-for-woocommerce/local-delivery-drivers-for-woocommerce.php')) {
     181        $order = wc_get_order($order_id);
     182        $driver_id = $order->get_meta('lddfw_driverid');
     183        if ($driver_id) {
     184            global $WCFM, $wpdb;
     185            // include upgrade-functions for maybe_create_table;
     186            if (!function_exists('maybe_create_table')) {
     187                require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     188            }
     189            $table_name = $wpdb->prefix . 'delivery_woo_notification';
     190            $sql = "CREATE TABLE " . $table_name . "(
     191            id mediumint(9) NOT NULL AUTO_INCREMENT,
     192            message text NOT NULL,
     193            order_id text NOT NULL,
     194            delivery_boy text NOT NULL,
     195            created datetime NOT NULL,
     196            UNIQUE KEY id (id)
     197            );";
     198            maybe_create_table($table_name, $sql);
     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            ));
     206        }
     207    }
     208    else if (is_plugin_active('delivery-drivers-for-woocommerce/delivery-drivers-for-woocommerce.php') || is_plugin_active('delivery-drivers-for-woocommerce-master/delivery-drivers-for-woocommerce.php')) {
    182209        $order = wc_get_order($order_id);
    183210        $driver_id = $order->get_meta('ddwc_driver_id');
     
    431458            'value' => $hide_on_single,
    432459        );
    433        
     460
    434461        $response->data['meta_data'] = $meta_data;
    435462    }
    436463    return $response;
     464}
     465
     466function normalizeRestrictedDays($restrictedDays) {
     467    if (is_array($restrictedDays)) {
     468        $normalized = new stdClass();
     469        foreach ($restrictedDays as $day) {
     470            $normalized->$day = $day;
     471        }
     472        return $normalized;
     473    } elseif (is_object($restrictedDays)) {
     474        return $restrictedDays;
     475    } elseif (is_string($restrictedDays) && $restrictedDays === "") {
     476        return new stdClass();
     477    }
     478    return $restrictedDays;
    437479}
    438480
     
    470512        $response->data['sale_price'] = null;
    471513    }
    472    
     514
    473515    if (!empty($woocommerce_wpml->multi_currency) && !empty($woocommerce_wpml->settings['currencies_order'])) {
    474516
     
    493535            $response->data['min_price'] = wc_get_price_to_display(  $product, array( 'price' => $product->get_variation_price() ) );
    494536            $response->data['max_price'] = wc_get_price_to_display(  $product, array( 'price' => $product->get_variation_price('max') ) );
    495            
     537
    496538            if(!$response->data['min_price']){
    497539                $response->data['min_price'] = '0';
     
    515557                $response->data['variation_products'] = $variation_arr;
    516558            }
    517            
     559
    518560        }
    519561    }
     
    537579                    return ['name'=>$v, 'slug' => $v];
    538580                },$attr["options"]) : $attrOptions;
    539                
     581
    540582                $is_image_type = $is_image_type == true && class_exists( 'Woo_Variation_Swatches_Frontend' );
    541583                if ($is_image_type) {
     
    548590                                $term['image_url'] = esc_url( $image[0] );
    549591                                return $term;
    550                             }   
     592                            }
    551593                        }
    552594                        return $item;
    553595                    },$attrOptions);
    554596                }
    555                
     597
    556598                $attributesData[] = array_merge($attr->get_data(), ["label" => $label, "name" => urldecode($key), 'is_image_type' => $is_image_type], ['options' =>$attrOptions]);
    557599            }
     
    559601        $response->data['attributesData'] = $attributesData;
    560602    }
    561    
    562    
     603
     604
    563605    // /* Product Add On */
    564606    if(class_exists('WC_Product_Addons_Helper')){
     
    610652            $response->data['appointment_duration'] = $product->get_duration();
    611653            $response->data['appointment_duration_unit'] = $product->get_duration_unit();
     654            $response->data['has_staff'] = $product->has_staff() ? true : false;
     655            $response->data['has_restricted_days'] = $product->has_restricted_days() ? true : false;
     656            $response->data['restricted_days'] = normalizeRestrictedDays($product->get_restricted_days());
    612657        }
    613658    }
     
    627672        }
    628673    }
    629    
     674
    630675    /* TeraWallet */
    631676    if ( class_exists( 'WooWallet' ) ) {
    632677        $response->data['is_wallet_product'] =  get_option( '_woo_wallet_recharge_product' ) == (string) $response->data['id'];
    633678    }
    634    
     679
    635680    /* YITH WooCommerce Barcodes and QR Codes Premium */
    636681    $response = addQRCodeUrlToMetaResponse($response);
     
    665710    }
    666711
     712    // Check if woo-discount-rules is active
     713    if (class_exists('Wdr\App\Controllers\ManageDiscount')) {
     714        // Get the discounted price using the plugin's API
     715        $prices = \Wdr\App\Controllers\ManageDiscount::calculateProductDiscountPrice(false,$product, 1, 0, 'all', true, false);
     716        $apply_as_cart_rule = isset($prices['apply_as_cart_rule']) ? $prices['apply_as_cart_rule'] : array('no');
     717        if(empty($apply_as_cart_rule) || in_array('no', $apply_as_cart_rule)){
     718            $discounted_price = isset($prices['discounted_price']) ? $prices['discounted_price'] : 0;
     719            if(!empty($discounted_price)){
     720                $response->data['price'] = wc_get_price_to_display($product, array('price' => $discounted_price));
     721                $response->data['on_sale'] = true;
     722
     723                $meta_data = $response->data['meta_data'];
     724                $meta_data[] = new WC_Meta_Data(
     725                    array(
     726                        'key'   =>'_wdr_simple_discount',
     727                        'value' => $discounted_price,
     728                    )
     729                );
     730                $response->data['meta_data'] = $meta_data;
     731            }
     732        }
     733    }
     734
    667735    $blackListKeys = ['yoast_head','yoast_head_json','_links'];
    668736    $response->data = array_diff_key($response->data,array_flip($blackListKeys));
     
    684752    if (!is_array($term_ids)) {
    685753        $term_ids = [$term_ids];
     754    }
     755
     756    if (empty($term_ids)) {
     757        return [];
    686758    }
    687759
     
    872944        }
    873945    }else{
    874         $users_query = new WP_User_Query( array( 
    875                     'role' => 'Administrator', 
     946        $users_query = new WP_User_Query( array(
     947                    'role' => 'Administrator',
    876948                    'fields' => 'ID'
    877949                    ));
     
    901973        $message = str_replace("{{name}}", $user->display_name, $message);
    902974        $message = str_replace("{{order}}", $order_id, $message);
    903    
     975
    904976        pushNotificationForVendor($seller_id, $title, $message);
    905977    }
     
    9421014            if( $commission ) {
    9431015                $vendorEarnings = (float) $commission;
    944        
     1016
    9451017                $gross_sales  = (float) $order->get_total();
    9461018                $total_refund = (float) $order->get_total_refunded();
     
    9961068        $response->data['delivery_status'] = $is_order_delivered ? 'delivered' : 'pending';
    9971069    }
    998    
     1070
    9991071    return $response;
    10001072}
     
    10151087            }
    10161088        }
    1017     }   
     1089    }
    10181090}
    10191091
     
    10491121                    $_POST = $addons;
    10501122                }
    1051                
     1123
    10521124                // Check the product variation
    10531125                if (!empty($variationId)) {
  • mstore-api/trunk/mstore-api.php

    r3293669 r3306788  
    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.17.6
     6 * Version: 4.17.7
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    5555include_once plugin_dir_path(__FILE__) . "controllers/flutter-points-offline-store.php";
    5656include_once plugin_dir_path(__FILE__) . "controllers/flutter-smart-cod.php";
     57include_once plugin_dir_path(__FILE__) . "controllers/flutter-discount-rules.php";
    5758
    5859if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
     
    6263class MstoreCheckOut
    6364{
    64     public $version = '4.17.6';
     65    public $version = '4.17.7';
    6566
    6667    public function __construct()
     
    645646    ]);
    646647
    647     $response->data['terms'] = $options;
    648 
    649648    // Get list count of attribute terms based on attribute.
    650649    $terms = get_filtered_term_product_counts($request, $taxonomy);
     
    653652    // Show this attribute if any attribute terms have product quantity > 0
    654653    foreach ($terms as $key => $term) {
    655         if ($term['term_count'] > 0) {
     654        $count = (int)$term['term_count'];
     655        if ($is_visible == false && $count > 0) {
    656656            $is_visible = true;
    657             break;
    658         }
    659     }
     657        }
     658        // Update term count for options
     659        foreach ($options as $option) {
     660            if ($option->term_id == $term['term_count_id']) {
     661                $option->count = $count;
     662                break;
     663            }
     664        }
     665    }
     666
     667    $response->data['terms'] = $options;
    660668
    661669    $response->data['is_visible'] = $is_visible;
  • mstore-api/trunk/readme.txt

    r3293669 r3306788  
    33Tags:              flutter, app builder, app creator, mobile app builder, woocommerce app
    44Requires at least: 4.4
    5 Tested up to:      6.8.0
    6 Stable tag:        4.17.6
     5Tested up to:      6.8.1
     6Stable tag:        4.17.7
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.17.7 =
     52  * Implement discount rules
     53  * support show/hide chat module as per vendor
     54  * add get follow vendor status api
     55  * add toggle follow vendor api
     56
    5157= 4.17.6 =
    5258  * Fix create post security issue
Note: See TracChangeset for help on using the changeset viewer.