<?php defined( 'ABSPATH' ) or die( "Cannot access pages directly." );

if ( ! function_exists( 'whcom_init' ) ) {
	function whcom_init() {
		if ( ! session_id() ) {
			session_start();
		}
		if ( ! isset( $_SESSION['whcom_cart'] ) ) {
			$_SESSION['whcom_cart'] = [];
		}
		if ( ! isset( $_SESSION['whcom_cart']['current_item'] ) ) {
			$_SESSION['whcom_cart']['current_item'] = - 1;
		}
		if ( ! isset( $_SESSION['whcom_cart']['all_items'] ) ) {
			$_SESSION['whcom_cart']['all_items'] = [];
		}
		if ( ! isset( $_SESSION['whcom_cart']['all_items_view'] ) ) {
			$_SESSION['whcom_cart']['all_items_view'] = [];
		}
		if ( ! isset( $_SESSION['whcom_cart']['order_specific'] ) ) {
			$_SESSION['whcom_cart']['order_specific'] = [];
		}

		if ( ! isset( $_SESSION['whcom_cart']['cart_domains'] ) ) {
			$_SESSION['whcom_cart']['cart_domains'] = [];
		}
		if ( ! isset( $_SESSION['whcom_cart']['cart_products'] ) ) {
			$_SESSION['whcom_cart']['cart_products'] = [];
		}
		if ( ! isset( $_SESSION['whcom_whmcs_settings'] ) ) {
			$_SESSION['whcom_whmcs_settings'] = [];
		}
		if ( ! isset( $_SESSION['whcom_user'] ) ) {
			$_SESSION['whcom_user'] = [];
		}

		if ( ! isset( $_SESSION['whcom_currencies_updated'] ) ) {
			$_SESSION['whcom_current_currency_id'] = '1';
			$_SESSION['currency']                  = '1';
			$_SESSION['whcom_current_currency']    = [
				'id'      => '1',
				'code'    => 'USD',
				'prefix'  => '$',
				'suffix'  => 'USD',
				'format'  => '1',
				'rate'    => '1.0000',
				'default' => '1',
			];
			$_SESSION['whcom_all_currencies']      = [
				[
					'id'      => '1',
					'code'    => 'USD',
					'prefix'  => '$',
					'suffix'  => 'USD',
					'format'  => '1',
					'rate'    => '1.0000',
					'default' => '1',
				]
			];
			whcom_update_currencies();
		}
	}
}
add_action( 'init', 'whcom_init' );



