Well, after few weeks of waiting for any help without any luck, I'd decided to fix this all by myself.
For first task with saving group_reduction in total_discounts - I'd decided not to do it, because I'm still not sure if this won't break something.
For the second task - I did it and did it that's how.
1. Changes in Database
Firstly add new field in orders table:
ALTER TABLE `ps_orders` ADD `group_reduction` DECIMAL(10,2) NOT NULL DEFAULT '0.00' AFTER `shipping_number`;
Also you can get group_reduction values for old orders from order_details, but this table contains value per each product, so there will be category based modifications. We don't have any of it, so I used this query:
/*
SELECT
od.id_order
, MAX(od.group_reduction) AS group_reduction
FROM ps_order_detail AS od
GROUP BY od.id_order;
*/
UPDATE `ps_orders` AS o
INNER JOIN (
SELECT
od.id_order
, MAX(od.group_reduction) AS group_reduction
FROM ps_order_detail AS od
GROUP BY od.id_order
) AS t ON t.id_order = o.id_order
SET o.group_reduction = t.group_reduction;
2. Code overrides
а. Show group reduction in a cart to customer
I'd overrided getSummaryDetails function of Cart class, so that user can see their group reduction in a cart. Copy /classes/Cart.php to /override/classes/Cart.php. Name it like this:
class Cart extends CartCore {
Clean everything except getSummaryDetails and in this function before '$summary = array(...' just add:
//get Customer group reduction
if ((int)$this->id_customer) {
$customer = new Customer((int)$this->id_customer);
$group_reduction = Group::getReduction($customer->id_default_group);
unset($customer);
} else {
$group_reduction = 0;
}
$summary = array(...
In the end of $summary array also add:
'group_reduction' => $group_reduction,
);
After that in template file (/themes/YOUR_THEME/shopping-cart.tpl) add something like this (change it based on your theme totals table code):
{if $group_reduction}
<tr class="cart_group_reduction">
<td colspan="{$col_span_subtotal}" class="text-right">{l s='Group reduction'}</td>
<td colspan="2" class="price" id="group_reduction">-{$group_reduction}%</td>
</tr>
{/if}
b. Save group reduction with order
Copy /classes/order/Order.php to /override/classes/order/Cart.php. In the begining you should have:
class Order extends OrderCore {
public $group_reduction;
After that in $definition array from add:
'group_reduction' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
Then delete everything else in the file, because no function overrides needed.
Also copy /classes/PaymentModule.php to/override/classes/PaymentModule.php. In the begining you should have:
abstract class PaymentModule extends PaymentModuleCore {
Clean everything except validateOrder and in this function before '$order->invoice_date = '0000-00-00 00:00:00';' just add:
//save Customer group reduction
$order->group_reduction = Group::getReduction($this->context->customer->id_default_group);
$order->invoice_date = '0000-00-00 00:00:00';...
Maybe there is a better solution, because this vaildation function is big and some modules may override it, but this works as planned for me.
c. Show group reduction in order for admin
Edit file /YOUR_ADMIN_FOLDER/themes/default/template/controllers/orders/helpers/view/view.tpl and add just before '<tr id="total_discounts"' next:
<tr id="total_group_reduction">
<td class="text-right">{l s='Group reduction:'}</td>
<td class="amount text-right nowrap">
{$order->group_reduction}%
</td>
<td class="partial_refund_fields current-edit" style="display:none;"></td>
</tr>
<tr id="total_discounts"...
d. Show customer group reduction in PDF invoice
Copy /classes/pdf/HTMLTemplateInvoice.php to /override/classes/pdf/HTMLTemplateInvoice.php. In the begining you should have:
class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore {
Clean everything except getContent and in this function just before '$order_details = $this->order_invoice->getProducts();' add:
$group_reduction = $this->order->group_reduction;
$order_details = $this->order_invoice->getProducts();...
Then find another line starting with '$footer = array(' and in the end of the array add:
'group_reduction' => $group_reduction,
);
After that in the /pdf/invoice.total-tab.tpl template after '<table id="total-tab" width="100%">' add:
{if isset($footer.group_reduction)}
<tr>
<td class="grey" width="44%">
{l s='Client Discount' pdf='true'}
</td>
<td class="white center" width="56%">
- {$footer.group_reduction}%
</td>
</tr>
{/if}
Also I'm planing to edit some client mails, but not right now.
Hope this helps someone.