Changeset 2447220
- Timestamp:
- 12/29/2020 08:04:25 AM (5 years ago)
- Location:
- mobile-builder/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (1 diff)
-
mobile-builder.php (modified) (1 diff)
-
product/class-mobile-builder-product.php (modified) (3 diffs)
-
public/class-mobile-builder-public.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mobile-builder/trunk/README.txt
r2433872 r2447220 3 3 Donate link: https://rnlab.io 4 4 Tags: mobile builder, app builder, react native, woocommerce mobile app, rnlab, flutter 5 Requires at least: 3.0.16 Tested up to: 3.47 Stable tag: 4. 35 Requires at least: 5.3 6 Tested up to: 5.6 7 Stable tag: 4.8.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 Requires PHP: 5.610 Requires PHP: 7.0 11 11 12 12 The most advanced drag & drop app builder. Create multi templates and app controls. -
mobile-builder/trunk/mobile-builder.php
r2433872 r2447220 11 11 * Plugin URI: https://doc-oreo.rnlab.io 12 12 * Description: The most advanced drag & drop app builder. Create multi templates and app controls. 13 * Version: 1.4. 013 * Version: 1.4.1 14 14 * Author: Rnlab.io 15 15 * Author URI: https://rnlab.io -
mobile-builder/trunk/product/class-mobile-builder-product.php
r2423337 r2447220 68 68 69 69 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', 73 73 ) ); 74 74 … … 79 79 ) ); 80 80 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', 85 85 ) ); 86 86 … … 95 95 * @return array|WP_Error|WP_REST_Response 96 96 */ 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; 112 156 } 113 157 -
mobile-builder/trunk/public/class-mobile-builder-public.php
r2433857 r2447220 1591 1591 1592 1592 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; 1596 1600 } 1597 1601
Note: See TracChangeset
for help on using the changeset viewer.