Plugin Directory

Changeset 3041939


Ignore:
Timestamp:
02/27/2024 01:28:25 PM (2 years ago)
Author:
connectordev
Message:

3.1.611.33

*Release Date - 27 Feb 2024*

Fixed First Name and Last Name value for guest customer bLoyal Connector.
Fixed Stored payment method websnippets API call multiple times.
Fixed invalid payment method issue on checkout page.
Removed checking message from Loyalty Tender Payment.

Location:
bloyal/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • bloyal/trunk/app/controller/class-bloyalcartcontroller.php

    r3025189 r3041939  
    2727                $is_guest                = ( is_user_logged_in() ) ? false : true;
    2828                $bLoyalCouponSession     = WC()->session->get( 'bloyal_coupon');
    29                 bLoyalLoggerService::write_custom_log( "\r\n ========== bLoyalCouponSessioncartuid ============\r\n" . json_encode( $bLoyalCouponSession ) );
     29                $bLoyalSessionCartuid    = WC()->session->get( 'bloyal_uid');
    3030                $bloyal_cart_data        = array(
    3131                    "CouponCodes"               => [$bLoyalCouponSession[0]['coupon_code']],
    32                     'Uid'                       => $cart_uid == '' ? $bLoyalCouponSession[0]['cart_uid'] : $cart_uid,
     32                    'Uid'                       => $cart_uid == '' ? $bLoyalSessionCartuid['u_id'] : $cart_uid,
    3333                    'ExternallyProcessedOrder'  => get_option( 'bloyal_use_order_engine' ) === 'true' ? false : true,
    3434                    'GuestCheckout'             => $is_guest,
     
    4040                    'DiscountDetails'           => $this->create_discount_details(),
    4141                );
    42                
    43                 bLoyalLoggerService::write_custom_log( "\r\n ========== bloyalcartdata ============\r\n" . json_encode( $bloyal_cart_data ) );
    4442                return $bloyal_cart_data;
    4543            } catch ( Exception $ex ) {
     
    103101                            $customer_data['EmailAddress'] = $customer['email'];
    104102                        }
    105                         $customer_data['FirstName']              = $customer['first_name'];
    106                         $customer_data['LastName']               = $customer['last_name'];
    107                         $customer_data['CompanyName']            = $customer['company'];
    108                         $customer_data['Phone1']                 = $customer['phone'];
     103
     104                       
     105                        // We have made some changes to store firstname, lastname, phone, and company name in connector.
     106
     107                        $customer_data['FirstName']              = $customer['first_name'] != '' ? $customer['first_name'] : $_REQUEST['billing_first_name'];
     108                        $customer_data['LastName']               = $customer['last_name'] != '' ? $customer['last_name'] : $_REQUEST['billing_last_name'];
     109                        $customer_data['CompanyName']            = $customer['company'] != '' ? $customer['company'] : $_REQUEST['billing_company'];
     110                        $customer_data['Phone1']                 = $customer['phone'] != '' ? $customer['phone'] : $_REQUEST['billing_phone'];
    109111                        $customer_data['BirthDate']              = isset( $_REQUEST['billing_birth_date'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['billing_birth_date'] ) ) : ''; //Added by Chetu Developer
    110112                        $customer_data['Address']                = array();
  • bloyal/trunk/app/controller/class-bloyalcontroller.php

    r3025189 r3041939  
    728728            try {
    729729                $woo_session_id = WC()->session->get_customer_id();
    730                 bLoyalLoggerService::write_custom_log( "\r\n ========== woo session id ============\r\n" . json_encode( $woo_session_id ) );
    731730                if ( $woo_session_id ) {
    732731                    $session = WC()->session->get( 'bloyal_uid' );
    733                     bLoyalLoggerService::write_custom_log( "\r\n ========== woo session data ============\r\n" . json_encode( $session ) );
    734732                    if ( ! empty( $session ) ) {
    735733                        if ( ! empty( $session['session_id'] ) ) {
  • bloyal/trunk/app/controller/class-bloyalstoredpaymentmethod.php

    r3025189 r3041939  
    771771                try {
    772772
    773                     $action   = $this->domain_name."/".$this->device_code."/snippets/websnippetprofiles/summaries?type=PaymentMethods";
    774 
    775                     $post_url = $this->loyalty_engine_url . '/api/v4/' . ( $action );
    776 
    777                     $args     = array(
    778 
    779                         'headers' => array(
    780 
    781                             'Content-Type' => 'application/json',
    782 
    783                         ),
    784 
    785                         'body'    => $content,
    786 
    787                         'method'  => 'GET',
    788 
    789                         'timeout' => 45,
    790 
    791                     );
    792 
    793                     $response        = wp_remote_get( $post_url, $args );
    794 
    795                     $response_status = wp_remote_retrieve_response_code( $response );
    796 
    797                     $response        = wp_remote_retrieve_body( $response );
    798 
    799                     $obj_response    = json_decode( $response, true );
    800 
    801                     if ( is_wp_error( $obj_response ) ) {
    802 
    803                         $error = $response->get_error_message();
    804 
    805                         return $error;
     773                    // this code will run when the user is logged in
     774                    if(is_user_logged_in() && $this->get_option('enabled') == 'yes'){
     775                        $action   = $this->domain_name."/".$this->device_code."/snippets/websnippetprofiles/summaries?type=PaymentMethods";
     776                        $post_url = $this->loyalty_engine_url . '/api/v4/' . ( $action );
     777                        $args     = array(
     778
     779                            'headers' => array(
     780
     781                                'Content-Type' => 'application/json',
     782
     783                            ),
     784
     785                            'body'    => $content,
     786
     787                            'method'  => 'GET',
     788
     789                            'timeout' => 45,
     790
     791                        );
     792
     793                        $response        = wp_remote_get( $post_url, $args );
     794
     795                        $response_status = wp_remote_retrieve_response_code( $response );
     796
     797                        $response        = wp_remote_retrieve_body( $response );
     798
     799                        $obj_response    = json_decode( $response, true );
     800
     801                        if ( is_wp_error( $obj_response ) ) {
     802
     803                            $error = $response->get_error_message();
     804
     805                            return $error;
     806
     807                        } else {
     808
     809                            $payment_snippets_option = array();
     810
     811                            if(!empty($obj_response['data']) && isset($obj_response['data']) && $obj_response['status'] === 'success') {
     812
     813                                $payment_snippets_option['0'] = "Select payment snippets";
     814
     815                                $payment_snippets_data        = $obj_response['data'];
     816
     817                                $payment_snippets_array       = array();
     818
     819                                foreach($payment_snippets_data as $payment_snippets_value ) {
     820
     821                                    $payment_snippets_uid           = $payment_snippets_value['Uid'];
     822
     823                                    $payment_snippets_code          = $payment_snippets_value['Code'];
     824
     825                                    $payment_snippets_name          = $payment_snippets_value['Name'];
     826
     827                                    $payment_snippets_array['Code'] = $payment_snippets_code;
     828
     829                                    $payment_snippets_array['Name'] = $payment_snippets_name;
     830
     831                                    $payment_snippets_option[$payment_snippets_uid] = $payment_snippets_code.','.$payment_snippets_name;
     832
     833                                   
     834
     835                                    $payment_snippets_json = json_encode( $payment_snippets_array );
     836
     837                                    update_option($payment_snippets_uid, $payment_snippets_json);
     838
     839                                }
     840
     841                                return  $payment_snippets_option;
     842
     843                            }else {
     844
     845                                return  $payment_snippets_option;
     846
     847                            }
     848
     849                        }
     850
     851                }
     852
     853                } catch ( Exception $ex ) {
     854
     855                    bLoyalLoggerService::write_custom_log( $ex->getMessage(), 3 );
     856
     857                }
     858
     859            }
     860
     861
     862
     863
     864
     865            public function payment_web_snippets_callback() {
     866
     867
     868
     869                 try {
     870
     871                    if(!empty($this->stored_payment_web_snippets_profile) && $this->stored_payment_web_snippets_profile  != '0') {
     872
     873                        $cart_data                                  = WC()->session->get( 'bloyal_cart_data');
     874
     875                        $page_id                                    = get_option( 'woocommerce_myaccount_page_id' );
     876
     877                        $login_page                                 = get_permalink( $page_id );
     878
     879                        $store_payment_json_data                    = get_option($this->stored_payment_web_snippets_profile);
     880
     881                        $store_payment_json_values                  = json_decode($store_payment_json_data, TRUE);
     882
     883                        $snippet_code                               = $store_payment_json_values['Code'];
     884
     885                        $bloyal_snippet_args                        = array();
     886
     887                        $bloyal_snippet_args['DeviceCode']          = $this->device_code;
     888
     889                        $bloyal_snippet_args['CartUid']             = $cart_data->Cart->Uid;
     890
     891                        $bloyal_snippet_args['LoginUrl']            = $login_page;
     892
     893                        $bloyal_snippet_args['OnSnippetComplete']   = "PaymentSnippetCompleteFn";
     894
     895                        $bloyal_snippet_args['PaymentRedirectToHome']   = true;
     896
     897                        $snippets_api_url                           = get_option( 'web_snippets_api_url' );
     898
     899                        $snippets_src                               = 'https://snippetsbeta.bloyal.io/bLoyalSnippetLoader.js';
     900
     901                        $alert_snippet_div                          = "<div data-bloyal-snippet-code='".$snippet_code."' data-bloyal-login-domain='".$this->domain_name."'  data-bloyal-snippet-args='".wp_json_encode($bloyal_snippet_args, TRUE)."' id='root'></div><script> function PaymentSnippetCompleteFn(paymentMethod) { jQuery.ajax( { type: 'POST', dataType : 'JSON',url: httpAdminUrl, data: { action: 'bloyal_stored_payment_method', method_uid: paymentMethod.Uid }, beforeSend: function(){  jQuery('#loading_resubmit').show(); }, success:function(responseData){  }, complete:function(responseData){jQuery('#loading_resubmit').hide(); } } ); console.log(paymentMethod); } </script>";
     902
     903                         
     904
     905                        return $alert_snippet_div;
    806906
    807907                    } else {
    808908
    809                         $payment_snippets_option = array();
    810 
    811                         if(!empty($obj_response['data']) && isset($obj_response['data']) && $obj_response['status'] === 'success') {
    812 
    813                             $payment_snippets_option['0'] = "Select payment snippets";
    814 
    815                             $payment_snippets_data        = $obj_response['data'];
    816 
    817                             $payment_snippets_array       = array();
    818 
    819                             foreach($payment_snippets_data as $payment_snippets_value ) {
    820 
    821                                 $payment_snippets_uid           = $payment_snippets_value['Uid'];
    822 
    823                                 $payment_snippets_code          = $payment_snippets_value['Code'];
    824 
    825                                 $payment_snippets_name          = $payment_snippets_value['Name'];
    826 
    827                                 $payment_snippets_array['Code'] = $payment_snippets_code;
    828 
    829                                 $payment_snippets_array['Name'] = $payment_snippets_name;
    830 
    831                                 $payment_snippets_option[$payment_snippets_uid] = $payment_snippets_code.','.$payment_snippets_name;
    832 
    833                                
    834 
    835                                 $payment_snippets_json = json_encode( $payment_snippets_array );
    836 
    837                                 update_option($payment_snippets_uid, $payment_snippets_json);
    838 
    839                             }
    840 
    841                             return  $payment_snippets_option;
    842 
    843                         }else {
    844 
    845                             return  $payment_snippets_option;
    846 
    847                         }
     909                        $alert_snippet_div = "Payment snippets not found, Place order with another payment method !";
     910
     911                        return $alert_snippet_div;
    848912
    849913                    }
    850914
    851                     bLoyalLoggerService::write_custom_log( "\n\r==========bloyal_stored_payment_method_websnippetprofiles============ \r\n" . json_encode( $obj_response ) );
    852 
    853915                } catch ( Exception $ex ) {
    854916
     
    859921            }
    860922
    861 
    862 
    863 
    864 
    865             public function payment_web_snippets_callback() {
    866 
    867 
    868 
    869                  try {
    870 
    871                     if(!empty($this->stored_payment_web_snippets_profile) && $this->stored_payment_web_snippets_profile  != '0') {
    872 
    873                         $cart_data                                  = WC()->session->get( 'bloyal_cart_data');
    874 
    875                         $page_id                                    = get_option( 'woocommerce_myaccount_page_id' );
    876 
    877                         $login_page                                 = get_permalink( $page_id );
    878 
    879                         $store_payment_json_data                    = get_option($this->stored_payment_web_snippets_profile);
    880 
    881                         $store_payment_json_values                  = json_decode($store_payment_json_data, TRUE);
    882 
    883                         $snippet_code                               = $store_payment_json_values['Code'];
    884 
    885                         $bloyal_snippet_args                        = array();
    886 
    887                         $bloyal_snippet_args['DeviceCode']          = $this->device_code;
    888 
    889                         $bloyal_snippet_args['CartUid']             = $cart_data->Cart->Uid;
    890 
    891                         $bloyal_snippet_args['LoginUrl']            = $login_page;
    892 
    893                         $bloyal_snippet_args['OnSnippetComplete']   = "PaymentSnippetCompleteFn";
    894 
    895                         $bloyal_snippet_args['PaymentRedirectToHome']   = true;
    896 
    897                         $snippets_api_url                           = get_option( 'web_snippets_api_url' );
    898 
    899                         $snippets_src                               = 'https://snippetsbeta.bloyal.io/bLoyalSnippetLoader.js';
    900 
    901                         $alert_snippet_div                          = "<div data-bloyal-snippet-code='".$snippet_code."' data-bloyal-login-domain='".$this->domain_name."'  data-bloyal-snippet-args='".wp_json_encode($bloyal_snippet_args, TRUE)."' id='root'></div><script> function PaymentSnippetCompleteFn(paymentMethod) { jQuery.ajax( { type: 'POST', dataType : 'JSON',url: httpAdminUrl, data: { action: 'bloyal_stored_payment_method', method_uid: paymentMethod.Uid }, beforeSend: function(){  jQuery('#loading_resubmit').show(); }, success:function(responseData){  }, complete:function(responseData){jQuery('#loading_resubmit').hide(); } } ); console.log(paymentMethod); } </script>";
    902 
    903                          
    904 
    905                         return $alert_snippet_div;
    906 
    907                     } else {
    908 
    909                         $alert_snippet_div = "Payment snippets not found, Place order with another payment method !";
    910 
    911                         return $alert_snippet_div;
    912 
    913                     }
    914 
    915                 } catch ( Exception $ex ) {
    916 
    917                     bLoyalLoggerService::write_custom_log( $ex->getMessage(), 3 );
    918 
    919                 }
    920 
    921             }
    922 
    923923        }
    924924
  • bloyal/trunk/app/controller/gift_card_tender_controller.php

    r3025189 r3041939  
    231231                            $("#giftCardMessage").text(response_obj.message);
    232232                            $("#check_balance").prop('disabled', false);
    233                             jQuery(document.body).trigger("update_checkout");
     233                            $('form.checkout').on('change', 'input[name="payment_method"]', function(){
     234                                $(document.body).trigger('update_checkout');
     235                            });
     236                            // jQuery(document.body).trigger("update_checkout");
    234237                            return false;
    235238                        });
  • bloyal/trunk/app/controller/loyalty_dollar_tender_controller.php

    r3025189 r3041939  
    150150                        if(sessionStorage.getItem('loyalty_dollar') === null) {
    151151                            $("input[type='radio'][value='bloyal_loyalty_dollar']").click(function(){
     152                                //chetu code to hide checking message on payment method selection
     153                                $('form.checkout').on('change', 'input[name="payment_method"]', function(){
     154                                    $("#storedPaymentMessage1").hide();
     155                                });
    152156                                stored_payment_snippets(this.value);
    153157                            });
     
    177181                                            sessionStorage.setItem('bL_sk', bl_session_key);
    178182                                            $('#check_loyalty_balance').click(function() {
     183                                                        $("#storedPaymentMessage1").text('checking...');
    179184                                                      $("#check_loyalty_balance").prop('disabled', true);
    180185                                                      var data = {
     
    239244                                                        $("#check_loyalty_balance").prop('disabled', true);
    240245                                                        $("#apply_loyalty_balance").prop('disabled', true);
    241                                                         jQuery(document.body).trigger("update_checkout");
     246                                                        $('form.checkout').on('change', 'input[name="payment_method"]', function(){
     247                                                            $(document.body).trigger('update_checkout');
     248                                                        });
     249                                                        // jQuery(document.body).trigger("update_checkout");
    242250                                                        return false;
    243251                                                      });
  • bloyal/trunk/bloyal.php

    r3025189 r3041939  
    44 * Plugin URI:
    55 * Description: bLoyal provides real-time customer loyalty and omni-channel order processing to your WooCommerce web store.
    6  * Version: 3.1.611.30
     6 * Version: 3.1.611.33
    77 * Author:  bLoyal
    88 */
     
    667667
    668668add_action( 'woocommerce_before_calculate_totals', 'bloyal_calculate_bloyal_promotions', 20, 2 );
     669
    669670function bloyal_calculate_bloyal_promotions( $cart_object, $order_id = 0 ) {
    670671    try {
     
    681682        $is_bloyal_applied_shipping_charges = get_option( 'bloyal_applied_shipping_charges' );
    682683        $third_party_cart_uid               = WC()->session->get( 'third_party_cardId' );
    683 
    684         bLoyalLoggerService::write_custom_log( "\r\n ========== third party cardId ============\r\n" . json_encode( $third_party_cart_uid ) );
    685         bLoyalLoggerService::write_custom_log( "\r\n ==========  bloyal uid value ============\r\n" . json_encode( $bloyal_obj->get_uid() ) );
    686 
    687684        $cart_uid                           = ( null != $third_party_cart_uid && '' != $third_party_cart_uid ) ? $third_party_cart_uid : $bloyal_obj->get_uid();
    688685        $bloyalCart['Cart']                 = $objectBloyalCarController->make_bloyal_cart( $cart_object, $cart_uid, $is_bloyal_applied_taxes, $order_id );
     
    31083105}
    31093106
    3110 add_filter( 'user_register', 'get_bloyal_session_registration');
    3111 function get_bloyal_session_registration($user_id) {
    3112     $current_user  = get_user_by('id', $user_id);
    3113     $user_email = $current_user->data->user_email;
    3114     get_bloyal_session($user_id, $user_email);
    3115 }
    3116 
    3117 //add_action('wp_login', 'get_bloyal_session_login', 10, 2);
    3118 function get_bloyal_session_login($user, $user_login) {
    3119     $user_email = $user_login->user_email;
    3120     $user_id = $user->ID;
    3121     get_bloyal_session($user_id, $user_email);
    3122 }
    3123 
    3124 function get_bloyal_session($user_id, $user_email) {
    3125     $bloyal_snippets_obj = new BloyalSnippetsController();
    3126     $bloyal_obj          = new BloyalController();
    3127     $device_context = $bloyal_snippets_obj->send_curl_request('', 'contextdevices', 'loyaltyengine', 0);
    3128     $snippet_device = $device_context->data->Code;
    3129     $snippet_domain = get_option('bloyal_domain_name');
    3130     $snippets_api_url = get_option('web_snippets_api_url');
    3131     $loyalty_engine_api_url = get_option('loyalty_engine_api_url');
    3132     $access_key = get_option('bloyal_access_key');
    3133     $customer_uid = $bloyal_obj->bloyal_fetch_customer_uid( $user_id, $user_email );
    3134     if (empty($customer_uid)) {
    3135         // code to add dob in customer data
    3136         $customer_birth_date = '';
    3137         if(WC()->session->get('billing_birth_date') != ''){
    3138             $customer_birth_date = WC()->session->get('billing_birth_date');
    3139         }
    3140         $action = 'customers/commands/signups';
    3141         $user_details = array('Customer' => array('EmailAddress' => $user_email), 'BirthDate' => $customer_birth_date, 'DeviceCode' => $snippet_device);
     3107// add_filter( 'user_register', 'get_bloyal_session_registration');
     3108// function get_bloyal_session_registration($user_id) {
     3109// $current_user  = get_user_by('id', $user_id);
     3110// $user_email = $current_user->data->user_email;
     3111// get_bloyal_session($user_id, $user_email);
     3112// }
     3113
     3114// //add_action('wp_login', 'get_bloyal_session_login', 10, 2);
     3115// function get_bloyal_session_login($user, $user_login) {
     3116// $user_email = $user_login->user_email;
     3117// $user_id = $user->ID;
     3118// get_bloyal_session($user_id, $user_email);
     3119// }
     3120
     3121// function get_bloyal_session($user_id, $user_email) {
     3122// $bloyal_snippets_obj = new BloyalSnippetsController();
     3123// $bloyal_obj          = new BloyalController();
     3124// $device_context = $bloyal_snippets_obj->send_curl_request('', 'contextdevices', 'loyaltyengine', 0);
     3125// $snippet_device = $device_context->data->Code;
     3126// $snippet_domain = get_option('bloyal_domain_name');
     3127// $snippets_api_url = get_option('web_snippets_api_url');
     3128// $loyalty_engine_api_url = get_option('loyalty_engine_api_url');
     3129// $access_key = get_option('bloyal_access_key');
     3130// $customer_uid = $bloyal_obj->bloyal_fetch_customer_uid( $user_id, $user_email );
     3131// if (empty($customer_uid)) {
     3132//      // code to add dob in customer data
     3133//      $customer_birth_date = '';
     3134//      if(WC()->session->get('billing_birth_date') != ''){
     3135//          $customer_birth_date = WC()->session->get('billing_birth_date');
     3136//      }
     3137//      $action = 'customers/commands/signups';
     3138//      $user_details = array('Customer' => array('EmailAddress' => $user_email), 'BirthDate' => $customer_birth_date, 'DeviceCode' => $snippet_device);
    31423139       
    3143         bLoyalLoggerService::write_custom_log( "Customer Signups Request \n\r" . wp_json_encode( $user_details ) . "\r\n ======================\r\n", 1 );
     3140//      bLoyalLoggerService::write_custom_log( "Customer Signups Request \n\r" . wp_json_encode( $user_details ) . "\r\n ======================\r\n", 1 );
    31443141       
    3145         $response = $bloyal_snippets_obj->send_curl_request( $user_details, $action, 'loyaltyengine', 1 );
    3146         bLoyalLoggerService::write_custom_log( "Customer Signups Response \n\r" . wp_json_encode( $response ) . "\r\n ======================\r\n", 1 );
    3147     }
     3142//      $response = $bloyal_snippets_obj->send_curl_request( $user_details, $action, 'loyaltyengine', 1 );
     3143//      bLoyalLoggerService::write_custom_log( "Customer Signups Response \n\r" . wp_json_encode( $response ) . "\r\n ======================\r\n", 1 );
     3144// }
    31483145   
    3149 }
     3146// }
    31503147// code to disable store payment method on checkout page if user is not logged
    31513148function rp_filter_gateways( $args ) {
  • bloyal/trunk/readme.txt

    r3025189 r3041939  
    1313Requires PHP: 5.6
    1414
    15 Stable tag: 3.1.611.16
     15Stable tag: 3.1.611.33
    1616
    1717License: GPLv2 or later
     
    254254Fixed bLoyal Applied tax issue mismatched on checkout page.
    255255
    256 
    257 
    258 
    259 
    260 
     256= 3.1.611.33 =
     257
     258*Release Date - 27 Feb 2024*
     259
     260Fixed First Name and Last Name value for guest customer bLoyal Connector.
     261Fixed Stored payment method websnippets API call multiple times.
     262Fixed invalid payment method issue on checkout page.
     263Removed checking message from Loyalty Tender Payment.
    261264
    262265== Changes ==
     
    288291
    289292
    290 = 3.1.611.30 =
     293= 3.1.611.33 =
    291294
    292295
Note: See TracChangeset for help on using the changeset viewer.