0

I'm currently making some changes in page which uses Smarty engine. I'm confused with outputting JavaScript, because when I look into page source there is nothing outputted but when I'm using Firebug my outputted JavaScript code is visible. Is it normal behaviour for Smarty templates?

<script type="text/javascript">
   if (isThanksPage == true) {ldelim}
     var biJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
     document.write('some javascript source code');
   {rdelim}

   if (isThanksPage === true) {ldelim}
      Order.SetCustomer('{$customerInfo.accountDetails.loginMail}', '{$customerInfo.shippingDetails.sFName}', '{$customerInfo.shippingDetails.sLName}');
      Order.OrderNumber = '{$orderId}';
      Order.OrderTotal = '{$totalAll|string_format:"%.2f"}';
      Order.ShippingTotal = '{if $shippingInfo.value eq 0}Free{else}${$shippingInfo.value|string_format:"%.2f"}{/if}';
   {rdelim}
</script>
      {assign var=totalWithoutTax value=`$total+$shippingInfo.value`}
      {if $tax}
        {assign var=taxValue value=`$tax*$totalWithoutTax/100`}
      {else}
        {assign var=taxValue value=0}
      {/if}
   {assign var=totalAll value=`$totalWithoutTax+$taxValue+$promoProduct.catalog_price`}
<script type="text/javascript">
   if (isThanksPage == true) {ldelim}
      Order.ItemTotal = '${$totalAll|string_format:"%.2f"}';      
   {rdelim}
</script>
      {foreach from=$cartProducts key=key item=product}
         {if $product.freeItemNum}
            <script type="text/javascript">
               if (isThanksPage == true) {ldelim}
               Order.AddLineItem('{$product.productInfo[1]}', {$product.freeItemNum}, '0.00');
               {rdelim}
            </script>
         {/if}

         {if $product.quantity > $product.freeItemNum}
            {assign var=quantity value=`$product.quantity-$product.freeItemNum`}
            {if $product.getYInfo.discountNumber >= $quantity}
               {assign var=priceValue value=`$quantity*$product.getYInfo.discountPrice`}
               {assign var=unitPriceValue value=`$product.getYInfo.discountPrice`}
            {elseif $product.getYInfo.discountNumber neq 0}
               {assign var=quantity1 value=`$quantity-$product.getYInfo.discountNumber`}
               {assign var=quantity2 value=`$product.getYInfo.discountNumber`}
               {assign var=priceValue value=`$quantity1*$product.sellPrice+$quantity2*$product.getYInfo.discountPrice`}
               {assign var=unitPriceValue value=`$product.sellPrice`}
            {else}
               {assign var=priceValue value=`$quantity*$product.sellPrice`}
               {assign var=unitPriceValue value=`$product.sellPrice`}
            {/if}
            <script type="text/javascript">
            if (isThanksPage == true) {ldelim}
            Order.AddLineItem('{$product.productInfo[1]}', {$quantity}, '${$priceValue|string_format:"%.2f"}');
            {rdelim}
            </script>
         {/if}
      {/foreach}
      <script type="text/javascript">
      if (isThanksPage == true) {ldelim}
      Order.Go();
      {rdelim}   
</script>
4

1 回答 1

0

你能展示代码示例吗?不,这不是正常行为

于 2013-03-10T10:53:55.187 回答