Beispiel #1
0
 public static function getActiveCartData()
 {
     /*
      * 1. Check in woocommerce session i.e cookies.
      * 2. Check in woocommerce session in database.
      * */
     $details = array('cart_data_alone' => array(), 'wc_session_data_serialized' => '', 'cart_items_n_quantity_hash' => array());
     $wcSession = new WC_Session_Handler();
     $customerId = $wcSession->get_customer_id();
     $userId = is_user_logged_in() ? get_current_user_id() : 0;
     $wcCustId = !empty($customerId) ? $customerId : $userId;
     if (!empty($wcCustId)) {
         $wcSessionData = get_option('_wc_session_' . $wcCustId);
         self::debugLog(json_encode($wcSessionData));
         if (!empty($wcSessionData)) {
             $details['cart_data_alone'] = unserialize($wcSessionData['cart']);
             $details['wc_session_data_serialized'] = serialize($wcSessionData);
             $details['cart_items_n_quantity_hash'] = WpsWcAFR::getItemsNQuantityHashFromWcSession($wcSessionData);
         }
     }
     return $details;
 }