Prestashop 1.5
  1. Prestashop 1.5
  2. PSCFV-11702

Bug on [total_discounts, total_discounts_tax_incl, total_discounts_tax_excl] in order calculation

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Security Level: All-users
    • Labels:
      None

      Description

      There is a bug when you have an order with free shipping (discount) and a total cost of zero. The fields in database for the discount calculation are wrong.

      To find this bug I use the manual creation of an order in the admin part of prestashop.

      Reproduce the bug :

      • Go in the admin of prestashop
      • Go to the orders view
      • Click on the "add" button to create a new order manually
      • Select a customer
      • Select a product
      • Click add to cart
      • IMPORTANT Set the price of the product to 0
      • Now check the free shipping checkbox
      • Validate your order !

      Normaly you have an order who cost 0.- for your customer but you still have something for the sipping even if there if a discount who is created to cover it.

      But when you go to the database on the table ps_orders and look at those fields : (total_discounts, total_discounts_tax_incl, total_discounts_tax_excl) the amount is 0 and that's wrong.

      This bug is hard to see because you can see it only if you need to export all the orders data for external accounting software. (that is my case)

      Correction :
      The probleme is arround the line 1547. When you do this :
      $order_total_discount = min(Tools::ps_round($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees);
      As the wrapping_fees, the order_total_products are equal to zero the result of $order_total_discount is zero !
      But normaly the shipping_fees should not be zero so to correct that I guess you need to edit the line 1341 :
      $with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING));
      to :
      $with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING, Cart::ONLY_DISCOUNTS));

      But I'm not sure of that so I hope you will find the right way to do it.

      Best regards

        Activity

        Hide
        Wurzag added a comment -

        This is on all version, not only 1.5.5

        Show
        Wurzag added a comment - This is on all version, not only 1.5.5
        Hide
        Wurzag added a comment -

        I've forgot to specified the file... It's all in classes/Cart.php

        Show
        Wurzag added a comment - I've forgot to specified the file... It's all in classes/Cart.php
        Hide
        Wurzag added a comment -

        I've made a pull request here regarding this issue :
        https://github.com/PrestaShop/PrestaShop/pull/1436

        Show
        Wurzag added a comment - I've made a pull request here regarding this issue : https://github.com/PrestaShop/PrestaShop/pull/1436
        Hide
        Rémi GAILLARD added a comment -

        Hi Wurzag,

        Thank you for your bug report.
        This happens when total_products < total_shipping and not only when the product price is equal to 0.
        I just fixed it on our development version, see https://github.com/PrestaShop/PrestaShop/commit/c9afdb7f6d7d7a5ded0bafbcd76825d0d4ba3ef8

        Best Regards,

        Show
        Rémi GAILLARD added a comment - Hi Wurzag, Thank you for your bug report. This happens when total_products < total_shipping and not only when the product price is equal to 0. I just fixed it on our development version, see https://github.com/PrestaShop/PrestaShop/commit/c9afdb7f6d7d7a5ded0bafbcd76825d0d4ba3ef8 Best Regards,

          People

          • Assignee:
            David BENOIT
            Reporter:
            Wurzag
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: