Jump to content

[Solucionado] Ayuda con Historial de pedidos


raymmer

Recommended Posts

Por ejemplo... yo pase este codigo de History.tpl a index.tpl 
 

{capture name=path}
	<a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}">
		{l s='My account'}
	</a>
	<span class="navigation-pipe">{$navigationPipe}</span>
	<span class="navigation_page">{l s='Order history'}</span>
{/capture}
{include file="$tpl_dir./errors.tpl"}
<h1 class="page-heading bottom-indent">{l s='Order history'}</h1>
<p class="info-title">{l s='Here are the orders you\'ve placed since your account was created.'}</p>
{if $slowValidation}
	<p class="alert alert-warning">{l s='If you have just placed an order, it may take a few minutes for it to be validated. Please refresh this page if your order is missing.'}</p>
{/if}
<div class="block-center table-responsive" id="block-history">
	{if $orders && count($orders)}
		<table id="order-list" class="table table-bordered footab ">
			<thead>
				<tr>
					<th class="first_item" data-sort-ignore="true">{l s='Order reference'}</th>
					<th class="item">{l s='Date'}</th>
					<th data-hide="phone" class="item">{l s='Pago de'}</th>
					
					<th class="item">{l s='Status'}</th>
					<th data-sort-ignore="true" data-hide="phone,tablet" class="item">{l s='Invoice'}</th>
					<th data-sort-ignore="true" data-hide="phone,tablet" class="last_item">Clic aquí para ver tu Link</th>
					
				</tr>
			</thead>
			<tbody>
				{foreach from=$orders item=order name=myLoop}
					<tr class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if} {if $smarty.foreach.myLoop.index % 2}alternate_item{/if}">
						<td class="history_link bold">
							{if isset($order.invoice) && $order.invoice && isset($order.virtual) && $order.virtual}
								<img class="icon" src="{$img_dir}icon/download_product.gif"	alt="{l s='Products to download'}" title="{l s='Products to download'}" />
							{/if}
							<a class="color-myaccount" href="javascript:showOrder(1, {$order.id_order|intval}, '{$link->getPageLink('order-detail', true)|escape:'html':'UTF-8'}');">
								{Order::getUniqReferenceOf($order.id_order)}
							</a>
						</td>
						<td data-value="{$order.date_add|regex_replace:"/[\-\:\ ]/":""}" class="history_date bold">
							{dateFormat date=$order.date_add full=0}
						</td>
						<td class="history_price" data-value="{$order.total_paid}">
							<span class="price">
								{displayPrice price=$order.total_paid currency=$order.id_currency no_utf8=false convert=false}
							</span>
						</td>
						
						<td{if isset($order.order_state)} data-value="{$order.id_order_state}"{/if} class="history_state">
							{if isset($order.order_state)}
								<span class="label{if isset($order.order_state_color) && Tools::getBrightness($order.order_state_color) > 128} dark{/if}"{if isset($order.order_state_color) && $order.order_state_color} style="background-color:{$order.order_state_color|escape:'html':'UTF-8'}; border-color:{$order.order_state_color|escape:'html':'UTF-8'};"{/if}>
									{$order.order_state|escape:'html':'UTF-8'}
								</span>
							{/if}
						</td>
						<td class="history_invoice">
							{if (isset($order.invoice) && $order.invoice && isset($order.invoice_number) && $order.invoice_number) && isset($invoiceAllowed) && $invoiceAllowed == true}
								<a class="link-button" href="{$link->getPageLink('pdf-invoice', true, NULL, "id_order={$order.id_order}")|escape:'html':'UTF-8'}" title="{l s='Invoice'}" target="_blank">
									<i class="fa fa-file-text large"></i>{l s='PDF'}
								</a>
							{else}
								-
							{/if}
						</td>
						<td class="history_detail">
							<a class="btn btn-outline button button-small btn-sm" href="javascript:showOrder(1, {$order.id_order|intval}, '{$link->getPageLink('order-detail', true)|escape:'html':'UTF-8'}');">
								<span>
									{l s='Details'}
								</span>
							
						</td>
					</tr>
				{/foreach}
			</tbody>
		</table>
		<div id="block-order-detail" class="unvisible"> </div>
	{else}
		<p class="alert alert-warning">{l s='You have not placed any orders.'}</p>
	{/if}
</div>





<ul class="footer_links clearfix">
	<li class="pull-left">
		<a class="btn btn-outline button button-small btn-sm" href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}">
			<span>
				<i class="fa fa-user"></i> {l s='Back to Your Account'}
			</span>
		</a>
	</li>
	<li class="pull-right">
		<a class="btn btn-outline button button-small btn-sm" href="{$base_dir}">
			<span><i class="fa fa-home"></i> {l s='Home'}</span>
		</a>
	</li>
</ul>

Y me dice que no hay ordenes....luego lo pse en lo ultimo del footer que se vea en todas las paginas de la tienda.... y sale el mismo error de que no hay pedidos en todas las paginas que entro menos en la pagina de "Historial de pedidos" 
... osea eso me dice que el codigo tiene algo que solo permite ver los pedidos que hay en la pagina de "Historial de pedidos (History)"....

Me podrias ayudar y decirme como hago para que se vean los pedidos en el infex... 


Saludos. 

Link to comment
Share on other sites

Te falta el acceso a las variables que aparecen en el tpl.

 

Añade en el archivo

classes/controller/FrontController.php

Debajo de esto

public function initContent

