Plugin Directory

Changeset 2344460


Ignore:
Timestamp:
07/22/2020 03:10:00 AM (6 years ago)
Author:
rnlab
Message:

bump: v1.1.0

Location:
mobile-builder/trunk
Files:
6 edited

Legend:

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

    r2337209 r2344460  
    4949* Add wc validation in the add_to_cart function (Thanks @raaquino)
    5050* Get checkout user location config
     51
     52= 1.1.0 =
     53* Add REST API get variable info
     54* Fixed: checkout via webview
     55* Fixed: login with phone number
  • mobile-builder/trunk/api/class-mobile-builder-cart.php

    r2339538 r2344460  
    7979        register_rest_route( $this->namespace, 'update-order-review', array(
    8080            'methods'             => WP_REST_Server::CREATABLE,
    81             'callback'            => array( $this, 'mobile_builder_update_order_review' ),
     81            'callback'            => array( $this, 'update_order_review' ),
    8282            'permission_callback' => array( $this, 'user_permissions_check' ),
    8383        ) );
     
    169169        $currency = $request->get_param( 'currency' );
    170170
     171        $user_id = get_current_user_id();
     172        $user = get_user_by( 'id', $user_id );
     173        wp_set_current_user( $user_id, $user->user_login );
     174        wp_set_auth_cookie( $user_id );
     175
    171176        wp_redirect( wc_get_checkout_url() . "?mobile=1&theme=$theme&currency=$currency" );
    172177        exit;
     
    374379    }
    375380
    376     public function mobile_builder_update_order_review( $request ) {
     381    public function update_order_review( $request ) {
     382        global $WCFM, $WCFMmp;
     383
    377384//      check_ajax_referer( 'update-order-review', 'security' );
    378385
     
    405412                'billing_address_2' => $request->get_param( 'address_2' ) ? wc_clean( wp_unslash( $request->get_param( 'address_2' ) ) ) : null,
    406413                'billing_company'   => $request->get_param( 'company' ) ? wc_clean( wp_unslash( $request->get_param( 'company' ) ) ) : null,
     414//              'wcfmmp_user_location'   => $request->get_param( 'wcfmmp_user_location' ) ? wc_clean( wp_unslash( $request->get_param( 'wcfmmp_user_location' ) ) ) : null,
     415                'wcfmmp_user_location'   => "12 khuat duy tien thanh xuan hanoi"
    407416            )
    408417        );
     
    440449        }
    441450
    442         if ( apply_filters( 'wcfmmp_is_allow_checkout_user_location', true ) ) {
    443             if ( $request->get_param( 'wcfmmp_user_location' ) ) {
    444                 WC()->customer->set_props( array( 'wcfmmp_user_location' => sanitize_text_field( $request->get_param( 'wcfmmp_user_location' ) ) ) );
    445                 WC()->session->set( '_wcfmmp_user_location', sanitize_text_field( $request->get_param( 'wcfmmp_user_location' ) ) );
    446             }
    447             if ( $request->get_param( 'wcfmmp_user_location_lat' ) ) {
    448                 WC()->session->set( '_wcfmmp_user_location_lat', sanitize_text_field( $request->get_param( 'wcfmmp_user_location_lat' ) ) );
    449             }
    450 
    451             if ( $request->get_param( 'wcfmmp_user_location_lng' ) ) {
    452                 WC()->session->set( '_wcfmmp_user_location_lng', sanitize_text_field( $request->get_param( 'wcfmmp_user_location_lng' ) ) );
    453             }
    454         }
     451//      if ( apply_filters( 'wcfmmp_is_allow_checkout_user_location', true ) ) {
     452//          if ( $request->get_param( 'wcfmmp_user_location' ) ) {
     453//              WC()->customer->set_props( array( 'wcfmmp_user_location' => sanitize_text_field( $request->get_param( 'wcfmmp_user_location' ) ) ) );
     454//              WC()->session->set( '_wcfmmp_user_location', sanitize_text_field( $request->get_param( 'wcfmmp_user_location' ) ) );
     455//          }
     456//          if ( $request->get_param( 'wcfmmp_user_location_lat' ) ) {
     457//              WC()->session->set( '_wcfmmp_user_location_lat', sanitize_text_field( $request->get_param( 'wcfmmp_user_location_lat' ) ) );
     458//          }
     459//
     460//          if ( $request->get_param( 'wcfmmp_user_location_lng' ) ) {
     461//              WC()->session->set( '_wcfmmp_user_location_lng', sanitize_text_field( $request->get_param( 'wcfmmp_user_location_lng' ) ) );
     462//          }
     463//      }
    455464
    456465        WC()->customer->save();
  • mobile-builder/trunk/includes/class-mobile-builder.php

    r2324940 r2344460  
    260260
    261261        /**
    262          * Fillter add to cart before redirect to checkout page
    263          * @since 1.2.0
    264          */
    265         $this->loader->add_action( 'template_redirect', $plugin_public, 'template_redirect' );
    266 
    267         /**
    268262         * Add style for checkout page
    269263         * @since 1.2.0
  • mobile-builder/trunk/mobile-builder.php

    r2339538 r2344460  
    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.0.9
     13 * Version:           1.1.0
    1414 * Author:            Rnlab.io
    1515 * Author URI:        https://rnlab.io
  • mobile-builder/trunk/product/class-mobile-builder-product.php

    r2337209 r2344460  
    7777            'permission_callback' => array( $products, 'get_items_permissions_check' ),
    7878        ) );
    79 
     79        register_rest_route(  'wc/v3/products', '/(?P<product_id>[a-zA-Z0-9-]+)/variable', array(
     80            'methods' => 'GET',
     81            'callback' => array( $this, 'product_get_all_variable_data' )
     82        ));
     83
     84    }
     85
     86    /**
     87     *
     88     * Get list products variable
     89     *
     90     * @param $request
     91     *
     92     * @return array|WP_Error|WP_REST_Response
     93     */
     94    function product_get_all_variable_data($request){
     95        $product_id = $request->get_param('product_id');
     96        $handle = new WC_Product_Variable($product_id);
     97        $variation_attributes = $handle->get_variation_attributes();
     98        $variation_attributes_data = array();
     99        $variation_attributes_label = array();
     100        foreach($variation_attributes as $key => $attribute){
     101            $variation_attributes_result['attribute_' . sanitize_title( $key )] = $attribute;
     102            $variation_attributes_label['attribute_' . sanitize_title( $key )] = $key;
     103        }
     104        return array(
     105            'variation_attributes_label' => $variation_attributes_label,
     106            'variation_attributes'=> $variation_attributes_result,
     107            'available_variations' => $handle->get_available_variations()
     108        );
    80109    }
    81110
  • mobile-builder/trunk/public/class-mobile-builder-public.php

    r2337209 r2344460  
    359359
    360360        return $template;
    361     }
    362 
    363     /**
    364      * Add product to cart before redirect to checkout page
    365      *
    366      * @author Ngoc Dang
    367      * @since 1.2.0
    368      */
    369     public function template_redirect() {
    370 
    371         if ( isset( $_GET['mobile'] ) && isset( $_GET['line_items'] ) ) {
    372 
    373             if ( is_user_logged_in() && isset( $_GET['token'] ) ) {
    374 
    375                 $decode = $this->decode( $_GET['token'] );
    376 
    377                 if ( ! is_wp_error( $decode ) && get_current_user_id() != $decode->data->user_id ) {
    378 
    379                     $user_id = $decode->data->user_id;
    380 
    381                     wp_set_current_user( 0 );
    382 
    383                     $user = get_user_by( 'id', $user_id );
    384                     wp_set_current_user( $user_id, $user->user_login );
    385                     wp_set_auth_cookie( $user_id );
    386 
    387                     header( "Refresh:0" );
    388                 }
    389 
    390             } else if ( is_user_logged_in() && ! isset( $_GET['token'] ) ) {
    391 
    392                 wp_logout();
    393                 wp_set_current_user( 0 );
    394                 header( "Refresh:0" );
    395 
    396             } else if ( ! is_user_logged_in() && isset( $_GET['token'] ) ) {
    397 
    398                 $decode = $this->decode( $_GET['token'] );
    399 
    400                 if ( ! is_wp_error( $decode ) ) {
    401                     $user_id = $decode->data->user_id;
    402                     $user    = get_user_by( 'id', $user_id );
    403                     wp_set_current_user( $user_id, $user->user_login );
    404                     wp_set_auth_cookie( $user_id );
    405 
    406                     header( "Refresh:0" );
    407                 }
    408             }
    409 
    410             $line_items = json_decode( html_entity_decode( stripslashes( $_GET['line_items'] ) ), true );
    411 
    412             WC()->session->set( 'refresh_totals', true );
    413             WC()->cart->empty_cart();
    414 
    415             foreach ( $line_items as $item ) {
    416                 WC()->cart->add_to_cart( $item['product_id'], $item['quantity'], $item['variation_id'] );
    417             }
    418         }
    419361    }
    420362
     
    10981040            }
    10991041
     1042            add_user_meta( $user_id, 'digt_countrycode', $digt_countrycode, true );
     1043            add_user_meta( $user_id, 'digits_phone_no', $digits_phone_no, true );
    11001044            add_user_meta( $user_id, 'digits_phone', $digits_phone, true );
    1101             add_user_meta( $user_id, 'digt_countrycode', $digits_phone, true );
    1102             add_user_meta( $user_id, 'digits_phone_no', $digits_phone, true );
    1103 
    11041045        }
    11051046
Note: See TracChangeset for help on using the changeset viewer.