Plugin Directory

Changeset 3333934


Ignore:
Timestamp:
07/25/2025 03:33:51 AM (8 months ago)
Author:
inspireui
Message:

up version 4.18.0

Location:
mstore-api
Files:
495 added
11 edited

Legend:

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

    r3306788 r3333934  
    393393    public function register()
    394394    {
    395         if (!get_option( 'users_can_register' )) {
     395        if (!get_option('users_can_register')) {
    396396            return parent::sendError("disabled_register", "Registration is not enabled.", 400);
    397397        }
     
    462462                }
    463463
    464                 $default_role = class_exists( 'WooCommerce' ) ? 'customer' : get_option('default_role');
    465                 if( isset($params['dokan_enable_selling'])){
     464                $default_role = class_exists('WooCommerce') ? 'customer' : get_option('default_role');
     465                if (isset($params['dokan_enable_selling'])) {
    466466                    $user['role'] = 'seller';
    467                 }else{
    468                     if (array_key_exists('role', $params) && in_array($params['role'], ['wcfm_delivery_boy', 'driver'], true)) {
     467                } else {
     468                    if (array_key_exists('role', $params) && in_array($params['role'], ['wcfm_delivery_boy', 'driver', 'owner'], true)) {
    469469                        $user['role'] = $params['role'];
    470                     }else{
     470                    } else {
    471471                        $user['role'] = $default_role;
    472472                    }
    473473                }
    474                 $_POST['user_role'] = $user['role'];//fix to register account with role in listeo
     474                $_POST['user_role'] = $user['role']; //fix to register account with role in listeo
    475475
    476476                //
  • mstore-api/trunk/controllers/flutter-vendor-admin.php

    r3306788 r3333934  
    584584                }
    585585                $data['slug'] ='pa_'.$tax->attribute_name;
     586                $data['attribute_key'] = strtolower(urlencode($data['slug']));
    586587                $data['default'] = true;
    587588                $attributes[] = $data;
  • mstore-api/trunk/controllers/flutter-woo.php

    r3246917 r3333934  
    776776                    "cost" => $rate->get_cost(),
    777777                    "taxes" => $rate->get_taxes(),
    778                     "shipping_tax" => $rate->get_shipping_tax()
     778                    "shipping_tax" => $rate->get_shipping_tax(),
     779                    "is_including_tax" => 'incl' === get_option( 'woocommerce_tax_display_cart' )
    779780                ];
    780781            }
  • mstore-api/trunk/controllers/helpers/product-management.php

    r3106210 r3333934  
    120120            $p["on_sale"] = $product->is_on_sale();
    121121            $p["tags"] = wp_get_post_terms($product->get_id(), "product_tag");
     122            $p['weight'] = $product->get_weight();
     123            $p['dimensions'] = [
     124                'length' => $product->get_length(),
     125                'width' => $product->get_width(),
     126                'height' => $product->get_height(),
     127            ];
    122128
    123129            $attributes = [];
    124             foreach ($product->get_attributes() as $attribute) {
     130            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    125131                $attributes[] = [
    126132                    "id" => $attribute["is_taxonomy"]
     
    132138                            ->singular_name
    133139                            : $attribute["name"],
     140                            "attribute_key" => $attribute_key,
    134141                    "position" => (int)$attribute["position"],
    135142                    "visible" => (bool)$attribute["is_visible"],
     
    189196                    $feature_image = wp_get_attachment_image_src( $variation_p->get_image_id(), 'single-post-thumbnail' );
    190197                    $variation_data['feature_image'] = $feature_image ? $feature_image[0] : null;
    191            
     198
     199                    $variation_data['weight'] = $variation_p->get_weight();
     200                    $variation_data['dimensions'] = [
     201                        'length' => $variation_p->get_length(),
     202                        'width' => $variation_p->get_width(),
     203                        'height' => $variation_p->get_height(),
     204                    ];
     205
    192206                    $attr_arr = array();
    193207                    $variation_attributes = $variation_p->get_attributes();
    194                     foreach($variation_attributes as $k=>$v){
     208                    foreach($variation_attributes as $taxonomy=>$term_slug){
    195209                        $attr_data = array();
    196                         $attr_data['name'] = $k;
    197                         $attr_data['slug'] = $v;
    198                         $meta = get_post_meta($variation->ID, 'attribute_'.$k, true);
    199                         $term = get_term_by('slug', $meta, $k);
    200                         if($term){
    201                             $attr_data['attribute_name'] = $term->name;
    202                         }
     210                       
     211                        // Decode taxonomy and term if needed
     212                        $decoded_taxonomy = urldecode($taxonomy);
     213                        $decoded_term_slug = urldecode($term_slug);
     214
     215                        if ( taxonomy_exists( $decoded_taxonomy ) ) {
     216                            // Get attribute name (label)
     217                            $attribute_label = wc_attribute_label( $decoded_taxonomy );
     218
     219                            // Get term (option) name
     220                            $term = get_term_by( 'slug', $decoded_term_slug, $decoded_taxonomy );
     221                            if ( $term && ! is_wp_error( $term ) ) {
     222                                $option_label = $term->name;
     223                            } else {
     224                                $option_label = $decoded_term_slug; // fallback
     225                            }
     226                        } else {
     227                            $attribute_label = $decoded_taxonomy;
     228                            $option_label = $decoded_term_slug;
     229                        }
     230
     231                        $attr_data['name'] = $attribute_label;
     232                        $attr_data['attribute_key'] = $taxonomy;
     233                        $attr_data['slug'] = $term_slug;
     234                        $attr_data['attribute_name'] = $option_label;
    203235                        $attr_arr[]=$attr_data;
    204236                    }
     
    317349
    318350        $tags = sanitize_text_field($request['tags']);
    319        
     351
    320352        $regular_price = sanitize_text_field($request['regular_price']);
    321353        $sale_price = sanitize_text_field($request['sale_price']);
    322354        $stock_quantity = sanitize_text_field($request['stock_quantity']);
    323355        $manage_stock  = sanitize_text_field($request['manage_stock']);
    324        
    325         $category_ids  = sanitize_text_field($request['category_ids']);   
     356
     357        $weight = isset($request['weight']) ? sanitize_text_field($request['weight']) : '';
     358        $length = isset($request['length']) ? sanitize_text_field($request['length']) : '';
     359        $width = isset($request['width']) ? sanitize_text_field($request['width']) : '';
     360        $height = isset($request['height']) ? sanitize_text_field($request['height']) : '';
     361
     362        $category_ids  = sanitize_text_field($request['category_ids']);
    326363       
    327364        if(isset($request['featuredImage'])){
     
    495532                }
    496533
    497        
     534                if (!empty($weight)) {
     535                    $product->set_weight($weight);
     536                }
     537                if (!empty($length)) {
     538                    $product->set_length($length);
     539                }
     540                if (!empty($width)) {
     541                    $product->set_width($width);
     542                }
     543                if (!empty($height)) {
     544                    $product->set_height($height);
     545                }
    498546
    499547                //Description
     
    581629                                : "private"
    582630                        );
     631
     632                        if (isset($variation['weight']) && !empty($variation['weight'])) {
     633                            $variationProduct->set_weight($variation['weight']);
     634                        }
     635                        if (isset($variation['length']) && !empty($variation['length'])) {
     636                            $variationProduct->set_length($variation['length']);
     637                        }
     638                        if (isset($variation['width']) && !empty($variation['width'])) {
     639                            $variationProduct->set_width($variation['width']);
     640                        }
     641                        if (isset($variation['height']) && !empty($variation['height'])) {
     642                            $variationProduct->set_height($variation['height']);
     643                        }
     644
    583645                        $variationProduct->save();
    584646
  • mstore-api/trunk/controllers/helpers/vendor-admin-dokan-helper.php

    r3032467 r3333934  
    268268            $attributes = array();
    269269
    270             foreach ($product->get_attributes() as $attribute) {
     270            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    271271                $attributes[] = array(
    272272                    'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0,
    273273                    'name' => 0 === strpos($attribute['name'], 'pa_') ? get_taxonomy($attribute['name'])
    274274                        ->labels->singular_name : $attribute['name'],
     275                        'attribute_key' => $attribute_key,
    275276                    'position' => (int)$attribute['position'],
    276277                    'visible' => (bool)$attribute['is_visible'],
     
    304305                    $dataVariation['manage_stock'] = $p_varation->get_manage_stock();
    305306                    $dataVariation['stock_status'] = $p_varation->get_stock_status();
    306                     $attributes = $p_varation->get_attributes();
    307307                    $dataVariation['attributes'] = array();
    308308                    foreach ($dataVariation['slugs'] as $key => $value) {
     
    14211421            $p['on_sale'] = $product->is_on_sale();
    14221422            $attributes = array();
    1423             foreach ($product->get_attributes() as $attribute) {
     1423            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    14241424                $attributes[] = array(
    14251425                    'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0,
    14261426                    'name' => $this->get_attribute_taxonomy_name($attribute['name'], $product),
     1427                    'attribute_key' => $attribute_key,
    14271428                    'position' => (int)$attribute['position'],
    14281429                    'visible' => (bool)$attribute['is_visible'],
  • mstore-api/trunk/controllers/helpers/vendor-admin-wcfm-helper.php

    r3293669 r3333934  
    333333
    334334            $attributes = [];
    335             foreach ($product->get_attributes() as $attribute) {
     335            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    336336                $attributes[] = [
    337337                    "id" => $attribute["is_taxonomy"]
     
    343343                            ->singular_name
    344344                            : $attribute["name"],
     345                            "attribute_key" => $attribute_key,
    345346                    "position" => (int)$attribute["position"],
    346347                    "visible" => (bool)$attribute["is_visible"],
     
    393394                    $dataVariation["slugs"] = $p_varation->get_attributes();
    394395                    $dataVariation["manage_stock"] = $p_varation->get_manage_stock();
    395                     $attributes = $p_varation->get_attributes();
    396396                    $dataVariation["attributes"] = [];
    397397                    foreach ($dataVariation["slugs"] as $key => $value) {
     
    26692669            $p["on_sale"] = $product->is_on_sale();
    26702670            $attributes = [];
    2671             foreach ($product->get_attributes() as $attribute) {
     2671            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    26722672                $attributes[] = [
    26732673                    "id" => $attribute["is_taxonomy"]
     
    26782678                        $product
    26792679                    ),
     2680                    "attribute_key" => $attribute_key,
    26802681                    "position" => (int)$attribute["position"],
    26812682                    "visible" => (bool)$attribute["is_visible"],
  • mstore-api/trunk/controllers/helpers/vendor-admin-woo-helper.php

    r2989540 r3333934  
    135135                $attributes = array();
    136136                $is_variable = false;
    137                 foreach ($product->get_attributes() as $attribute) {
     137                foreach ($product->get_attributes() as $attribute_key => $attribute) {
    138138                    $attributes[] = array(
    139139                        'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0,
    140140                        'name' => 0 === strpos($attribute['name'], 'pa_') ? get_taxonomy($attribute['name'])
    141141                            ->labels->singular_name : $attribute['name'],
     142                            'attribute_key' => $attribute_key,
    142143                        'position' => (int)$attribute['position'],
    143144                        'visible' => (bool)$attribute['is_visible'],
     
    175176                        $dataVariation['slugs'] = $p_varation->get_attributes();
    176177                        $dataVariation['manage_stock'] = $p_varation->get_manage_stock();
    177                         $attributes = $p_varation->get_attributes();
    178178                        $dataVariation['attributes'] = array();
    179179                        foreach ($dataVariation['slugs'] as $key => $value) {
     
    13061306            $p['on_sale'] = $product->is_on_sale();
    13071307            $attributes = array();
    1308             foreach ($product->get_attributes() as $attribute) {
     1308            foreach ($product->get_attributes() as $attribute_key => $attribute) {
    13091309                $attributes[] = array(
    13101310                    'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0,
    13111311                    'name' => $this->get_attribute_taxonomy_name($attribute['name'], $product),
     1312                    'attribute_key' => $attribute_key,
    13121313                    'position' => (int)$attribute['position'],
    13131314                    'visible' => (bool)$attribute['is_visible'],
  • mstore-api/trunk/controllers/listing-rest-api/class.api.fields.php

    r3293669 r3333934  
    902902            }, $services);
    903903        }
    904         $data['price'] = Listeo_Core_Bookings_Calendar::calculate_price($request['listing_id'], $request['date_start'], $request['date_end'], $multiply, $services, '');
    905         if (!empty($coupon))
    906         {
    907             $data['price_discount'] = Listeo_Core_Bookings_Calendar::calculate_price($request['listing_id'], $request['date_start'], $request['date_end'], $multiply, $services, $coupon);
    908 
     904
     905        try {
     906            $args = array(
     907                $request['listing_id'],
     908                $request['date_start'],
     909                $request['date_end'],
     910                $multiply,
     911                isset($request['children']) ? (int)$request['children'] : 0,
     912                isset($request['animals']) ? (int)$request['animals'] : 0,
     913                $services,
     914                ''
     915            );
     916
     917            $data['price'] = call_user_func_array(
     918                array('Listeo_Core_Bookings_Calendar', 'calculate_price'),
     919                $args
     920            );
     921
     922            if (!empty($coupon)) {
     923                $args[count($args)-1] = $coupon;
     924                $data['price_discount'] = call_user_func_array(
     925                    array('Listeo_Core_Bookings_Calendar', 'calculate_price'),
     926                    $args
     927                );
     928            }
     929        } catch (Error $e) {
     930            $data['price'] = Listeo_Core_Bookings_Calendar::calculate_price(
     931                $request['listing_id'],
     932                $request['date_start'],
     933                $request['date_end'],
     934                $multiply,
     935                $services,
     936                ''
     937            );
     938
     939            if (!empty($coupon))
     940            {
     941                $data['price_discount'] = Listeo_Core_Bookings_Calendar::calculate_price(
     942                    $request['listing_id'],
     943                    $request['date_start'],
     944                    $request['date_end'],
     945                    $multiply,
     946                    $services,
     947                    $coupon
     948                );
     949            }
    909950        }
    910951        // $_slots = $this->update_slots($request);
     
    10311072        $_user_id = $object['user_id'];
    10321073        $user_info = get_user_meta($_user_id);
    1033         $u_data = get_user_by( 'id', $_user_id );
     1074        $u_data = get_user_by('id', $_user_id);
    10341075
    10351076        $first_name = isset($user_info['billing_first_name']) ? $user_info['billing_first_name'][0] : $user_info['first_name'][0];
     
    10651106        $coupon = isset($data->coupon) ? $data->coupon : null;
    10661107        $message = '';
     1108        $calculate_price = function($listing_id, $date_start, $date_end, $multiply, $services, $coupon) use ($data) {
     1109            try {
     1110                $args = array(
     1111                    $listing_id,
     1112                    $date_start,
     1113                    $date_end,
     1114                    $multiply,
     1115                    isset($data->children) ? (int)$data->children : 0,
     1116                    isset($data->animals) ? (int)$data->animals : 0,
     1117                    $services,
     1118                    $coupon
     1119                );
     1120                return call_user_func_array(
     1121                    array('Listeo_Core_Bookings_Calendar', 'calculate_price'),
     1122                    $args
     1123                );
     1124            } catch (Error $e) {
     1125                return Listeo_Core_Bookings_Calendar::calculate_price(
     1126                    $listing_id,
     1127                    $date_start,
     1128                    $date_end,
     1129                    $multiply,
     1130                    $services,
     1131                    $coupon
     1132                );
     1133            }
     1134        };
     1135
    10671136        if (!empty($services))
    10681137        {
     
    10981167            {
    10991168
    1100                 if (in_array(sanitize_title($service['name']) , array_column($services, 'service')))
     1169                if (in_array(sanitize_title($service['name']), array_column($services, 'service')))
    11011170                {
     1171                    try {
     1172                        $price = listeo_calculate_service_price(
     1173                            $service,
     1174                            $adults,
     1175                            isset($data->children) ? (int)$data->children : 0,
     1176                            isset($service['children_discount']) ? $service['children_discount'] : 0,
     1177                            $days_count,
     1178                            $countable[$i]
     1179                        );
     1180                    } catch (Error $e) {
     1181                        $price = listeo_calculate_service_price(
     1182                            $service,
     1183                            $adults,
     1184                            $days_count,
     1185                            $countable[$i]
     1186                        );
     1187                    }
     1188
    11021189                    $comment_services[] = array(
    11031190                        'service' => $service,
     
    11051192                        'days' => $days_count,
    11061193                        'countable' => $countable[$i],
    1107                         'price' => listeo_calculate_service_price($service, $adults, $days_count, $countable[$i])
     1194                        'price' => $price
    11081195                    );
    11091196
     
    11521239                    'date_start' => $date_start,
    11531240                    'date_end' => $date_start,
    1154                     'comment' => json_encode($comment) ,
     1241                    'comment' => json_encode($comment),
    11551242                    'type' => 'reservation',
    1156                     'price' => Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $tickets, $services, $coupon) ,
     1243                    'price' => $calculate_price($listing_id, $date_start, $date_end, $tickets, $services, $coupon),
    11571244                ));
    11581245
     
    11781265                    if ($count_per_guest)
    11791266                    {
    1180                         $multiply = 1;
    1181                         if (isset($adults)) $multiply = $adults;
    1182                         $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
     1267                        $multiply = isset($adults) ? $adults : 1;
     1268                        $price = $calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
    11831269                    }
    11841270                    else
    11851271                    {
    1186                         $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
     1272                        $price = $calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
    11871273                    }
    11881274
     
    12051291                            'billing_city' => $billing_city,
    12061292                            'billing_country' => $billing_country
    1207                         )) ,
     1293                        )),
    12081294                        'type' => 'reservation',
    12091295                        'price' => $price,
     
    12331319                    if ($count_per_guest)
    12341320                    {
    1235                         $multiply = 1;
    1236                         if (isset($adults)) $multiply = $adults;
    1237                         $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
     1321                        $multiply = isset($adults) ? $adults : 1;
     1322                        $price = $calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
    12381323                    }
    12391324                    else
    12401325                    {
    1241                         $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
     1326                        $price = $calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
    12421327                    }
    12431328                    $hour_end = (isset($_hour_end) && !empty($_hour_end)) ? $_hour_end : $_hour;
     
    12611346                            'billing_country' => $billing_country
    12621347
    1263                         )) ,
     1348                        )),
    12641349                        'type' => 'reservation',
    12651350                        'price' => $price,
     
    12741359                    if ($free_places > 0)
    12751360                    {
    1276                         $slot = is_array($slot) ?  $slot : json_encode($slot);
     1361                        $slot = is_array($slot) ? $slot : json_encode($slot);
    12771362                        $hours = explode(' - ', $slot[0]);
    12781363                        $hour_start = date("H:i:s", strtotime($hours[0]));
     
    12821367                        if ($count_per_guest)
    12831368                        {
    1284                             $multiply = 1;
    1285                             if (isset($adults)) $multiply = $adults;
    1286                             $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
     1369                            $multiply = isset($adults) ? $adults : 1;
     1370                            $price = $calculate_price($listing_id, $date_start, $date_end, $multiply, $services, $coupon);
    12871371                        }
    12881372                        else
    12891373                        {
    1290                             $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
     1374                            $price = $calculate_price($listing_id, $date_start, $date_end, 1, $services, $coupon);
    12911375                        }
    12921376
     
    13101394                                'billing_country' => $billing_country
    13111395
    1312                             )) ,
     1396                            )),
    13131397                            'type' => 'reservation',
    13141398                            'price' => $price,
  • mstore-api/trunk/functions/index.php

    r3320914 r3333934  
    596596                }
    597597
    598                 $attributesData[] = array_merge($attr->get_data(), ["label" => $label, "name" => urldecode($key), 'is_image_type' => $is_image_type], ['options' =>$attrOptions]);
     598                $attributesData[] = array_merge($attr->get_data(), ["attribute_key" => $key, "label" => $label, "name" => urldecode($key), 'is_image_type' => $is_image_type], ['options' =>$attrOptions]);
    599599            }
    600600        }
     
    853853            $yith_addons_exists = false;
    854854            foreach ( $meta_data as $meta_item ) {
    855                 if ( $meta_item->get_data()['key'] === '_yith_wapo_addons' ) {
     855                // Handle both array and WC_Meta_Data object formats
     856                $key = is_array( $meta_item ) ? $meta_item['key'] : $meta_item->get_data()['key'];
     857                if ( $key === '_yith_wapo_addons' ) {
    856858                    $yith_addons_exists = true;
    857859                    break;
  • mstore-api/trunk/mstore-api.php

    r3320914 r3333934  
    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.9
     6 * Version: 4.18.0
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    6363class MstoreCheckOut
    6464{
    65     public $version = '4.17.9';
     65    public $version = '4.18.0';
    6666
    6767    public function __construct()
  • mstore-api/trunk/readme.txt

    r3320914 r3333934  
    44Requires at least: 4.4
    55Tested up to:      6.8.1
    6 Stable tag:        4.17.9
     6Stable tag:        4.18.0
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.18.0 =
     52  * Response is_including_tax for shipping methods
     53  * Response attribute_key
     54  * Save product shipping info
     55  * Add owner role registration for Listing
     56  * Support multi-version Listeo theme price calculation
     57  * Support multi-version Listeo theme booking
     58
    5159= 4.17.9 =
    5260  * Support YITH Product Add-Ons
Note: See TracChangeset for help on using the changeset viewer.