<?php

// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

use CodeClouds\Unify\Model\Order as OrderModel;
?>

<div style="margin-top: 10px; display: inline-block;">
    <h3>Payment Information</h3>
    <?php
        $unify_connection_type = CodeClouds\Unify\Model\Config\Connection::get(OrderModel::get_connection($order->get_id(), 'connection'));
    ?>
    <p><strong><?php echo esc_html(__('Connection', 'unify')) ?>:</strong> <?php echo esc_html($unify_connection_type); ?></p>

    <?php
    if (!empty(OrderModel::get_connection($order->get_id(), 'connection_id')))
    {
        $unify_connection = \CodeClouds\Unify\Model\Connection::get_post_meta(OrderModel::get_connection($order->get_id(), 'connection_id'));

        if (!empty($unify_connection['unify_connection_campaign_id'][0]))
        {
            ?>
            <p><strong><?php echo esc_html(__('Campaign ID', 'unify')) ?>:</strong> <?php echo esc_html($unify_connection['unify_connection_campaign_id'][0]) ?></p>
            <?php
        }
        $unify_connection_type_index = !empty($unify_connection)?$unify_connection['unify_connection_crm'][0]:'';

        if (!empty($unify_connection_type_index === 'limelight'))
        {
            $unify_shipping_id = get_post_meta($order->get_id(), "_codeclouds_unify_shipping_id");
            ?>
            <p><strong><?php echo esc_html(__('Shipping ID', 'unify')) ?>:</strong> <?php echo esc_html($unify_shipping_id[0]);?></p>
            <?php
        }else{
            if(!empty($unify_connection['unify_connection_shipping_id'][0])){
            ?>
            <p><strong><?php echo esc_html(__('Shipping ID', 'unify')) ?>:</strong> <?php echo esc_html($unify_connection['unify_connection_shipping_id'][0]) ?></p>
        <?php 
            }
        }
    }
    ?>
</div>