Plugin Directory

Changeset 2447220


Ignore:
Timestamp:
12/29/2020 08:04:25 AM (5 years ago)
Author:
rnlab
Message:

bump: 1.4.1

Location:
mobile-builder/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mobile-builder/trunk/README.txt

    r2433872 r2447220  
    33Donate link: https://rnlab.io
    44Tags: mobile builder, app builder, react native, woocommerce mobile app, rnlab, flutter
    5 Requires at least: 3.0.1
    6 Tested up to: 3.4
    7 Stable tag: 4.3
     5Requires at least: 5.3
     6Tested up to: 5.6
     7Stable tag: 4.8.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    10 Requires PHP: 5.6
     10Requires PHP: 7.0
    1111
    1212The most advanced drag & drop app builder. Create multi templates and app controls.
  • mobile-builder/trunk/mobile-builder.php

    r2433872 r2447220  
    1111 * Plugin URI:        https://doc-oreo.rnlab.io
    1212 * Description:       The most advanced drag & drop app builder. Create multi templates and app controls.
    13  * Version:           1.4.0
     13 * Version:           1.4.1
    1414 * Author:            Rnlab.io
    1515 * Author URI:        https://rnlab.io
  • mobile-builder/trunk/product/class-mobile-builder-product.php

    r2423337 r2447220  
    6868
    6969        register_rest_route( $namespace, 'rating-count', array(
    70             'methods'  => 'GET',
    71             'callback' => array( $this, 'rating_count' ),
    72             'permission_callback'   => '__return_true',
     70            'methods'             => 'GET',
     71            'callback'            => array( $this, 'rating_count' ),
     72            'permission_callback' => '__return_true',
    7373        ) );
    7474
     
    7979        ) );
    8080
    81         register_rest_route( $namespace, 'variable/(?P<product_id>[a-zA-Z0-9-]+)', array(
    82             'methods'  => 'GET',
    83             'callback' => array( $this, 'product_get_all_variable_data' ),
    84             'permission_callback'   => '__return_true',
     81        register_rest_route( $namespace, 'attributes/(?P<product_id>[a-zA-Z0-9-]+)', array(
     82            'methods'             => 'GET',
     83            'callback'            => array( $this, 'get_all_product_attributes' ),
     84            'permission_callback' => '__return_true',
    8585        ) );
    8686
     
    9595     * @return array|WP_Error|WP_REST_Response
    9696     */
    97     function product_get_all_variable_data($request){
    98         $product_id = $request->get_param('product_id');
    99         $handle = new WC_Product_Variable($product_id);
    100         $variation_attributes = $handle->get_variation_attributes();
    101         $variation_attributes_data = array();
    102         $variation_attributes_label = array();
    103         foreach($variation_attributes as $key => $attribute){
    104             $variation_attributes_result['attribute_' . sanitize_title( $key )] = $attribute;
    105             $variation_attributes_label['attribute_' . sanitize_title( $key )] = $key;
    106         }
    107         return array(
    108             'variation_attributes_label' => $variation_attributes_label,
    109             'variation_attributes'=> $variation_attributes_result,
    110             'available_variations' => $handle->get_available_variations()
    111         );
     97    function get_all_product_attributes( $request ) {
     98        // Get product id from request
     99        $product_id = $request->get_param( 'product_id' );
     100
     101        // Get all attribute
     102        $attributes = wc_get_attribute_taxonomies();
     103
     104        // Get variation product info
     105        $variation_product = new WC_Product_Variable( $product_id );
     106
     107        // Product variation attributes
     108        $variation_attributes = $variation_product->get_variation_attributes();
     109
     110        // Init product attribute
     111        $product_attributes = array();
     112
     113        foreach ( $attributes as $key => $attribute ) {
     114
     115
     116            $slug = wc_attribute_taxonomy_name( $attribute->attribute_name );
     117
     118            if ( isset( $variation_attributes[ $slug ] ) ) {
     119
     120                $attr = new stdClass();
     121
     122                $attr->id           = (int) $attribute->attribute_id;
     123                $attr->name         = $attribute->attribute_label;
     124                $attr->slug         = wc_attribute_taxonomy_name( $attribute->attribute_name );
     125                $attr->type         = $attribute->attribute_type;
     126                $attr->order_by     = $attribute->attribute_orderby;
     127                $attr->has_archives = (bool) $attribute->attribute_public;
     128
     129                $option_term = array();
     130                foreach ( $variation_attributes[ $slug ] as $value ) {
     131                    $term = get_term_by( 'slug', $value, $slug );
     132
     133                    // Type color
     134                    if ( $term && $attribute->attribute_type == 'color' ) {
     135                        $term->value = sanitize_hex_color( get_term_meta( $term->term_id, 'product_attribute_color', true ) );
     136                    }
     137
     138                    // Type image
     139                    if ( $term && $attribute->attribute_type == 'image' ) {
     140                        $attachment_id = absint( get_term_meta( $term->term_id, 'product_attribute_image', true ) );
     141                        $image_size    = function_exists( 'woo_variation_swatches' ) ? woo_variation_swatches()->get_option( 'attribute_image_size' ) : 'thumbnail';
     142                        $term->value   = wp_get_attachment_image_url( $attachment_id, apply_filters( 'wvs_product_attribute_image_size', $image_size ) );
     143                    }
     144
     145                    $option_term[] = $term ? $term : $value;
     146                }
     147
     148                $attr->options = $option_term;
     149                $attr->terms   = $option_term;
     150
     151                $product_attributes[] = $attr;
     152            }
     153        }
     154
     155        return $product_attributes;
    112156    }
    113157
  • mobile-builder/trunk/public/class-mobile-builder-public.php

    r2433857 r2447220  
    15911591
    15921592        if ( $token ) {
    1593             $user = $this->decode( $token );
    1594 
    1595             return $user->data->user_id;
     1593            $user_decode = $this->decode( $token );
     1594
     1595            if ( is_wp_error( $user_decode ) ) {
     1596                return $user;
     1597            }
     1598
     1599            return $user_decode->data->user_id;
    15961600        }
    15971601
Note: See TracChangeset for help on using the changeset viewer.