Jump to content

[SOLVED] Print Products in Carrier Page


Recommended Posts

I think that you can look into payment-summary.tpl line 94 to 134, there is a loop for displaying products in the cart.
Including this should work.
If not, you can also to include the summary that appears when you go to shopping cart (shopping-cart.tpl) line 142 to 181

Link to comment
Share on other sites

I could not find any file called payment-summary.tpl but I looked at shopping-cart.tpl and took this from it:

{foreach from=$products item=product name=productLoop}
{assign var='productId' value=$product.id_product}
{$productId}
{/foreach}

Nothing is being printed.
Please help me!

Link to comment
Share on other sites

Oups, yes you're right, i created the file payment-summary that is why you do not have it. Sorry for that.

Ok, i get a solution for you (maybe not the best) but i think you can manage to have something nice.
First, paste this tpl code from shopping-cart.tpl into order-carrier.tpl (you know line 142 - 180


>{foreach from=$products item=product name=productLoop}
           {assign var='productId' value=$product.id_product}
           {assign var='productAttributeId' value=$product.id_product_attribute}
           {assign var='quantityDisplayed' value=0}
           {* Display the product line *}
           {include file=$tpl_dir./shopping-cart-product-line.tpl}
           {* Then the customized datas ones*}
           {if isset($customizedDatas.$productId.$productAttributeId)}
               {foreach from=$customizedDatas.$productId.$productAttributeId key='id_customization' item='customization'}


                           {foreach from=$customization.datas key='type' item='datas'}
                               {if $type == $CUSTOMIZE_FILE}


                                           {foreach from=$datas item='picture'}{/foreach}


                               {elseif $type == $CUSTOMIZE_TEXTFIELD}
</pre>
<ul>
                                       {foreach from=$datas item='textField' name='typedText'}{l s='Text #'}{$smarty.foreach.typedText.index+1}{l s=':'} {$textField.value}{/foreach}
</ul>
<br>                               {/if}<br>                           {/foreach}<br><br><br><a href="%7B%24base_dir_ssl%7Dcart.php?delete&id;_product=%7B%24product.id_product%7Cintval%7D&ipa;=%7B%24product.id_product_attribute%7Cintval%7D&id;_customization=%7B%24id_customization%7D&token;=%7B%24token_cart%7D" rel=""></a><br><p>{$customization.quantity}</p>
<br><a href="%7B%24base_dir_ssl%7Dcart.php?add&id;_product=%7B%24product.id_product%7Cintval%7D&ipa;=%7B%24product.id_product_attribute%7Cintval%7D&id;_customization=%7B%24id_customization%7D&token;=%7B%24token_cart%7D" title="{l s='Add'}" rel=""></a><br><br><a href="%7B%24base_dir_ssl%7Dcart.php?add&id;_product=%7B%24product.id_product%7Cintval%7D&ipa;=%7B%24product.id_product_attribute%7Cintval%7D&id;_customization=%7B%24id_customization%7D&op=down&token;=%7B%24token_cart%7D" title="{l s='Substract'}" rel=""></a><br><br><br><br>                   {assign var='quantityDisplayed' value=$quantityDisplayed+$customization.quantity}<br>               {/foreach}<br>               {* If it exists also some uncustomized products *}<br>               {if $product.quantity-$quantityDisplayed > 0}{include file=$tpl_dir./shopping-cart-product-line.tpl}{/if}<br>           {/if}<br>       {/fo



Ok, nothing appears because smarty does not have variables.
Then go into order.php

And change this

case 2:
           if(Tools::isSubmit('processAddress'))
               processAddress();
           autoStep(2);
           displayCarrier();
           break;



to this

case 2:
           if(Tools::isSubmit('processAddress'))
               processAddress();
           autoStep(2);
           displayMySummary();
           displayCarrier();
           break;



I added a new function displayMySummary();
Then at the end of order.php
copy function displaySummary()
and rename by displayMySummary()
and at the end of this function

remove this

    Tools::safePostVars();
   include_once(dirname(__FILE__).'/header.php');
   $smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');


unless you will have two rendering of the list.

Finally, edit your order-carrier.tpl to remove the +/- sign and the bin to only display a static list.



PS: you can maybe remove this from the function displayMySummary. try it, i think it should work but i do not tested it.

    $token = Tools::getToken(false);
   $smarty->assign(array(
       'token_cart' => $token,
       'productNumber' => $cart->nbProducts(),
       'voucherAllowed' => Configuration::get('PS_VOUCHERS'),
       'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary),
       'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary),
       'shippingCost' => $cart->getOrderTotal(true, 5),
       'shippingCostTaxExc' => $cart->getOrderTotal(false, 5),
       'customizedDatas' => $customizedDatas,
       'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
       'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
       'lastProductAdded' => $cart->getLastProduct()
       ));

displayMySummary.php

Link to comment
Share on other sites

THANKS e-motostore, you are a genius!

Basically I added the new displayMySummary function into order.php and just put this in order-carrier.tpl:

   {foreach from=$products item=product name=productLoop}
       {assign var='productId' value=$product.id_product}
       {$productId} - {$product.name}


   {/foreach}



It works now. Amazing how adding that function did the trick.
I am not familiar with smarty, may I just ask how order-carrier.tpl knows the functions are in order.php?
Is it this line?

<form id="form" action="{$base_dir_ssl}order.php" method="post">




Thanks again buddy!

Link to comment
Share on other sites

Order carrier does not know any function. It works in the other direction. The .php file assign variables and values to smarty. Then, in the .php file, you ask smarty to render its content into a tpl file. See functions like smarty->display(XXXX.tpl).
So, displayMySummary is only there to assign to smarty the variables you need to make the loop on products in cart

example :

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');



index.tpl

<body>
Hello, {$name}!
</body>

Link to comment
Share on other sites

  • 1 month later...

Hello e-motostore,

Could I have your kind help?
I know nothing about PHP.
I don't know how to copy function displaySummary() and rename by displayMySummary() that you mentioned.
Also which line should I insert those codes in order-carrier.tpl?
Could you please explain it with more details?

Thanks a lot

Link to comment
Share on other sites

×
×
  • Create New...