Plugin Directory

Changeset 3094904


Ignore:
Timestamp:
05/30/2024 03:18:08 AM (22 months ago)
Author:
inspireui
Message:

version 4.14.3

Location:
mstore-api
Files:
486 added
6 edited

Legend:

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

    r2878156 r3094904  
    6161        $body = json_decode($json, TRUE);
    6262
    63         $params = array(
    64             'transaction_details' => array(
    65                 'order_id' => sanitize_text_field($body['order_id']),
    66                 'gross_amount' => sanitize_text_field($body['amount']),
    67             )
    68         );
     63        if($body['currency'] != 'IDR'){
     64             $options  =  get_option( 'woocommerce_midtrans_settings');
     65             if ($options && $options['to_idr_rate']) {
     66                $params = array(
     67                    'transaction_details' => array(
     68                        'order_id' => sanitize_text_field($body['order_id']),
     69                        'gross_amount' => floatval(sanitize_text_field($body['amount']))*intval($options['to_idr_rate']),
     70                    )
     71                );
     72             }
     73        }
     74        if (!isset($params)) {
     75            $params = array(
     76                'transaction_details' => array(
     77                    'order_id' => sanitize_text_field($body['order_id']),
     78                    'gross_amount' => sanitize_text_field($body['amount']),
     79                )
     80            );
     81        }
    6982        require_once ABSPATH . 'wp-content/plugins/midtrans-woocommerce/midtrans-gateway.php';
    7083        $order = wc_get_order( sanitize_text_field($body['order_id']) );
  • mstore-api/trunk/controllers/flutter-woo.php

    r3086463 r3094904  
    12031203            }
    12041204        }
    1205         if(apply_filters('wcfm_is_pref_vendor_reviews', true)){
    1206             global $WCFMmp;
     1205        global $WCFMmp;
     1206        if(apply_filters('wcfm_is_pref_vendor_reviews', true) && $WCFMmp){
    12071207            $WCFMmp->wcfmmp_reviews->wcfmmp_add_store_review( $comment_id );
    12081208        }   
  • mstore-api/trunk/controllers/helpers/product-management.php

    r3048873 r3094904  
    9090    }
    9191
    92     public function get_products($request, $user_id)
    93     {
    94         global $wpdb;
    95         $page = isset($request["page"]) ? sanitize_text_field($request["page"])  : 1;
    96         $limit = isset($request["per_page"]) ? sanitize_text_field($request["per_page"]) : 10;
    97         if(!is_numeric($page)){
    98             $page = 1;
    99         }
    100         if(!is_numeric($limit)){
    101             $limit = 10;
    102         }
    103         if ($page >= 1) {
    104             $page = ($page - 1) * $limit;
    105         }
    106 
    107         if ($user_id) {
    108             $user = get_userdata($user_id);
    109             $is_admin = $user != false ? in_array('administrator', (array)$user->roles) : false;
    110             $vendor_id = absint($user_id);
    111         }
    112 
    113         $table_name = $wpdb->prefix . "posts";
    114         $postmeta_table = $wpdb->prefix . "postmeta";
    115         $is_admin = isset($is_admin) && $is_admin == true;
    116         if($is_admin){
    117             $sql = "SELECT * FROM `$table_name` WHERE `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
    118         }else{
    119             $sql = "SELECT * FROM `$table_name` WHERE `$table_name`.`post_author` = %s AND `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
    120         }
    121 
    122         if (isset($request["search"])) {
    123             $search =  sanitize_text_field($request["search"]);
    124             $search = "%$search%";
    125 
    126             if ($is_admin) {
    127                 $sql = "SELECT DISTINCT `$table_name`.ID, `$table_name`.* FROM `$table_name` LEFT JOIN `$postmeta_table` ON {$table_name}.ID = {$postmeta_table}.post_id WHERE `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
    128             } else {
    129                 $sql = "SELECT DISTINCT `$table_name`.ID, `$table_name`.* FROM `$table_name` LEFT JOIN `$postmeta_table` ON {$table_name}.ID = {$postmeta_table}.post_id WHERE `$table_name`.`post_author` = %s AND `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
    130             }
    131 
    132             $sql .= " AND (`$table_name`.`post_content` LIKE %s OR `$table_name`.`post_title` LIKE %s OR `$table_name`.`post_excerpt` LIKE %s OR (`$postmeta_table`.`meta_key` = '_sku' AND `$postmeta_table`.`meta_value` LIKE %s))";
    133         }
    134         $sql .= " ORDER BY `ID` DESC LIMIT %d OFFSET %d";
    135 
    136         $args = array();
    137         if(!$is_admin){
    138             $args[] = $vendor_id;
    139         }
    140         if (isset($search)) {
    141             $args[] = $search;
    142             $args[] = $search;
    143             $args[] = $search;
    144             $args[] = $search;
    145         }
    146         $args[] = $limit;
    147         $args[] = $page;
    148         $sql = $wpdb->prepare($sql, $args);
    149         $item = $wpdb->get_results($sql);
    150 
    151         $products_arr = [];
    152         foreach ($item as $pro) {
    153             $product = wc_get_product($pro->ID);
     92    private function get_product_info_by_id($id){
     93        $product = wc_get_product($id);
    15494            $p = $product->get_data();
    15595            $image_arr = [];
     
    267207                }
    268208            }
    269             $products_arr[] = $p;
     209            return $p;
     210    }
     211
     212    public function get_products($request, $user_id)
     213    {
     214        global $wpdb;
     215        $page = isset($request["page"]) ? sanitize_text_field($request["page"])  : 1;
     216        $limit = isset($request["per_page"]) ? sanitize_text_field($request["per_page"]) : 10;
     217        if(!is_numeric($page)){
     218            $page = 1;
     219        }
     220        if(!is_numeric($limit)){
     221            $limit = 10;
     222        }
     223        if ($page >= 1) {
     224            $page = ($page - 1) * $limit;
     225        }
     226
     227        if ($user_id) {
     228            $user = get_userdata($user_id);
     229            $is_admin = $user != false ? in_array('administrator', (array)$user->roles) : false;
     230            $vendor_id = absint($user_id);
     231        }
     232
     233        $table_name = $wpdb->prefix . "posts";
     234        $postmeta_table = $wpdb->prefix . "postmeta";
     235        $is_admin = isset($is_admin) && $is_admin == true;
     236        if($is_admin){
     237            $sql = "SELECT * FROM `$table_name` WHERE `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
     238        }else{
     239            $sql = "SELECT * FROM `$table_name` WHERE `$table_name`.`post_author` = %s AND `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
     240        }
     241
     242        if (isset($request["search"])) {
     243            $search =  sanitize_text_field($request["search"]);
     244            $search = "%$search%";
     245
     246            if ($is_admin) {
     247                $sql = "SELECT DISTINCT `$table_name`.ID, `$table_name`.* FROM `$table_name` LEFT JOIN `$postmeta_table` ON {$table_name}.ID = {$postmeta_table}.post_id WHERE `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
     248            } else {
     249                $sql = "SELECT DISTINCT `$table_name`.ID, `$table_name`.* FROM `$table_name` LEFT JOIN `$postmeta_table` ON {$table_name}.ID = {$postmeta_table}.post_id WHERE `$table_name`.`post_author` = %s AND `$table_name`.`post_type` = 'product' AND `$table_name`.`post_status` != 'trash'";
     250            }
     251
     252            $sql .= " AND (`$table_name`.`post_content` LIKE %s OR `$table_name`.`post_title` LIKE %s OR `$table_name`.`post_excerpt` LIKE %s OR (`$postmeta_table`.`meta_key` = '_sku' AND `$postmeta_table`.`meta_value` LIKE %s))";
     253        }
     254        $sql .= " ORDER BY `ID` DESC LIMIT %d OFFSET %d";
     255
     256        $args = array();
     257        if(!$is_admin){
     258            $args[] = $vendor_id;
     259        }
     260        if (isset($search)) {
     261            $args[] = $search;
     262            $args[] = $search;
     263            $args[] = $search;
     264            $args[] = $search;
     265        }
     266        $args[] = $limit;
     267        $args[] = $page;
     268        $sql = $wpdb->prepare($sql, $args);
     269        $item = $wpdb->get_results($sql);
     270
     271        $products_arr = [];
     272        foreach ($item as $pro) {
     273            $products_arr[] = $this->get_product_info_by_id($pro->ID);
    270274        }
    271275
     
    525529                if ($product->get_type() == "variable") {
    526530                    $variations_arr = json_decode($variations,true);
    527                     $available_variations = $product->get_available_variations();
    528                     $available_variations_arr = array();
    529                     foreach($available_variations as $value){
    530                         $available_variations_arr[]=intval($value['variation_id']);
    531                     }
     531                    $available_variations_arr = $product->get_children();
    532532                    foreach ($variations_arr as $variation) {
    533533                        if(isset($variation['id'])){
     
    635635                }
    636636                /*********************/
    637 
    638                 $controller = new CUSTOM_WC_REST_Products_Controller();
    639                 $req = new WP_REST_Request('GET');
    640                 $params = array('id' => $p['id']);
    641                 $req->set_query_params($params);
    642 
    643                 $response = $controller->get_item($req);
    644                 $pData = $response->get_data();
    645 
    646                 $attributes = [];
    647                 foreach ($product->get_attributes() as $attribute) {
    648                     $attributes[] = [
    649                         "id" => $attribute["is_taxonomy"]
    650                             ? wc_attribute_taxonomy_id_by_name($attribute["name"])
    651                             : 0,
    652                         "name" =>
    653                             0 === strpos($attribute["name"], "pa_")
    654                                 ? get_taxonomy($attribute["name"])->labels
    655                                 ->singular_name
    656                                 : $attribute["name"],
    657                         "position" => (int)$attribute["position"],
    658                         "visible" => (bool)$attribute["is_visible"],
    659                         "variation" => (bool)$attribute["is_variation"],
    660                         "options" => $this->get_attribute_options(
    661                             $product->get_id(),
    662                             $attribute
    663                         ),
    664                         "slugs" => $this->get_attribute_slugs(
    665                             $product->get_id(),
    666                             $attribute
    667                         ),
    668                         "default" => 0 === strpos($attribute["name"], "pa_"),
    669                         "slug" => str_replace(' ','-',$attribute["name"]),
    670                     ];
    671                 }
    672                 $pData["attributesData"] = $attributes;
    673                 $pData["featured_image"] = isset($featured_image) ? $featured_image : null;
    674                 $pData["images"] = $image_arr;
    675637                return new WP_REST_Response(
    676638                        [
    677639                            "status" => "success",
    678                             "response" => $pData,
     640                            "response" => $this->get_product_info_by_id($p['id']),
    679641                        ],
    680642                        200
  • mstore-api/trunk/controllers/listing-rest-api/class.api.fields.php

    r3059647 r3094904  
    995995                    if ($free_places > 0)
    996996                    {
    997                         $slot = json_encode($slot);
     997                        $slot = is_array($slot) ?  $slot : json_encode($slot);
    998998                        $hours = explode(' - ', $slot[0]);
    999999                        $hour_start = date("H:i:s", strtotime($hours[0]));
  • mstore-api/trunk/mstore-api.php

    r3089934 r3094904  
    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.2
     6 * Version: 4.14.3
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    5656class MstoreCheckOut
    5757{
    58     public $version = '4.14.2';
     58    public $version = '4.14.3';
    5959
    6060    public function __construct()
  • mstore-api/trunk/readme.txt

    r3089934 r3094904  
    44Requires at least: 4.4
    55Tested up to:      6.5.3
    6 Stable tag:        4.14.2
     6Stable tag:        4.14.3
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.14.3 =
     52  * Fix update product in vendor admin
     53
    5154= 4.14.2 =
    5255  * Fix syntax error
Note: See TracChangeset for help on using the changeset viewer.