Jump to content

Merchandise Returns is a real pain in the.....


subaru4wd

Recommended Posts

Our store sells electronic parts, and we have quite a high return rate, not only for defective products but also for products purchased in error.    We have been in business just over a year, and have over 500 returns.   

 

Why can't the Merchandise Return screen list the customers name with their RMA?   I have to click on and view every single RMA before I can find the customer I am looking for.

 

My 8 hour day, would be 2 hours if it werent for prestashop :(

Link to comment
Share on other sites

Yeah you have any idea how much a prestashop coder charges???     And then I have to deal with some sort of hack.   Ive done that before and its broken more than it fixed.

 

Would just be nice if Prestashop wasnt such a pain in the ass to work with.   Its like they leave certain features out of the software, just to annoy the user.

Link to comment
Share on other sites

If you want to just display name in list it is not too hard. Here is code that could help.

You need to create new file in override/controllers/admin folder and name it AdminReturnController.php

Copy code below and save. Then clear cache in Advanced Parameters > Performance and also check

that "Disable all overrides" is at NO. 

<?php

class AdminReturnController extends AdminReturnControllerCore
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->context = Context::getContext();
        $this->table = 'order_return';
        $this->className = 'OrderReturn';
        $this->colorOnBackground = true;
        $this->_select = 'ors.color, orsl.`name`, o.`id_shop`,CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`';
        $this->_join = 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)';
        $this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)$this->context->language->id.')';
        $this->_join .= ' LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = a.`id_order`)';
        $this->_join .= ' LEFT JOIN '._DB_PREFIX_.'customer c ON (c.`id_customer` = a.`id_customer`)';

        $this->fields_list = array(
            'id_order_return' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
            'id_order' => array('title' => $this->l('Order ID'), 'width' => 100, 'align' => 'center', 'filter_key'=>'a!id_order'),
            'customer' => array('title' => $this->l('Customer'), 'width' => 'auto', 'align' => 'center'),
            'name' => array('title' => $this->l('Status'),'color' => 'color', 'width' => 'auto', 'align' => 'left'),
            'date_add' => array('title' => $this->l('Date issued'), 'width' => 150, 'type' => 'date', 'align' => 'right', 'filter_key'=>'a!date_add'),
        );

        $this->fields_options = array(
            'general' => array(
                'title' =>    $this->l('Merchandise return (RMA) options'),
                'fields' =>    array(
                    'PS_ORDER_RETURN' => array(
                        'title' => $this->l('Enable returns'),
                        'desc' => $this->l('Would you like to allow merchandise returns in your shop?'),
                        'cast' => 'intval', 'type' => 'bool'),
                    'PS_ORDER_RETURN_NB_DAYS' => array(
                        'title' => $this->l('Time limit of validity'),
                        'desc' => $this->l('How many days after the delivery date does the customer have to return a product?'),
                        'cast' => 'intval',
                        'type' => 'text',
                        'size' => '2'),
                    'PS_RETURN_PREFIX' => array(
                        'title' => $this->l('Returns prefix'),
                        'desc' => $this->l('Prefix used for return name (e.g. RE00001).'),
                        'size' => 6,
                        'type' => 'textLang'
                    ),
                ),
                'submit' => array('title' => $this->l('Save'))
            ),
        );

        AdminController::__construct();

        $this->_where = Shop::addSqlRestriction(false, 'o');
        $this->_use_found_rows = false;
    }
}

This should then add new columns with customer names.  :)

Edited by razaro (see edit history)
  • Like 1
Link to comment
Share on other sites

Razaro THANK YOU VERY VERY MUCH!!!    I will certainly give this a try.

I do have a backup of my store on a cloned server.  And I use the cloned server to implement and test changes.   I will be trying this modification out soon and report back with my results.

Link to comment
Share on other sites

  • 2 weeks later...

I did notice that it wont let me search by name.   I get a error:

Bad SQL query
Unknown column 'customer' in 'where clause'

Also you seem pretty knowledgeable about modifying prestashop.   Would you know how I can include the Return ID# on the screen with the RMA details?   It would also be really nice if the customers email address was listed next to their name so that I could send them an email with ease.     

 

Thank you again

Link to comment
Share on other sites

  • 2 weeks later...

Ok here is code, modification for adding customer name in list and email with id to form. Changes are in two files

 

AdminReturnController.php should be in override/controllers/admin/

<?php

