Syntaxfehler im PHP-Code finden
bearbeitet von HenryHallo,
ich habe ein kleines PHP Programm gebaut. Im Array scheint wohl ein Syntaxfehler drin zu sein, hab aber leider keine Ahnung was genau falsch ist. Könnt ihr kurz drüber schauen?
~~~php
<?php
$transactionId = "12345";
$transctionTotal = "46,30 Euro";
$items[0][product_ean] = "1";
$items[0][product_name] = "Produkt 1";
$items[0][category] = "Kategorie 1";
$items[0][product_item_price] = "10,00 Euro";
$items[0][product_quantity] = "1";
$items[1][product_ean] = "2";
$items[1][product_name] = "Produkt 2";
$items[1][category] = "Kategorie 2";
$items[1][product_item_price] = "20,00 Euro";
$items[1][product_quantity] = "2";
$items[2][product_ean] = "3";
$items[2][product_name] = "Produkt 3";
$items[2][category] = "Kategorie 3";
$items[2][product_item_price] = "30,00 Euro";
$items[2][product_quantity] = "3";
?>
<script>
dataLayer = [{
'transactionId': '1',
'transactionTotal': '2',
'transactionProducts': [
<?php foreach($items as $item){?>
{
'sku': '<?php print $item->product_ean?>',
'name': '<?php print $item->product_name?>',
'category': '<?php print $item->$category?>',
'price': '<?php print $item->product_item_price?>',
'quantity': '<?php print $item->product_quantity?>'
}
<?php } ?>
]
}];
</script>
~~~
Syntaxfehler im PHP-Code finden
bearbeitet von HenryHallo,
ich habe ein kleines PHP Programm gebaut. Im Array scheint wohl ein Syntaxfehler drin zu sein, hab aber leider keine Ahnung was genau falsch ist. Könnt ihr kurz drüber schauen?
~~~php
<?php
$transactionId = "12345";
$transctionTotal = "46,30 Euro";
$items[0][product_ean] = "1";
$items[0][product_name] = "Produkt 1";
$items[0][category] = "Kategorie 1";
$items[0][product_item_price] = "10,00 Euro";
$items[0][product_quantity] = "1";
$items[1][product_ean] = "2";
$items[1][product_name] = "Produkt 2";
$items[1][category] = "Kategorie 2";
$items[1][product_item_price] = "20,00 Euro";
$items[1][product_quantity] = "2";
$items[2][product_ean] = "3";
$items[2][product_name] = "Produkt 3";
$items[2][category] = "Kategorie 3";
$items[2][product_item_price] = "30,00 Euro";
$items[2][product_quantity] = "3";
?>
<script>
dataLayer = [{
'transactionId': '1',
'transactionTotal': '2',
'transactionProducts': [
<?php foreach($items as $item){?>
{
'sku': '<?php print $item->product_ean?>',
'name': '<?php print $item->product_name)?>',
'category': '<?php print $item->$category)?>',
'price': '<?php print $item->product_item_price)?>',
'quantity': '<?php print $item->product_quantity?>'
}
<?php } ?>
]
}];
</script>
~~~
Syntaxfehler im PHP-Code finden
bearbeitet von HenryHallo,
ich habe ein kleines PHP Programm gebaut. Im Array scheint wohl ein Syntaxfehler drin zu sein, hab aber leider keine Ahnung was genau falsch ist. Könnt ihr kurz drüber schauen?
~~~php
<?php
$transactionId = "12345";
$transctionTotal = "46,30 Euro";
$items[0][product_ean] = "1";
$items[0][product_name] = "Produkt 1";
$items[0][category] = "Kategorie 1";
$items[0][product_item_price] = "10,00 Euro";
$items[0][product_quantity] = "1";
$items[1][product_ean] = "2";
$items[1][product_name] = "Produkt 2";
$items[1][category] = "Kategorie 2";
$items[1][product_item_price] = "20,00 Euro";
$items[1][product_quantity] = "2";
$items[2][product_ean] = "3";
$items[2][product_name] = "Produkt 3";
$items[2][category] = "Kategorie 3";
$items[2][product_item_price] = "30,00 Euro";
$items[2][product_quantity] = "3";
?>
<script>
dataLayer = [{
'transactionId': '1',
'transactionTotal': '2',
'transactionProducts': [
<?php foreach($items as $item){?>
{
'sku': '<?php print $item->product_ean?>',
'name': '<?php print addslashes($item->product_name)?>',
'category': '<?php print addslashes($item->$category)?>',
'price': '<?php print $this->price_format($item->product_item_price)?>',
'quantity': '<?php print $item->product_quantity?>'
}
<?php } ?>
]
}];
</script>
~~~