Facebook
From Sludgy Anoa, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 199
  1. <?php
  2. /**
  3.  * @author Amasty Team
  4.  * @copyright Copyright (c) 2017 Amasty (https://www.amasty.com)
  5.  * @package Amasty_Checkout
  6.  */
  7. ?>
  8. <?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
  9. <div class="checkout-success">
  10.     <?php if ($block->getOrderId()):?>
  11.         <div class="success-messages">
  12.             <?php if ($block->getCanViewOrder()) :?>
  13.                 <p><?= __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p>
  14.             <?php  else :?>
  15.                 <p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
  16.             <?php endif;?>
  17.             <p><?= __('We'll email you an order confirmation with details and tracking info.') ?></p>
  18.         </div>
  19.         <?= $block->getChildHtml('details') ?>
  20.     <?php endif;?>
  21.  
  22.     <?= $block->getChildHtml('cms') ?>
  23.  
  24.     <div class="actions-toolbar">
  25.         <div class="primary">
  26.             <a class="action primary continue" href="<?= $block->getUrl() ?>"><span><?= __('Continue Shopping') ?></span></a>
  27.         </div>
  28.     </div>
  29. </div>
  30.  
  31.  
  32. <?php
  33.  
  34. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  35. $order = $objectManager->create('MagentoSalesModelOrder')->loadByIncrementId($block->getOrderId());
  36. $orderItems = $order->getAllItems();
  37.  
  38. // Function to return the JavaScript representation of a TransactionData object.
  39. function getTransactionJs($transId,$subtotal,$shipping,$tax) {
  40.   return <<<HTML
  41. ga('ecommerce:addTransaction', {
  42.   'id': '{$transId}',
  43.   'affiliation': 'Bookland',
  44.   'revenue': '{$subtotal}',
  45.   'shipping': '{$shipping}',
  46.   'tax': '{$tax}'
  47. });
  48. HTML;
  49. }
  50.  
  51. // Function to return the JavaScript representation of an ItemData object.
  52. function getItemJs($transId, $items) {
  53.   return <<<HTML
  54. ga('ecommerce:addItem', {
  55.   'id': '$transId',
  56.   'name': '{$items['name']}',
  57.   'sku': '{$items['sku']}',
  58.   'category': '{$items['category']}',
  59.   'price': '{$items->getPriceInclTax()}',
  60.   'quantity': '{$items->getQtyOrdered()}'
  61. });
  62. HTML;
  63. }
  64. ?>
  65.  
  66. <!-- Begin HTML -->
  67. <script type="text/javascript">
  68. ga('require', 'ecommerce');
  69. <?php
  70. echo getTransactionJs($block->getOrderId(),round($order->getGrandTotal(),2)-round($order->getShippingAmount(),2),round($order->getShippingAmount(),2), 23.00);
  71.  
  72. foreach ($orderItems as $item) {
  73.   echo getItemJs($block->getOrderId(), $item);
  74. }
  75. ?>
  76.  
  77. ga('ecommerce:send');
  78. </script>
  79.  
  80.  
  81. <?php
  82.    $ceneoProductIds = '';
  83.    $items = $order->getAllItems();
  84.    foreach ($items as $item){
  85.        $ceneoProductIds .= '#'.$item->getSku();
  86.       }
  87.    ?>
  88.  
  89.  
  90.    <script type="text/javascript">
  91.        ceneo_client_email = '<?php echo $order->getCustomerEmail() ?>';
  92.        ceneo_order_id = '<?php echo $order->getIncrementId(); ?>';
  93.        ceneo_shop_product_ids = '<?php echo $ceneoProductIds; ?>';
  94.        ceneo_work_days_to_send_questionnaire = 3;
  95.    </script>
  96.  
  97.    <script type="text/javascript" src="https://ssl.ceneo.pl/transactions/track/v2/script.js?accountGuid=bb5c3419-9e43-4ac7-ba2c-d240c10d4fd2"></script>
  98.  
  99.  
  100. <script>
  101.     require([
  102.         'Magento_Customer/js/customer-data'
  103.     ], function (customerData) {
  104.         var sections = ['customsection'];
  105.         customerData.invalidate(sections);
  106.         customerData.reload(sections, true);
  107.     });
  108. </script>