<?php
	//[fbbttm-checkout]
	if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
	function fbbttm_foodboxbooker_checkout(){

		global $fbbttm_helperobj,$fbbttm_cartobj,$cartsummary,$fbbttm_fullcartinfo,$userid,$fbbttm_emailobj;

		$return = $contactinfo = $cartsummary = $address= $cartsummarynew='';
			

			$fbbttm_fullcartinfo = $fbbttm_cartobj->fbbttm_get_basic_cartinfo();

			if(!empty($fbbttm_fullcartinfo))
			{
			
			$userid = $fbbttm_helperobj->fbbttm_check_user_loginornot();

			$display ='';

				if(!empty($userid))
				{
					$display ="style='display:block'"; 
				}
				else
				{
					$display ="style='display:none'"; 
				}

				$cartsummary = $fbbttm_cartobj->fbbttm_get_cart_summaryata($fbbttm_fullcartinfo);

			 	if( file_exists(FBBTTM_DIR . 'templates/checkout/contact-info.php') ){	
					$contactinfopath = FBBTTM_DIR . 'templates/checkout/contact-info.php';
					$contactinfo  =  $fbbttm_helperobj->fbbttm_get_filecontent( $contactinfopath);
				}

				if( file_exists(FBBTTM_DIR . 'templates/cartsummary.php') ){	

					$cartsummarypath = FBBTTM_DIR . 'templates/checkout/cartsummary.php';
					$cartsummarynew  =  $fbbttm_helperobj->fbbttm_get_filecontent( $cartsummarypath);

			    }

			    if( file_exists(FBBTTM_DIR . 'templates/checkout/addressform.php') ){	
			    	 $addresspath = FBBTTM_DIR . 'templates/checkout/addressform.php';
			    	 $address = $fbbttm_helperobj->fbbttm_get_filecontent( $addresspath);
			     }


			     if( file_exists(FBBTTM_DIR . 'templates/checkout/placeorderform.php') ){	

			    	 $placeorderformpath = FBBTTM_DIR . 'templates/checkout/placeorderform.php';
			    	 $placeorderform = $fbbttm_helperobj->fbbttm_get_filecontent( $placeorderformpath);
			    	
			     }

				
			$return .='<div class="row fbbttm-checkout-page-info">
					   <div class="col-md-8 fbbttm-delivery-form">';

			$return .= $contactinfo; 

			$return .= '<div class="fbbttm-cehckout-deliveryinfo" '.$display.'>

			 <h4 class="">'.esc_html__("Delivery information",'foodboxbooker').'</h4>';
			$return .= $address; 

			$return .= '</div>';


			$return .= '</div>';

			$return .='<div class="col-md-4 fbbttm-checkout-process">';

			$return.= '<h3>'.esc_html__("Order Summary",'foodboxbooker').'</h3>';

			$return .='<div class="fbbttm-checkout-titleprocess">';

			$return .= $cartsummarynew;

			$return .= '<div class="fbbttm-cehckout-orderlaststep" '.$display.'>

			<h4 class="">'.esc_html__("Payment options",'foodboxbooker').'</h4>';

			$return .= $placeorderform; 

			$return .= '</div>'; 

			$return .= '</div>';

			$return .= '<div class="fbbttm-ordersuccess-message"></div>';
			
			$return .= '</div>';

			}
			else
			{

				$return .='<p>'.esc_html__('Your cart is empty','foodboxbooker').'</p>';

			}

			

		return $return;

	}
	add_shortcode( 'fbbttm-checkout', 'fbbttm_foodboxbooker_checkout' );
?>