Jump to content

fr0sty

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Activity
    Other

fr0sty's Achievements

Newbie

Newbie (1/14)

  • Dedicated Rare
  • Week One Done Rare
  • One Month Later Rare
  • One Year In Rare

Recent Badges

3

Reputation

  1. 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.
  2. Thank you for answer. Right now we are showing current group for the order invoices and in admin part. But as you mentioned customer group changes over time, based on how much customer totaly spend. So that's why I'm thinking about some new customizations. I find default Presta realization a bit confusing. I think this customizations should be in CMS by default. Also we find out that discounts are applied in series. First customer gets group reduction by 3% for example, so it sees $97 instead of $100 product price. After that if product have 10% discount it applies it to 97$ so final price is $87.3. So basicly total client discount is 12.7%, not 13%. I don't think that it's a big problem, but it would be more flexible if there were some options about how to apply reductions. For example russian terrible CMS Bitrix allows to sum discounts, or aply them in series (by discount priorities), or create discount rule that will be first & last (not combining with any other). Comapring the code from both CMS I see that Bitrix devs had planned whole functionality from scrach, so whole discounts system works together. In Presta code looks like plugs here and there that works somehow. And that's a bit pitty because I hate Bitrix CMS and recommend Presta to all my clients. This is my first client with such big discounting system and we have so much troubles with it.
  3. Hello. I have a shop based on PS 1.6.1.13. We have multiple client groups with default discount (reduction) for each (3%-15%). When client logged in he sees prices with group disount already applied to base product price. But in cart or order total amount of disounts doesn't show at all. So it's a bit complicated to understand wich order have wich discounts. I'd found that total_disounts field from DB is used for showing total discount amount everywhere in the shop. If I'd understand this correct, it calculated in Cart class by getOrderTotal function. But I'm still not sure yet how to add this default group reduction to it's calculation. So I'm thinking about two modifications: 1) calculate total_discounts with group reduction amount in it Please, correct me if I'm wrong, there should be difference between base product prices and product prices with group reduction applied. Also why that was made like that. Is there any problems if we store group reduction amount in this field? 2) make a field in order table where store current order group discount value By default our client group have discount with 3%. I want to save client group reduction at the moment of order creation in some separate field in order to show it later in admin panel. What method should I override? If someone already did this modifications please share your code or help with the where to dig. Thanks in advance!
×
×
  • Create New...