News:

Looking for documentation? Take a look on our wiki

Main Menu

echo comma separated list of all the product skus that is on cart

Started by tsimpouri, November 19, 2015, 13:29:15 PM

Previous topic - Next topic

tsimpouri

Hello,

i want to add this code on cart page for facebook pixel track.I want to have all the skus that is on the cart in one line

fbq('track', 'Purchase', {
  content_ids: ['sku1', 'sku2' ], 
});

when i am adding the following   content_ids: ['<?php echo $prow->product_sku ?>' ],   i can have only the one sku that is on the cart but i want all the sku's in one line...

is there something i can do?

Thanks

Studio 42

YOu need to do a foreach in PHP
something so :

<?php $skus = array();
foreach (
$this->cart->products as $pkey => $prow) {
 
$skus[] =  $prow->product_sku;
}
?>

// javascript part
fbq('track', 'Purchase', {
  content_ids: ['<?php echo implode("','",$skus?>' ],
});