我有一个带有变量的iFrame标签,我正尝试在Magento网络商店上使用javascript函数动态填充这些变量。我在这个Magento博客1上找到了一些代码,但是似乎有些过时了,并且没有指定我应该在Magento文件中的哪个位置插入函数。
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
echo '<script type="text/javascript">' private function _getOrderProductsList($order) {
$orderItems = $order->getAllItems();
$purchasedSkus = array();
$count_orderItems = count($orderItems);
for($i = 0; $i < $count_orderItems; $i++) { $item=$orderItems[$i]; $product_type=$item->getProductType();
$price = $item->getPrice();
if($price>”0.00″)
{
$purchasedSkus[$i] = array(
‘ITEM’ => $orderItems[$i][‘sku’],
‘QTY’ => number_format($orderItems[$i][‘qty_ordered’],0), // no decimals
‘AMT’ => number_format($orderItems[$i][‘price’],2) // 2 decimal places
// Per C.J, the following line should be commented out.
// ‘DCNT’ => number_format(abs($orderItems[$i][‘discount_amount’]),2)
);
} // end if if price > 0.00
}
}; '</script>' // end for statement?>
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<div class="checkout-success">
<iframe height="1" width="1" frameborder="0" scrolling="no" src="https://www.emjcd.com/tags/c?containerTagId=[ContainerID]&TYPE=[TYPE]&CID=[CID]&AMOUNT=[Subtotal]&ITEMx=[ItemSku]&AMTx=[AmountofItem]&QTYx=[Quantity]&DCNTx=[ItemDiscount]&OID=[OID]&DISCOUNT=[DiscountAmount]&CURRENCY=USD&COUPON=[couponcode]&CJEVENT=[INBOUNDVALUE]&CHANNEL=[CHANNEL]&CHANNEL_TS=[TIMESTAMP]" name="cj_conversion" ></iframe>
<?php if ($block->getOrderId()):?>
<?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><?= /* @escapeNotVerified */ __('We\'ll email you an order confirmation with details and tracking info.') ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= /* @escapeNotVerified */ $block->getContinueUrl() ?>"><span><?= /* @escapeNotVerified */ __('Continue Shopping') ?></span></a>
</div>
</div>
</div>