- <?php
- /**
- * @author Amasty Team
- * @copyright Copyright (c) 2017 Amasty (https://www.amasty.com)
- * @package Amasty_Checkout
- */
- ?>
- <?php /** @var $block MagentoCheckoutBlockOnepageSuccess */ ?>
- <div class="checkout-success">
- <?php if ($block->getOrderId()):?>
- <div class="success-messages">
- <?php if ($block->getCanViewOrder()) :?>
- <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>
- <?php else :?>
- <p><?= __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p>
- <?php endif;?>
- <p><?= __('We'll email you an order confirmation with details and tracking info.') ?></p>
- </div>
- <?= $block->getChildHtml('details') ?>
- <?php endif;?>
- <?= $block->getChildHtml('cms') ?>
- <div class="actions-toolbar">
- <div class="primary">
- <a class="action primary continue" href="<?= $block->getUrl() ?>"><span><?= __('Continue Shopping') ?></span></a>
- </div>
- </div>
- </div>
- <?php
- $objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $order = $objectManager->create('MagentoSalesModelOrder')->loadByIncrementId($block->getOrderId());
- $orderItems = $order->getAllItems();
- // Function to return the JavaScript representation of a TransactionData object.
- function getTransactionJs($transId,$subtotal,$shipping,$tax) {
- return <<<HTML
- ga('ecommerce:addTransaction', {
- 'id': '{$transId}',
- 'affiliation': 'Bookland',
- 'revenue': '{$subtotal}',
- 'shipping': '{$shipping}',
- 'tax': '{$tax}'
- });
- HTML;
- }
- // Function to return the JavaScript representation of an ItemData object.
- function getItemJs($transId, $items) {
- return <<<HTML
- ga('ecommerce:addItem', {
- 'id': '$transId',
- 'name': '{$items['name']}',
- 'sku': '{$items['sku']}',
- 'category': '{$items['category']}',
- 'price': '{$items->getPriceInclTax()}',
- 'quantity': '{$items->getQtyOrdered()}'
- });
- HTML;
- }
- ?>
- <!-- Begin HTML -->
- <script type="text/javascript">
- ga('require', 'ecommerce');
- <?php
- echo getTransactionJs($block->getOrderId(),round($order->getGrandTotal(),2)-round($order->getShippingAmount(),2),round($order->getShippingAmount(),2), 23.00);
- foreach ($orderItems as $item) {
- echo getItemJs($block->getOrderId(), $item);
- }
- ?>
- ga('ecommerce:send');
- </script>
- <?php
- $ceneoProductIds = '';
- $items = $order->getAllItems();
- foreach ($items as $item){
- $ceneoProductIds .= '#'.$item->getSku();
- }
- ?>
- <script type="text/javascript">
- ceneo_client_email = '<?php echo $order->getCustomerEmail() ?>';
- ceneo_order_id = '<?php echo $order->getIncrementId(); ?>';
- ceneo_shop_product_ids = '<?php echo $ceneoProductIds; ?>';
- ceneo_work_days_to_send_questionnaire = 3;
- </script>
- <script type="text/javascript" src="https://ssl.ceneo.pl/transactions/track/v2/script.js?accountGuid=bb5c3419-9e43-4ac7-ba2c-d240c10d4fd2"></script>
- <script>
- require([
- 'Magento_Customer/js/customer-data'
- ], function (customerData) {
- var sections = ['customsection'];
- customerData.invalidate(sections);
- customerData.reload(sections, true);
- });
- </script>