Plugin Directory

Changeset 2423337


Ignore:
Timestamp:
11/23/2020 05:27:31 AM (5 years ago)
Author:
rnlab
Message:

bump 1.3.2

Location:
mobile-builder/trunk
Files:
5 edited

Legend:

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

    r2421992 r2423337  
    40405. Colors config
    41416. App settings
     42
     43== Changelog ==
     44= 1.3.2 =
     45
     46* Fixed: get products variations *
    4247
    4348== Changelog ==
  • mobile-builder/trunk/api/class-mobile-builder-products.php

    r2421992 r2423337  
    242242
    243243    /**
     244     * @param $product_data
     245     *
     246     * @return mixed
     247     * @since    1.0.0
     248     */
     249    public function custom_woocommerce_rest_prepare_product_variation_object( $product_data ) {
     250
     251        global $woocommerce_wpml;
     252
     253        if ( ! empty( $woocommerce_wpml->multi_currency ) && ! empty( $woocommerce_wpml->settings['currencies_order'] ) ) {
     254
     255            $product_data->data['multi-currency-prices'] = array();
     256
     257            $custom_prices_on = get_post_meta( $product_data->data['id'], '_wcml_custom_prices_status', true );
     258
     259            foreach ( $woocommerce_wpml->settings['currencies_order'] as $currency ) {
     260
     261                if ( $currency != get_option( 'woocommerce_currency' ) ) {
     262
     263                    if ( $custom_prices_on ) {
     264
     265                        $custom_prices = (array) $woocommerce_wpml->multi_currency->custom_prices->get_product_custom_prices( $product_data->data['id'],
     266                            $currency );
     267                        foreach ( $custom_prices as $key => $price ) {
     268                            $product_data->data['multi-currency-prices'][ $currency ][ preg_replace( '#^_#', '',
     269                                $key ) ] = $price;
     270
     271                        }
     272
     273                    } else {
     274                        $product_data->data['multi-currency-prices'][ $currency ]['regular_price'] =
     275                            $woocommerce_wpml->multi_currency->prices->raw_price_filter( $product_data->data['regular_price'],
     276                                $currency );
     277                        if ( ! empty( $product_data->data['sale_price'] ) ) {
     278                            $product_data->data['multi-currency-prices'][ $currency ]['sale_price'] =
     279                                $woocommerce_wpml->multi_currency->prices->raw_price_filter( $product_data->data['sale_price'],
     280                                    $currency );
     281                        }
     282                    }
     283
     284                }
     285            }
     286
     287        }
     288
     289        return $product_data;
     290    }
     291
     292    /**
    244293     * @param $response
    245294     * @param $post
  • mobile-builder/trunk/includes/class-mobile-builder.php

    r2421992 r2423337  
    239239        $this->loader->add_action( 'rest_api_init', $products_api, 'add_api_routes', 10 );
    240240        $this->loader->add_filter( 'woocommerce_rest_product_object_query', $products_api, 'woocommerce_rest_product_object_query', 10, 2 );
    241 
    242241        $this->loader->add_filter( 'woocommerce_rest_prepare_product_object', $products_api,
    243242            'prepare_product_images', 30, 3 );
     243
     244        // Product variation
     245        $this->loader->add_filter( 'woocommerce_rest_prepare_product_variation_object', $products_api,
     246            'custom_woocommerce_rest_prepare_product_variation_object' );
     247
     248        $this->loader->add_filter( 'woocommerce_rest_prepare_product_variation_object', $products_api,
     249            'prepare_product_variation_images', 10, 3 );
     250
     251        // Product Attributes
    244252        $this->loader->add_filter( 'woocommerce_rest_prepare_product_attribute', $products_api,
    245253            'custom_woocommerce_rest_prepare_product_attribute', 10, 3 );
     
    311319        $this->loader->add_action( 'rest_api_init', $plugin_product, 'add_api_routes' );
    312320
    313         // Product variation
    314         $this->loader->add_filter( 'woocommerce_rest_prepare_product_variation_object', $plugin_product,
    315             'custom_woocommerce_rest_prepare_product_variation_object' );
    316 
    317         $this->loader->add_filter( 'woocommerce_rest_prepare_product_variation_object', $plugin_product,
    318             'prepare_product_variation_images', 10, 3 );
    319 
    320321        // Product
    321322        $this->loader->add_filter( 'woocommerce_rest_prepare_product_object', $plugin_product,
  • mobile-builder/trunk/mobile-builder.php

    r2421992 r2423337  
    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.3.1
     13 * Version:           1.3.2
    1414 * Author:            Rnlab.io
    1515 * Author URI:        https://rnlab.io
  • mobile-builder/trunk/product/class-mobile-builder-product.php

    r2421992 r2423337  
    283283        return wp_specialchars_decode( $title );
    284284    }
    285 
    286     /**
    287      * @param $product_data
    288      *
    289      * @return mixed
    290      * @since    1.0.0
    291      */
    292     public function custom_woocommerce_rest_prepare_product_variation_object( $product_data ) {
    293 
    294         global $woocommerce_wpml;
    295 
    296         if ( ! empty( $woocommerce_wpml->multi_currency ) && ! empty( $woocommerce_wpml->settings['currencies_order'] ) ) {
    297 
    298             $product_data->data['multi-currency-prices'] = array();
    299 
    300             $custom_prices_on = get_post_meta( $product_data->data['id'], '_wcml_custom_prices_status', true );
    301 
    302             foreach ( $woocommerce_wpml->settings['currencies_order'] as $currency ) {
    303 
    304                 if ( $currency != get_option( 'woocommerce_currency' ) ) {
    305 
    306                     if ( $custom_prices_on ) {
    307 
    308                         $custom_prices = (array) $woocommerce_wpml->multi_currency->custom_prices->get_product_custom_prices( $product_data->data['id'],
    309                             $currency );
    310                         foreach ( $custom_prices as $key => $price ) {
    311                             $product_data->data['multi-currency-prices'][ $currency ][ preg_replace( '#^_#', '',
    312                                 $key ) ] = $price;
    313 
    314                         }
    315 
    316                     } else {
    317                         $product_data->data['multi-currency-prices'][ $currency ]['regular_price'] =
    318                             $woocommerce_wpml->multi_currency->prices->raw_price_filter( $product_data->data['regular_price'],
    319                                 $currency );
    320                         if ( ! empty( $product_data->data['sale_price'] ) ) {
    321                             $product_data->data['multi-currency-prices'][ $currency ]['sale_price'] =
    322                                 $woocommerce_wpml->multi_currency->prices->raw_price_filter( $product_data->data['sale_price'],
    323                                     $currency );
    324                         }
    325                     }
    326 
    327                 }
    328             }
    329 
    330         }
    331 
    332         return $product_data;
    333     }
    334285}
Note: See TracChangeset for help on using the changeset viewer.