Magento PHP脚本停止运行且没有错误

时间:2018-08-27 18:34:45

标签: php html magento

我正在尝试运行以下脚本来检索购物车中的物品。

<script type="text/javascript">
    <?php echo $cart = Mage::getModel('checkout/cart')->getQuote();
        foreach ($cart->getAllItems() as $item) {
        $productId = $item->getProduct()->getId();
        $productPrice = $item->getProduct()->getPrice();
        }
    ?>

    var abc;
    abc = <?php echo $block->getAbcID()?>;
    var tag = document.querySelector("iframe");
    // Retrieving cookie with Event ID and setting Event to a variable
    var value = "; " + document.cookie;
    var parts = value.split("; " + "EventID" + "=");
    var retrievedCookie = "";
    if (parts.length == 2) retrievedCookie = parts.pop().split(";").shift();
    // Insert variables into the iframe
    tag.setAttribute("src","blahblahblah");
</script>

在测试页面时,除p标记外,所有html都不运行,并且以下内容显示在开发人员工具的“源”部分下:

<script type="text/javascript">
</script>

谁能解释为什么PHP无法运行?

0 个答案:

没有答案