<div class="mobile-banner-wrap relative">
    <div class="layer"></div>
    <img class="mobile-banner" src="<?= base_url('assets/images/banner-5-mobile.jpg') ?>"></div>
<div id="parallax-wrap" class="parallax-search" data-parallax="scroll" data-position="top" data-bleed="10" data-image-src="/assets/images/banner-5-mobile.jpg">
    <div class="search-wraps">
        <?php if(isset($_SESSION['orderData'])) { ?>
            <h1>Thank You</h1><p>Your order has been placed.</p>
        <?php }else { ?>
            <h1>oops something went wrong</h1>
        <?php } ?>
    </div> <!--search-wraps-->
</div> <!--parallax-container-->
<div class="sections section-grey2 section-receipt"> <div class="container">
    <?php
    $orderinfo = $receiptData['data'];
    // print_r($orderinfo);
    foreach ($orderinfo as $item) {
      if ($item['label'] === 'Reference #') {
        $reference = $item['value'];
        // print($reference);
      }
    }
    
    $orderinfo1 = $receiptData['html'];
    // print_r($orderinfo1);
    if (preg_match('/<div.*?>Total<\/div>\s*<div.*?>([\d.]+)/', $orderinfo1, $matches)) {
        $total = $matches[1];
        // echo "Total value is: $total";
    } else {
        $total = 0;
        // echo "Total value not found!";
    }
?>
        <?php if(isset($_SESSION['orderData'])) { ?>
        <div class="inner" id="receipt-content"> <h1>Order Details</h1>
            <div class="box-grey"> <div class="text-center bottom10">
                    <i class="ion-ios-checkmark-outline i-big-extra green-text"></i> </div>
                <table class="table table-striped">
                    <tbody>
                    <?php foreach ($receiptData['data'] as $row) { ?>
                        <tr>
                            <td><?= $row['label']; ?></td>
                            <td class="text-right"><?= $row['value']; ?></td>
                        </tr>
                    <?php } ?>
                    </tbody>
                </table>

                <?= $receiptData['html']; ?>
                <!--box-grey--> </div> <!--inner-->
            <div class="row">
                <div class="col-sm-12 text-right">
                    <a href="javascript:;" class="print-receipt" style="display:none"><i class="ion-ios-printer-outline"></i></a>
                </div> <!--col--> </div> <!--row--> </div> <!--container--></div> <!--section-receipt-->
    <?php }else { ?>
        <h3 class="text-danger">merchant is not available</h3>
    <?php } ?>
</div></div>
<script>
    $( document ).on( "click", ".print-receipt", function() {
        $('#receipt-content');
    });
</script>
<!-- Event snippet for Website traffic conversion page -->
	<script>
        <?php
            $getUrl .= "$_SERVER[REQUEST_URI]";
            if (basename($getUrl) == 'receipt') {
              $tag1 = $this->session->merchantInfo['google_tag_event_snippet'];
              //   echo "$tag1";
             $value = $total ;
             $currency = "NZD";
                echo "gtag('event', 'conversion', {
                    'send_to': '$tag1',
                    'value': $value,
                    'currency': 'NZD',
                    'transaction_id': '$reference'
                });";
          }
        ?>
    </script>