Este codigo


		if ($orders = Order::getCustomerOrders($this->context->customer->id))
			foreach ($orders as &$order)
			{
				$myOrder = new Order((int)$order['id_order']);
				if (Validate::isLoadedObject($myOrder))
					$order['virtual'] = $myOrder->isVirtual(false);
			}
		$this->context->smarty->assign(array(
			'orders' => $orders,
			'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
			'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
			'slowValidation' => Tools::isSubmit('slowvalidation')
		));
  • Like 1
Link to comment
Share on other sites

el codigo del tpl no hace falta que lo pongas, bastaria con un include

{include file="$tpl_dir./history.tpl"}

Y para tener acceso a las variables de los pedidos del cliente, lo que te comentaba antes, tienes que incluir la funcion

Order::getCustomerOrders

en el FrontController.php

  • Like 1
Link to comment
Share on other sites

Ya elimine un 

{include file="$tpl_dir./history.tpl"}

lo guardo y sale que no hay ordenes en el index (el error)

Luego cuando agrego 

Order::getCustomerOrders

La pagina no carga...

 

 

El FrontController.php estabas asi:

public function initContent()
	{
		
		$this->process();
		if (!isset($this->context->cart))
			$this->context->cart = new Cart();
		if (!$this->useMobileTheme())
		{
			// These hooks aren't used for the mobile theme.
			// Needed hooks are called in the tpl files.
			$this->context->smarty->assign(array(
				'HOOK_HEADER' => Hook::exec('displayHeader'),
				'HOOK_TOP' => Hook::exec('displayTop'),
				'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
				'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
			));
		}

Luego le agrege el Order::getCustomerOrders asi: 
 

public function initContent()
	{
		Order::getCustomerOrders
		$this->process();
		if (!isset($this->context->cart))
			$this->context->cart = new Cart();
		if (!$this->useMobileTheme())
		{
			// These hooks aren't used for the mobile theme.
			// Needed hooks are called in the tpl files.
			$this->context->smarty->assign(array(
				'HOOK_HEADER' => Hook::exec('displayHeader'),
				'HOOK_TOP' => Hook::exec('displayTop'),
				'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
				'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
			));
		}
		else
			$this->context->smarty->assign('HOOK_MOBILE_HEADER', Hook::exec('displayMobileHeader'));
	}

y la pagina no carga... 

 

 

Una pregunta, el Order::getCustomerOrders es para que en la pagina de index no salga ese error de que no hay pedidos aunque en realidad si hay ... cierto?

Link to comment
Share on other sites

Usted me dijo:

"Y para tener acceso a las variables de los pedidos del cliente, lo que te comentaba antes, tienes que incluir la funcion

Order::getCustomerOrders

en el FrontController.php"

Donde es que tengo que agregar: Order::getCustomerOrders
En que parte del FrontController.php

 

 

o donde es?
y ya revise el 
controllers/front/HistoryController.php
es el mismo codigo que usted me puso arriba .... 

Link to comment
Share on other sites

Te explico proceso para version con instalacion en 1.6.0.11 con plantilla defaulf

 

En el archivo

classes/controller/FrontController.php

Debajo de 

public function initContent

Añadimos este codigo


		if ($orders = Order::getCustomerOrders($this->context->customer->id))
			foreach ($orders as &$order)
			{
				$myOrder = new Order((int)$order['id_order']);
				if (Validate::isLoadedObject($myOrder))
					$order['virtual'] = $myOrder->isVirtual(false);
			}
			
			$total_orders = count($orders);
		$this->context->smarty->assign(array(
			'any_orders' => $total_orders,
			'orders' => $orders,
			'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
			'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
			'slowValidation' => Tools::isSubmit('slowvalidation')
		));
 

Lo ideal sería hacerlo en un override pero eso lo dejamos para otro momento

 

Despues en el archivo 

themes/tu-tema/ index.tpl

Añades esto al principio 

{if $logged && $any_orders}{include file="$tpl_dir./history.tpl"}{/if}

Encima de esto

{if isset($HOOK_HOME_TAB_CONTENT) && $HOOK_HOME_TAB_CONTENT|trim}

De esta manera este contenido solo será visible cuando el cliente este logeado y tenga algun pedido realizado

 

El resultado seria el de la imagen adjunta

post-107989-0-92204100-1422474621_thumb.png

Link to comment
Share on other sites

Gracias por la respuesta 

 

Uso este tema de leotheme
http://www.leotheme.com/prestashop/themes/234-leo-converse.html

Y cuando agrego el codigo debajo de (classes/controller/FrontController.php)

public function initContent
if ($orders = Order::getCustomerOrders($this->context->customer->id))
			foreach ($orders as &$order)
			{
				$myOrder = new Order((int)$order['id_order']);
				if (Validate::isLoadedObject($myOrder))
					$order['virtual'] = $myOrder->isVirtual(false);
			}
			
			$total_orders = count($orders);
		$this->context->smarty->assign(array(
			'any_orders' => $total_orders,
			'orders' => $orders,
			'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'),
			'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'),
			'slowValidation' => Tools::isSubmit('slowvalidation')
		));
 

La pagina no carga.. y cuando lo quito carga... 

Link to comment
Share on other sites

añade el codigo debajo de la llave, asi

public function initContent()
{


if ($orders = Order::getCustomerOrders($this->context->customer->id)) foreach ($orders as &$order) { $myOrder = new Order((int)$order['id_order']); if (Validate::isLoadedObject($myOrder)) $order['virtual'] = $myOrder->isVirtual(false); } $total_orders = count($orders); $this->context->smarty->assign(array( 'any_orders' => $total_orders, 'orders' => $orders, 'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(int)Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation') ));
Edited by ventura (see edit history)
  • Like 1
Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...