Print with PHP into Javascript -
code analysis of payment page not write code in javascript codes..
for example (html print):
<script> woopra.track('odeme sayfasi', { urunsayisi: '', amount: '', currency: '$' }); </script> 21234.55
2: 2 pcs products
1234.55: amount
php & javascript codes:
<?php $magefilename = '/home4/emre2010/public_html/app/mage.php'; require_once $magefilename; umask(0); mage::app(); mage::getsingleton('core/session', array('name'=>'frontend')); $session = mage::getsingleton('checkout/session'); $output = ""; foreach ($session->getquote()->getallitems() $item) { ?> <script> woopra.track('payment page', { urunsayisi: '<?php $output .= $item->getqty(); ?>', amount: '<?php $output .= $item->getbasecalculationprice(); ?>', currency: '$' }); </script> <?php } print $output; ?>
why not write javascript code? - make mistake?
p.s: e-commerce script: magento1
you're mixing 2 approaches. when close php tags , start javascript code, that's getting output directly page. you're storing information in variable instead of outputting directly content.
you need this:
<script> woopra.track('payment page', { urunsayisi: '<?php echo $item->getqty(); ?>', amount: '<?php echo $item->getbasecalculationprice(); ?>', currency: '$' }); </script>
if want build javascript code , spit out in 1 go, you'd need put js code php variable , print output, so:
<?php $output = ''; $output .= "<script>"; $output .= " woopra.track('paymentpage', {"; $output .= " urunsayisi: '" . $item->getqty() . "',";
etc.
but top approach of printing directly code simpler , cleaner seem doing.
Comments
Post a Comment