init
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head><script src="https://www.17track.net/externalcall.js" src_type="url"/></head>
|
||||
<body>
|
||||
<referenceBlock name="esun.sales.order.detail">
|
||||
<block class="Esun\SeventeenTrack\Block\Order\Tracking" name="esun.order.17track" as="seventeen_track" template="Esun_SeventeenTrack::order/tracking.phtml" cacheable="false"/>
|
||||
</referenceBlock>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/** @var \Esun\SeventeenTrack\Block\Order\Tracking $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$tracks = $block->getTracks();
|
||||
?>
|
||||
<?php if ($block->canDisplay()): ?>
|
||||
<section class="esun-order-detail__panel esun-order-tracking">
|
||||
<h2><?= $escaper->escapeHtml(__('Logistics Tracking')) ?></h2>
|
||||
<?php foreach ($tracks as $index => $track): ?>
|
||||
<?php $containerId = 'YQContainer-' . $index; ?>
|
||||
<div class="esun-order-tracking__shipment">
|
||||
<div class="esun-order-tracking__meta">
|
||||
<strong><?= $escaper->escapeHtml($track['title']) ?></strong>
|
||||
<span><?= $escaper->escapeHtml(__('Tracking Number: %1', $track['number'])) ?></span>
|
||||
</div>
|
||||
<div id="<?= $escaper->escapeHtmlAttr($containerId) ?>"
|
||||
class="esun-order-tracking__widget"
|
||||
data-mage-init='<?= /* @noEscape */ json_encode([
|
||||
'Esun_SeventeenTrack/js/tracking-widget' => [
|
||||
'containerId' => $containerId,
|
||||
'number' => $track['number'],
|
||||
'height' => $block->getWidgetHeight(),
|
||||
'language' => $block->getWidgetLanguage(),
|
||||
],
|
||||
], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) ?>'>
|
||||
<p><?= $escaper->escapeHtml(__('Loading tracking information...')) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,33 @@
|
||||
define(['mage/translate'], function ($t) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var attempts = 0,
|
||||
timer;
|
||||
|
||||
function render() {
|
||||
attempts += 1;
|
||||
if (window.YQV5 && typeof window.YQV5.trackSingle === 'function') {
|
||||
element.innerHTML = '';
|
||||
window.YQV5.trackSingle({
|
||||
YQ_ContainerId: config.containerId,
|
||||
YQ_Height: config.height,
|
||||
YQ_Fc: '0',
|
||||
YQ_Lang: config.language,
|
||||
YQ_Num: config.number
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (attempts < 100) {
|
||||
timer = window.setTimeout(render, 100);
|
||||
} else {
|
||||
element.innerHTML = '<p>' + $t('Tracking information is temporarily unavailable.') + '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
render();
|
||||
return function () {
|
||||
window.clearTimeout(timer);
|
||||
};
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user