<script type="text/javascript">
var myVar= {
"pagetype": "CART",
<?php $session = Mage::getSingleton('checkout/session');
foreach ($session->getQuote()->getAllItems() as $item) ?>
"itemid" : "<?php echo $item->getId(); ?>"
</script>
答案 0 :(得分:0)
您需要打印一系列ID。当前的中心正在产生:"{id}{id-0}{id-1}{id-2}{id-3}"
用于将ID存储在数组中以打印出JSON:
<script type="text/javascript">
var myVar= {
"pagetype": "CART",
<?php $session = Mage::getSingleton('checkout/session');
$ids = array();
foreach ($session->getQuote()->getAllItems() as $item):
array_push($ids, $item->getId());
endforeach; ?>
"itemid" : <?php echo json_encode($ids); ?>
}
</script>