Changeset 2344460
- Timestamp:
- 07/22/2020 03:10:00 AM (6 years ago)
- Location:
- mobile-builder/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (1 diff)
-
api/class-mobile-builder-cart.php (modified) (5 diffs)
-
includes/class-mobile-builder.php (modified) (1 diff)
-
mobile-builder.php (modified) (1 diff)
-
product/class-mobile-builder-product.php (modified) (1 diff)
-
public/class-mobile-builder-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mobile-builder/trunk/README.txt
r2337209 r2344460 49 49 * Add wc validation in the add_to_cart function (Thanks @raaquino) 50 50 * 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 79 79 register_rest_route( $this->namespace, 'update-order-review', array( 80 80 'methods' => WP_REST_Server::CREATABLE, 81 'callback' => array( $this, ' mobile_builder_update_order_review' ),81 'callback' => array( $this, 'update_order_review' ), 82 82 'permission_callback' => array( $this, 'user_permissions_check' ), 83 83 ) ); … … 169 169 $currency = $request->get_param( 'currency' ); 170 170 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 171 176 wp_redirect( wc_get_checkout_url() . "?mobile=1&theme=$theme¤cy=$currency" ); 172 177 exit; … … 374 379 } 375 380 376 public function mobile_builder_update_order_review( $request ) { 381 public function update_order_review( $request ) { 382 global $WCFM, $WCFMmp; 383 377 384 // check_ajax_referer( 'update-order-review', 'security' ); 378 385 … … 405 412 'billing_address_2' => $request->get_param( 'address_2' ) ? wc_clean( wp_unslash( $request->get_param( 'address_2' ) ) ) : null, 406 413 '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" 407 416 ) 408 417 ); … … 440 449 } 441 450 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 // } 455 464 456 465 WC()->customer->save(); -
mobile-builder/trunk/includes/class-mobile-builder.php
r2324940 r2344460 260 260 261 261 /** 262 * Fillter add to cart before redirect to checkout page263 * @since 1.2.0264 */265 $this->loader->add_action( 'template_redirect', $plugin_public, 'template_redirect' );266 267 /**268 262 * Add style for checkout page 269 263 * @since 1.2.0 -
mobile-builder/trunk/mobile-builder.php
r2339538 r2344460 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. 0.913 * Version: 1.1.0 14 14 * Author: Rnlab.io 15 15 * Author URI: https://rnlab.io -
mobile-builder/trunk/product/class-mobile-builder-product.php
r2337209 r2344460 77 77 'permission_callback' => array( $products, 'get_items_permissions_check' ), 78 78 ) ); 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 ); 80 109 } 81 110 -
mobile-builder/trunk/public/class-mobile-builder-public.php
r2337209 r2344460 359 359 360 360 return $template; 361 }362 363 /**364 * Add product to cart before redirect to checkout page365 *366 * @author Ngoc Dang367 * @since 1.2.0368 */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 }419 361 } 420 362 … … 1098 1040 } 1099 1041 1042 add_user_meta( $user_id, 'digt_countrycode', $digt_countrycode, true ); 1043 add_user_meta( $user_id, 'digits_phone_no', $digits_phone_no, true ); 1100 1044 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 1104 1045 } 1105 1046
Note: See TracChangeset
for help on using the changeset viewer.