Uploaded image for project: '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


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


      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




            • Assignee:
              david.benoit David BENOIT
              wurzag Wurzag
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created:

                Zendesk Support