<?php

	function getCart($cartId){
		global $config;
		$curl = curl_init();
		curl_setopt_array($curl, array(
		  CURLOPT_URL => "https://api.bigcommerce.com/stores/".STORE_HASH."/v3/checkouts/".$cartId,
		  CURLOPT_RETURNTRANSFER => true,
		  CURLOPT_ENCODING => "",
		  CURLOPT_MAXREDIRS => 10,
		  CURLOPT_TIMEOUT => 30,
		  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		  CURLOPT_CUSTOMREQUEST => "GET",
		  CURLOPT_HTTPHEADER => array(
		    "accept: application/json",
		    "content-type: application/json",
		    "x-auth-token: ".AUTH_TOKEN
		  ),
		));

		$response = curl_exec($curl);
		curl_close($curl);

		$cart_data = json_decode($response,true);

		return $cart_data;
	}

	function utf8ize($d) {
	    if (is_array($d)) {
	        foreach ($d as $k => $v) {
	            $d[$k] = utf8ize($v);
	        }
	    } else if (is_string ($d)) {
	        return utf8_encode($d);
	    }
	    return $d;
	}

	function getSingleColumn($column,$sql){
        global $Conn_db;
        $res = mysqli_query($Conn_db,$sql);
        if ($row = mysqli_fetch_assoc($res) )
            return $row[$column];
    }

?>