raymmer Posted January 28, 2015 Share Posted January 28, 2015 (edited) Hola me interesa algun modulo que sea como historial de pedidos.. digo modulo porque lo que quiero haces es poner la tabla de historial de pedidos en la pagina de inicio...Saludos y gracias de antemano. Edited January 29, 2015 by ventura (see edit history) Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 Se puede hacer mediante un modulo que se muestre solo cuando el cliente este logueado y tenga pedidos realizados 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 Gracias por responder Ventura, Que modulo seria ese? y si es gratis mucho mejor...Enserio me urge, y gracias otra vez. Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 No creo que exista ninguno, no es una funcionalidad tipica pero resultaria relativamente facil crear un modulo de ese tipo 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 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 More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 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') )); 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 Osea, para que se vean los pedidos tengo que ponenr ese codigo y el codigo que te envie? Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 Al parecer no es asi, me puede decir por favor lo que tengo que hacer? Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 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 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 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 More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 No hombre el codigo completo te lo he puesto antes, es el que aparece en el archivo controllers/front/HistoryController.php Y si, esa funcion que incluye es la que te muestra los pedidos realizados por cada cliente 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 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::getCustomerOrdersEn que parte del FrontController.php o donde es?y ya revise el controllers/front/HistoryController.phpes el mismo codigo que usted me puso arriba .... Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 Enserio me urge, por favor si es posible especifiqueme los codigos que tengo que modificar, Gracias de antemano,.. Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 Enserio me urge, por favor si es posible especifiqueme los codigos que tengo que modificar, Gracias de antemano,.. Ya se lo he dicho en los post anteriores, utilice el codigo del archivo HistoryController.php Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 ok, el codigo que me ha dicho de HistoryController.phpdonde lo pego? Gracias por responder. Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 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 Link to comment Share on other sites More sharing options...
raymmer Posted January 28, 2015 Author Share Posted January 28, 2015 Gracias por la respuesta Uso este tema de leothemehttp://www.leotheme.com/prestashop/themes/234-leo-converse.htmlY 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 More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 que version de Prestashop tienes instalada ¿? Link to comment Share on other sites More sharing options...
ventura Posted January 28, 2015 Share Posted January 28, 2015 (edited) 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 January 28, 2015 by ventura (see edit history) 1 Link to comment Share on other sites More sharing options...
raymmer Posted January 29, 2015 Author Share Posted January 29, 2015 Prestashop 1.6lo pongo debajo de la llave y nada Link to comment Share on other sites More sharing options...
raymmer Posted January 29, 2015 Author Share Posted January 29, 2015 SIIIIIIIIIIIIIII YA SIII!!! MIL GRACIAS!!! ENSERIO!!! Link to comment Share on other sites More sharing options...
ventura Posted January 29, 2015 Share Posted January 29, 2015 Me alegro de que te haya funcionada. Doy el tema por solucionado entonces Link to comment Share on other sites More sharing options...
Recommended Posts