Plugin Directory

Changeset 3279132


Ignore:
Timestamp:
04/22/2025 01:58:42 PM (11 months ago)
Author:
inspireui
Message:

version 4.17.5

Location:
mstore-api
Files:
494 added
3 edited

Legend:

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

    r3277790 r3279132  
    408408        }
    409409
    410         if( isset($params['dokan_enable_selling'])){
    411             $dokan_enable_selling  =  $params['dokan_enable_selling'];
    412         }
    413410        if(isset($params['wcfm_membership_application_status'])){
    414411            $wcfm_membership_application_status = $params['wcfm_membership_application_status'];
     
    507504        }
    508505
    509         // 'dokan_enable_selling' metadata should be 'yes' or 'no'
    510         if (isset($dokan_enable_selling)) {
    511             update_user_meta($user_id, 'dokan_enable_selling', $dokan_enable_selling);
     506        if (isset($params['dokan_enable_selling'])) {
     507            update_user_meta($user_id, 'dokan_enable_selling', 'no');
    512508        }
    513509        $cookie = generateCookieByUserId($user_id,  $seconds);
  • mstore-api/trunk/mstore-api.php

    r3277794 r3279132  
    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.4
     6 * Version: 4.17.5
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    6262class MstoreCheckOut
    6363{
    64     public $version = '4.17.4';
     64    public $version = '4.17.5';
    6565
    6666    public function __construct()
     
    12361236    );
    12371237}
     1238
     1239// Check if Woo Variation Swatches is active before adding the filter
     1240if (!function_exists('add_variation_swatches_attribute_images_to_api')) {
     1241    function add_variation_swatches_attribute_images_to_api($response, $product, $request) {
     1242        // First check if the plugin is active
     1243        if (!function_exists('woo_variation_swatches') || !class_exists('Woo_Variation_Swatches')) {
     1244            return $response;
     1245        }
     1246       
     1247        $data = $response->get_data();
     1248       
     1249        // Only proceed if product has attributes
     1250        if (empty($data['attributes'])) {
     1251            return $response;
     1252        }
     1253       
     1254        $product_attributes = $product->get_attributes();
     1255       
     1256        foreach ($data['attributes'] as $key => $attribute) {
     1257            $attribute_name = $attribute['name'];
     1258            $attribute_obj = isset($product_attributes[$attribute_name]) ? $product_attributes[$attribute_name] : null;
     1259           
     1260            if ($attribute_obj && $attribute_obj->is_taxonomy()) {
     1261                $terms = wp_get_post_terms($product->get_id(), $attribute_name, ['fields' => 'all']);
     1262               
     1263                foreach ($terms as $term_key => $term) {
     1264                    // Get image ID from term meta set by Woo Variation Swatches
     1265                    $image_id = get_term_meta($term->term_id, 'product_attribute_image', true);
     1266                   
     1267                    if ($image_id) {
     1268                        $image_size = woo_variation_swatches()->get_option('attribute_image_size', 'variation_swatches_image_size');
     1269                        $image_src = wp_get_attachment_image_src($image_id, $image_size);
     1270                       
     1271                        if ($image_src) {
     1272                            // Add image data to the term in the API response
     1273                            $data['attributes'][$key]['options'][$term_key] = [
     1274                                'term_id' => $term->term_id,
     1275                                'name' => $term->name,
     1276                                'slug' => $term->slug,
     1277                                'image' => [
     1278                                    'src' => $image_src[0],
     1279                                    'width' => $image_src[1],
     1280                                    'height' => $image_src[2]
     1281                                ]
     1282                            ];
     1283                        }
     1284                    }
     1285                }
     1286            }
     1287        }
     1288       
     1289        $response->set_data($data);
     1290        return $response;
     1291    }
     1292}
     1293
     1294// Only add the filter if the function exists (as an extra check)
     1295if (function_exists('add_variation_swatches_attribute_images_to_api')) {
     1296    add_filter('woocommerce_rest_prepare_product_object', 'add_variation_swatches_attribute_images_to_api', 10, 3);
     1297}
  • mstore-api/trunk/readme.txt

    r3277794 r3279132  
    44Requires at least: 4.4
    55Tested up to:      6.8.0
    6 Stable tag:        4.17.4
     6Stable tag:        4.17.5
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.17.5 =
     52  * Fix register security issue
     53  * Support to get attribute image for Variation Swatches
     54
    5155= 4.17.4 =
    5256  * Update for the latest wordpress v6.8
Note: See TracChangeset for help on using the changeset viewer.