From b2ba507b0319787ebcc2e3d5fa03b808f8551ce0 Mon Sep 17 00:00:00 2001 From: fBrignoli Date: Tue, 17 Jul 2012 14:14:24 +0000 Subject: [PATCH] [-] BO : Bug Fixed ##PSCFV-3128 - part 2 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16455 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/admin/AdminOrdersController.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 7652da050..6ac2ec6ae 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -734,14 +734,15 @@ class AdminOrdersControllerCore extends AdminController { $cartrule = new CartRule(); $languages = Language::getLanguages($order); + $cartrule->description = sprintf($this->l('Credit Slip for order #%d'), $order->id); foreach ($languages as $language) { - $cartrule->description[$language['id_lang']] = sprintf($this->l('Credit Slip for order #%d'), $order->id); // Define a temporary name $cartrule->name[$language['id_lang']] = 'V0C'.(int)($order->id_customer).'O'.(int)($order->id); } // Define a temporary code $cartrule->code = 'V0C'.(int)($order->id_customer).'O'.(int)($order->id); + $cartrule->quantity = 1; $cartrule->quantity_per_user = 1; // Specific to the customer @@ -751,23 +752,17 @@ class AdminOrdersControllerCore extends AdminController $cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */ $cartrule->active = 1; - // Calculate the amount of the discount $products = $order->getProducts(false, $full_product_list, $full_quantity_list); - // Totals are stored in the order currency (or at least should be) - $total = $order->getTotalProductsWithTaxes($products); - $discounts = $order->getCartRules(); - $total_tmp = $total; - foreach ($discounts as $discount) - { - if ($discount['id_discount_type'] == Discount::PERCENT) - $total -= $total_tmp * ($discount['value'] / 100); - elseif ($discount['id_discount_type'] == Discount::AMOUNT) - $total -= ($discount['value'] * ($total_tmp / $order->total_products_wt)); - } + + $total = 0; + foreach ($products as $product) + $total += $product['unit_price_tax_incl'] * $product['product_quantity']; + if (Tools::isSubmit('shippingBack')) $total += $order->total_shipping; $cartrule->reduction_amount = $total; + $cartrule->reduction_tax = true; $cartrule->minimum_amount_currency = $order->id_currency; $cartrule->reduction_currency = $order->id_currency;