Plugin Directory

Changeset 3148545


Ignore:
Timestamp:
09/09/2024 09:18:17 AM (18 months ago)
Author:
revechat
Message:

Issue fixing for getting current customer

Location:
revechat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • revechat/tags/6.2.2/revechat.php

    r3060324 r3148545  
    8080       
    8181        $user_id = apply_filters( 'determine_current_user', false );
    82         $customerId=wp_set_current_user( $user_id );
    83        
    84        
    85         WC()->customer = new WC_Customer( $customerId, true );
     82        $customer=wp_set_current_user( $user_id );
     83       
     84       
     85        WC()->customer = new WC_Customer( $customer, true );
    8686        WC()->cart = new WC_Cart();
    8787       
    88         $response = new WP_REST_Response($this->getCartPayload($customerId), 200);
     88        $response = new WP_REST_Response($this->getCartPayload($customer), 200);
    8989       
    9090
     
    9393        return $response;
    9494
    95     } 
     95    }   
    9696   
    9797
     
    102102     *
    103103     */
    104     public function getCartPayload($customerId)
     104    public function getCartPayload($currentCustomer)
    105105    {
    106106        $products = array();
     
    124124       
    125125   
    126         if (is_numeric($customerId))
     126        if (isset($currentCustomer) && isset($currentCustomer->ID) )
    127127        {
    128           $customer->customerId = $customerId;
     128          $customer->customerId = $currentCustomer->ID;
    129129        }
    130130       
  • revechat/trunk/revechat.php

    r3060324 r3148545  
    8080       
    8181        $user_id = apply_filters( 'determine_current_user', false );
    82         $customerId=wp_set_current_user( $user_id );
    83        
    84        
    85         WC()->customer = new WC_Customer( $customerId, true );
     82        $customer=wp_set_current_user( $user_id );
     83       
     84       
     85        WC()->customer = new WC_Customer( $customer, true );
    8686        WC()->cart = new WC_Cart();
    8787       
    88         $response = new WP_REST_Response($this->getCartPayload($customerId), 200);
     88        $response = new WP_REST_Response($this->getCartPayload($customer), 200);
    8989       
    9090
     
    9393        return $response;
    9494
    95     } 
     95    }   
    9696   
    9797
     
    102102     *
    103103     */
    104     public function getCartPayload($customerId)
     104    public function getCartPayload($currentCustomer)
    105105    {
    106106        $products = array();
     
    124124       
    125125   
    126         if (is_numeric($customerId))
     126        if (isset($currentCustomer) && isset($currentCustomer->ID) )
    127127        {
    128           $customer->customerId = $customerId;
     128          $customer->customerId = $currentCustomer->ID;
    129129        }
    130130       
Note: See TracChangeset for help on using the changeset viewer.