class AdminReturnController extends AdminReturnControllerCore
{
public function __construct()
{
$this->bootstrap = true;
$this->context = Context::getContext();
$this->table = 'order_return';
$this->className = 'OrderReturn';
$this->colorOnBackground = true;
$this->_select = 'ors.color, orsl.`name`, o.`id_shop`,CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,c.`email` AS `customer_email`';
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'order_return_state ors ON (ors.`id_order_return_state` = a.`state`)';
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)$this->context->language->id.')';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'orders o ON (o.`id_order` = a.`id_order`)';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'customer c ON (c.`id_customer` = a.`id_customer`)';

$this->fields_list = array(
'id_order_return' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'id_order' => array('title' => $this->l('Order ID'), 'width' => 100, 'align' => 'center', 'filter_key'=>'a!id_order'),
'customer' => array('title' => $this->l('Customer'), 'width' => 'auto', 'align' => 'center','havingFilter' => true, 'filter_key'=>'customer'),
'customer_email' => array('title' => $this->l('Customer Email'), 'width' => 'auto', 'align' => 'center','havingFilter' => true, 'filter_key'=>'customer_email'),
'name' => array('title' => $this->l('Status'),'color' => 'color', 'width' => 'auto', 'align' => 'left'),
'date_add' => array('title' => $this->l('Date issued'), 'width' => 150, 'type' => 'date', 'align' => 'right', 'filter_key'=>'a!date_add'),
);

$this->fields_options = array(
'general' => array(
'title' => $this->l('Merchandise return (RMA) options'),
'fields' => array(
'PS_ORDER_RETURN' => array(
'title' => $this->l('Enable returns'),
'desc' => $this->l('Would you like to allow merchandise returns in your shop?'),
'cast' => 'intval', 'type' => 'bool'),
'PS_ORDER_RETURN_NB_DAYS' => array(
'title' => $this->l('Time limit of validity'),
'desc' => $this->l('How many days after the delivery date does the customer have to return a product?'),
'cast' => 'intval',
'type' => 'text',
'size' => '2'),
'PS_RETURN_PREFIX' => array(
'title' => $this->l('Returns prefix'),
'desc' => $this->l('Prefix used for return name (e.g. RE00001).'),
'size' => 6,
'type' => 'textLang'
),
),
'submit' => array('title' => $this->l('Save'))
),
);

AdminController::__construct();

$this->_where = Shop::addSqlRestriction(false, 'o');
$this->_use_found_rows = false;
}
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Return Merchandise Authorization (RMA)'),
'image' => '../img/admin/return.gif'
),
'input' => array(
array(
'type' => 'hidden',
'name' => 'id_order'
),
array(
'type' => 'hidden',
'name' => 'id_customer'
),
array(
'type' => 'free',
'label' => $this->l('Return ID#'),
'name' => 'id_order_return',
'size' => '',
'required' => false,
),
array(
'type' => 'text_customer',
'label' => $this->l('Customer'),
'name' => '',
'size' => '',
'required' => false,
),
array(
'type' => 'text_email',
'label' => $this->l('Customer Email'),
'name' => '',
'size' => '',
'required' => false,
),
array(
'type' => 'text_order',
'label' => $this->l('Order'),
'name' => '',
'size' => '',
'required' => false,
),
array(
'type' => 'free',
'label' => $this->l('Customer explanation'),
'name' => 'question',
'size' => '',
'required' => false,
),
array(
'type' => 'select',
'label' => $this->l('Status'),
'name' => 'state',
'required' => false,
'options' => array(
'query' => OrderReturnState::getOrderReturnStates($this->context->language->id),
'id' => 'id_order_return_state',
'name' => 'name'
),
'desc' => $this->l('Merchandise return (RMA) status.')
),
array(
'type' => 'list_products',
'label' => $this->l('Products'),
'name' => '',
'size' => '',
'required' => false,
'desc' => $this->l('List of products in return package.')
),
array(
'type' => 'pdf_order_return',
'label' => $this->l('Return slip'),
'name' => '',
'size' => '',
'required' => false,
'desc' => $this->l('The link is only available after validation and before the parcel gets delivered.')
),
),
'submit' => array(
'title' => $this->l('Save'),
)
);

$order = new Order($this->object->id_order);
$quantity_displayed = array();
// Customized products */
if ($returned_customizations = OrderReturn::getReturnedCustomizedProducts((int)($this->object->id_order))) {
foreach ($returned_customizations as $returned_customization) {
$quantity_displayed[(int)$returned_customization['id_order_detail']] = isset($quantity_displayed[(int)$returned_customization['id_order_detail']]) ? $quantity_displayed[(int)$returned_customization['id_order_detail']] + (int)$returned_customization['product_quantity'] : (int)$returned_customization['product_quantity'];
}
}

// Classic products
$products = OrderReturn::getOrdersReturnProducts($this->object->id, $order);

// Prepare customer explanation for display
$this->object->question = '<span class="normal-text">'.nl2br($this->object->question).'</span>';

$this->tpl_form_vars = array(
'customer' => new Customer($this->object->id_customer),
'url_customer' => 'index.php?tab=AdminCustomers&id_customer='.(int)$this->object->id_customer.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id),
'text_order' => sprintf($this->l('Order #%1$d from %2$s'), $order->id, Tools::displayDate($order->date_upd)),
'url_order' => 'index.php?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)Tab::getIdFromClassName('AdminOrders').(int)$this->context->employee->id),
'picture_folder' => _THEME_PROD_PIC_DIR_,
'returnedCustomizations' => $returned_customizations,
'customizedDatas' => Product::getAllCustomizedDatas((int)($order->id_cart)),
'products' => $products,
'quantityDisplayed' => $quantity_displayed,
'id_order_return' => $this->object->id,
'state_order_return' => $this->object->state,
);

return AdminController::renderForm();
}

}

and also form.tpl that should be in override/controllers/admin/templates/return/helpers/form/ folder (create all missing ones)

{*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}

{extends file='helpers/form/form.tpl'}

{block name="input"}
    {if $input.type == 'text_customer'}
        <span>{$customer->firstname} {$customer->lastname}</span>
        <p>
            <a class="text-muted" href="{$url_customer}">{l s='View details on the customer page'}</a>
        </p>
    {elseif $input.type == 'text_order'}
        <span>{$text_order}</span>
        <p>
            <a class="text-muted" href="{$url_order}">{l s='View details on the order page'}</a>
        </p>
    {elseif $input.type == 'text_email'}
        <span>{$customer->email}</span>
        <p>
            <a class="text-muted" href="{$url_customer}">{l s='View details on the customer page'}</a>
        </p>
    {elseif $input.type == 'pdf_order_return'}
        <p>
            {if $state_order_return == 2}
                <a class="btn" href="{$link->getPageLink('pdf-order-return', true, NULL, "id_order_return={$id_order_return|intval}&adtoken={Tools::getAdminTokenLite('AdminReturn')}&id_employee={$employee->id|intval}")|escape:'html':'UTF-8'}">
                    <i class="icon-file-text"></i> {l s='Print out'}
                </a>
            {else}
                --
            {/if}
        </p>
    {elseif $input.type == 'list_products'}
        <table class="table">
            <thead>
                <tr>
                    <th>{l s='Reference'}</th>
                    <th>{l s='Product name'}</th>
                    <th class="text-center">{l s='Quantity'}</th>
                    <th class="text-center">{l s='Action'}</th>
                </tr>
            </thead>
            <tbody>
                {foreach $returnedCustomizations as $returnedCustomization}
                    <tr>
                        <td>{$returnedCustomization['reference']}</td>
                        <td>{$returnedCustomization['name']}</td>
                        <td class="text-center">{$returnedCustomization['product_quantity']|intval}</td>
                        <td class="text-center">
                            <a class="btn btn-default" href="{$current|escape:'html':'UTF-8'}&deleteorder_return_detail&id_order_detail={$returnedCustomization['id_order_detail']}&id_order_return={$id_order_return}&id_customization={$returnedCustomization['id_customization']}&token={$token|escape:'html':'UTF-8'}">
                                <i class="icon-remove"></i>
                                {l s='Delete'}
                            </a>
                        </td>
                    </tr>
                    {assign var='productId' value=$returnedCustomization.product_id}
                    {assign var='productAttributeId' value=$returnedCustomization.product_attribute_id}
                    {assign var='customizationId' value=$returnedCustomization.id_customization}
                    {assign var='addressDeliveryId' value=$returnedCustomization.id_address_delivery}
                    {foreach $customizedDatas.$productId.$productAttributeId.$addressDeliveryId.$customizationId.datas as $type => $datas}
                        <tr>
                            <td colspan="4">
                                <div class="form-horizontal">
                                    {if $type == Product::CUSTOMIZE_FILE}
                                        {foreach from=$datas item='data'}
                                            <div class="form-group">
                                                <span class="col-lg-3 control-label"><strong>{l s='Attachment'}</strong></span>
                                                <div class="col-lg-9">
                                                    <a href="displayImage.php?img={$data['value']}&name={$returnedCustomization['id_order_detail']|intval}-file{$smarty.foreach.data.iteration.iteration}" class="_blank"><img class="img-thumbnail" src="{$picture_folder}{$data['value']}_small" alt="" /></a>
                                                </div>
                                            </div>
                                        {/foreach}
                                    {elseif $type == Product::CUSTOMIZE_TEXTFIELD}
                                            {foreach from=$datas item='data'}
                                                <div class="form-group">
                                                    <span class="control-label col-lg-3"><strong>{if $data['name']}{$data['name']}{else}{l s='Text #%d' sprintf=$smarty.foreach.data.iteration}{/if}</strong></span>
                                                    <div class="col-lg-9">
                                                        <p class="form-control-static">
                                                            {$data['value']}
                                                        </p>
                                                    </div>
                                                </div>
                                            {/foreach}
                                    {/if}
                                </div>
                            </td>
                        </tr>
                    {/foreach}
                {/foreach}

                {* Classic products *}
                {foreach $products as $k => $product}
                    {if !isset($quantityDisplayed[$product['id_order_detail']]) || $product['product_quantity']|intval > $quantityDisplayed[$product['id_order_detail']]|intval}
                        <tr>
                            <td>{$product['product_reference']}</td>
                            <td class="text-center">{$product['product_name']}</td>
                            <td class="text-center">{$product['product_quantity']}</td>
                            <td class="text-center">
                                <a class="btn btn-default" href="{$current|escape:'html':'UTF-8'}&deleteorder_return_detail&id_order_detail={$product['id_order_detail']}&id_order_return={$id_order_return}&token={$token|escape:'html':'UTF-8'}">
                                    <i class="icon-remove"></i>
                                    {l s='Delete'}
                                </a>
                            </td>
                        </tr>
                    {/if}
                {/foreach}
            </tbody>
        </table>
    {else}
        {$smarty.block.parent}
    {/if}
{/block} 
 
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...