// fix little bug on AdminOrdersController

[~] Deprecated: Cart::getOrderShippingCost()
This commit is contained in:
aFolletete
2011-11-30 17:25:27 +00:00
parent 8394ab35c2
commit 37cdfcdeea
7 changed files with 107 additions and 106 deletions
+5 -5
View File
@@ -560,27 +560,27 @@
<table class="table" width="300px;" cellspacing="0" cellpadding="0"> <table class="table" width="300px;" cellspacing="0" cellpadding="0">
<tr id="total_products"> <tr id="total_products">
<td width="150px;"><b>{l s='Products'}</b></td> <td width="150px;"><b>{l s='Products'}</b></td>
<td align="right">{displayPrice price=$order->total_products_wt currency=$currency->id}</td> <td class="amount" align="right">{displayPrice price=$order->total_products_wt currency=$currency->id}</td>
<td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td> <td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td>
</tr> </tr>
<tr id="total_discounts" {if $order->total_discounts_tax_incl == 0}style="display: none;"{/if}> <tr id="total_discounts" {if $order->total_discounts_tax_incl == 0}style="display: none;"{/if}>
<td><b>{l s='Discounts'}</b></td> <td><b>{l s='Discounts'}</b></td>
<td align="right">-{displayPrice price=$order->total_discounts_tax_incl currency=$currency->id}</td> <td class="amount" align="right">-{displayPrice price=$order->total_discounts_tax_incl currency=$currency->id}</td>
<td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td> <td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td>
</tr> </tr>
<tr id="total_wrapping" {if $order->total_wrapping_tax_incl == 0}style="display: none;"{/if}> <tr id="total_wrapping" {if $order->total_wrapping_tax_incl == 0}style="display: none;"{/if}>
<td><b>{l s='Wrapping'}</b></td> <td><b>{l s='Wrapping'}</b></td>
<td align="right">{displayPrice price=$order->total_wrapping_tax_incl currency=$currency->id}</td> <td class="amount" align="right">{displayPrice price=$order->total_wrapping_tax_incl currency=$currency->id}</td>
<td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td> <td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td>
</tr> </tr>
<tr id="total_shipping"> <tr id="total_shipping">
<td><b>{l s='Shipping'}</b></td> <td><b>{l s='Shipping'}</b></td>
<td align="right">{displayPrice price=$order->total_shipping_tax_incl currency=$currency->id}</td> <td class="amount" align="right">{displayPrice price=$order->total_shipping_tax_incl currency=$currency->id}</td>
<td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);"><input type="text" size="3" name="partialRefundShippingCost" /> &euro;</td> <td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);"><input type="text" size="3" name="partialRefundShippingCost" /> &euro;</td>
</tr> </tr>
<tr style="font-size: 20px" id="total_order"> <tr style="font-size: 20px" id="total_order">
<td style="font-size: 20px">{l s='Total'}</td> <td style="font-size: 20px">{l s='Total'}</td>
<td style="font-size: 20px" align="right"> <td class="amount" style="font-size: 20px" align="right">
{displayPrice price=$order->total_paid_tax_incl currency=$currency->id} {displayPrice price=$order->total_paid_tax_incl currency=$currency->id}
</td> </td>
<td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td> <td class="partial_refund_fields" style="display:none;background-color:rgb(232, 237, 194);">&nbsp;</td>
+2 -2
View File
@@ -563,8 +563,8 @@ class CarrierCore extends ObjectModel
} }
$row['name'] = (strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME')); $row['name'] = (strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'));
$row['price'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int)$row['id_carrier'])); $row['price'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier']));
$row['price_tax_exc'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int)$row['id_carrier'], false)); $row['price_tax_exc'] = ($shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int)$row['id_carrier'], false));
$row['img'] = file_exists(_PS_SHIP_IMG_DIR_.(int)$row['id_carrier']).'.jpg' ? _THEME_SHIP_DIR_.(int)$row['id_carrier'].'.jpg' : ''; $row['img'] = file_exists(_PS_SHIP_IMG_DIR_.(int)$row['id_carrier']).'.jpg' ? _THEME_SHIP_DIR_.(int)$row['id_carrier'].'.jpg' : '';
// If price is false, then the carrier is unavailable (carrier module) // If price is false, then the carrier is unavailable (carrier module)
+3 -2
View File
@@ -275,8 +275,8 @@ class CartCore extends ObjectModel
$total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS); $total_products_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
$total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS); $total_products_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$shipping_ti = $this->getOrderShippingCost(); $shipping_ti = $this->getPackageShippingCost();
$shipping_te = $this->getOrderShippingCost(NULL, false); $shipping_te = $this->getPackageShippingCost(NULL, false);
$result = Db::getInstance()->executeS(' $result = Db::getInstance()->executeS('
SELECT * SELECT *
@@ -1630,6 +1630,7 @@ class CartCore extends ObjectModel
*/ */
public function getOrderShippingCost($id_carrier = null, $useTax = true, Country $default_country = null, $product_list = null) public function getOrderShippingCost($id_carrier = null, $useTax = true, Country $default_country = null, $product_list = null)
{ {
Tools::displayAsDeprecated();
return $this->getPackageShippingCost($id_carrier, $useTax, $default_country, $product_list); return $this->getPackageShippingCost($id_carrier, $useTax, $default_country, $product_list);
} }
+4 -4
View File
@@ -452,7 +452,7 @@ class CartRuleCore extends ObjectModel
if ($this->free_shipping) if ($this->free_shipping)
{ {
if (!$this->carrier_restriction) if (!$this->carrier_restriction)
$reductionValue += $context->cart->getOrderShippingCost($context->cart->id_carrier, $useTax = true, $context->country); $reductionValue += $context->cart->getPackageShippingCost($context->cart->id_carrier, $useTax = true, $context->country);
elseif ($context->cart->id_carrier) elseif ($context->cart->id_carrier)
{ {
$id_cart_rule = (int)Db::getInstance()->getValue(' $id_cart_rule = (int)Db::getInstance()->getValue('
@@ -461,7 +461,7 @@ class CartRuleCore extends ObjectModel
WHERE crc.id_cart_rule = '.(int)$this->id.' WHERE crc.id_cart_rule = '.(int)$this->id.'
AND crc.id_carrier = '.(int)$context->cart->id_carrier); AND crc.id_carrier = '.(int)$context->cart->id_carrier);
if ($id_cart_rule) if ($id_cart_rule)
$reductionValue += $context->cart->getOrderShippingCost($context->cart->id_carrier, $useTax, $context->country); $reductionValue += $context->cart->getPackageShippingCost($context->cart->id_carrier, $useTax, $context->country);
} }
} }
@@ -492,7 +492,7 @@ class CartRuleCore extends ObjectModel
} }
} }
// Discount (¤) // Discount (�)
if ($this->reduction_amount) if ($this->reduction_amount)
{ {
$reduction_amount = $this->reduction_amount; $reduction_amount = $this->reduction_amount;
@@ -529,7 +529,7 @@ class CartRuleCore extends ObjectModel
$reductionValue += $reduction_amount * (1 + $product_vat_rate); $reductionValue += $reduction_amount * (1 + $product_vat_rate);
} }
} }
// Discount (¤) on the whole order // Discount (�) on the whole order
elseif ($this->reduction_product == 0) elseif ($this->reduction_product == 0)
{ {
$cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
+1 -1
View File
@@ -344,7 +344,7 @@ class OrderCore extends ObjectModel
$cart->update(); $cart->update();
/* Update order */ /* Update order */
$shippingDiff = $this->total_shipping - $cart->getOrderShippingCost(); $shippingDiff = $this->total_shipping - $cart->getPackageShippingCost();
$this->total_products -= $productPriceWithoutTax; $this->total_products -= $productPriceWithoutTax;
// After upgrading from old version // After upgrading from old version
+9 -9
View File
@@ -980,15 +980,15 @@ class AdminOrdersControllerCore extends AdminController
$order_invoice->total_paid_tax_incl = Tools::ps_round((float)$cart->getOrderTotal($use_taxes, Cart::BOTH), 2); $order_invoice->total_paid_tax_incl = Tools::ps_round((float)$cart->getOrderTotal($use_taxes, Cart::BOTH), 2);
$order_invoice->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $order_invoice->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$order_invoice->total_products_wt = (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS); $order_invoice->total_products_wt = (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
$order_invoice->total_shipping_tax_excl = (float)$cart->getOrderShippingCost(null, false); $order_invoice->total_shipping_tax_excl = (float)$cart->getPackageShippingCost(null, false);
$order_invoice->total_shipping_tax_incl = (float)$cart->getOrderShippingCost(); $order_invoice->total_shipping_tax_incl = (float)$cart->getPackageShippingCost();
$order_invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING)); $order_invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING));
$order_invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order_invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
// Update current order field, only shipping because other field is updated later // Update current order field, only shipping because other field is updated later
$order->total_shipping += (float)$cart->getOrderShippingCost(); $order->total_shipping += (float)$cart->getPackageShippingCost();
$order->total_shipping_tax_excl += (float)$cart->getOrderShippingCost(null, false); $order->total_shipping_tax_excl += (float)$cart->getPackageShippingCost(null, false);
$order->total_shipping_tax_incl += (float)$cart->getOrderShippingCost(null, $use_taxes); $order->total_shipping_tax_incl += (float)$cart->getPackageShippingCost(null, $use_taxes);
$order->total_wrapping += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order->total_wrapping += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
$order->total_wrapping_tax_excl += abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING)); $order->total_wrapping_tax_excl += abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING));
@@ -997,7 +997,7 @@ class AdminOrdersControllerCore extends AdminController
// Adding an entry in order_carrier table // Adding an entry in order_carrier table
Db::getInstance()->execute(' Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_carrier` (`id_order`, `id_carrier`, `id_order_invoice`, `weight`, `shipping_cost_tax_excl`, `shipping_cost_tax_incl`, `date_add`) VALUES INSERT INTO `'._DB_PREFIX_.'order_carrier` (`id_order`, `id_carrier`, `id_order_invoice`, `weight`, `shipping_cost_tax_excl`, `shipping_cost_tax_incl`, `date_add`) VALUES
('.(int)$order->id.', '.(int)$order->id_carrier.', '.(int)$order_invoice->id.', '.(float)$cart->getTotalWeight().', '.(float)$cart->getOrderShippingCost(null, false).', '.(float)$cart->getOrderShippingCost(null, $use_taxes).', NOW())'); ('.(int)$order->id.', '.(int)$order->id_carrier.', '.(int)$order_invoice->id.', '.(float)$cart->getTotalWeight().', '.(float)$cart->getPackageShippingCost(null, false).', '.(float)$cart->getPackageShippingCost(null, $use_taxes).', NOW())');
} }
// Update current invoice // Update current invoice
else else
@@ -1006,8 +1006,8 @@ class AdminOrdersControllerCore extends AdminController
$order_invoice->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, Cart::BOTH)), 2); $order_invoice->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, Cart::BOTH)), 2);
$order_invoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $order_invoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
$order_invoice->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS); $order_invoice->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
$order_invoice->total_shipping_tax_excl += (float)$cart->getOrderShippingCost(null, false); $order_invoice->total_shipping_tax_excl += (float)$cart->getPackageShippingCost(null, false);
$order_invoice->total_shipping_tax_incl += (float)$cart->getOrderShippingCost(null, $use_taxes); $order_invoice->total_shipping_tax_incl += (float)$cart->getPackageShippingCost(null, $use_taxes);
$order_invoice->total_wrapping_tax_excl += abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING)); $order_invoice->total_wrapping_tax_excl += abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING));
$order_invoice->total_wrapping_tax_incl += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order_invoice->total_wrapping_tax_incl += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
$order_invoice->update(); $order_invoice->update();
@@ -1283,7 +1283,7 @@ class AdminOrdersControllerCore extends AdminController
'error' => Tools::displayError('Can\'t edit this Order Detail for this order') 'error' => Tools::displayError('Can\'t edit this Order Detail for this order')
))); )));
if ($order_invoice->id_order != Tools::getValue('id_order')) if (!empty($order_invoice) && $order_invoice->id_order != Tools::getValue('id_order'))
die(Tools::jsonEncode(array( die(Tools::jsonEncode(array(
'result' => false, 'result' => false,
'error' => Tools::displayError('Can\'t use this invoice for this order') 'error' => Tools::displayError('Can\'t use this invoice for this order')
+5 -5
View File
@@ -523,27 +523,27 @@ function refreshProductLineView(element, view)
function updateAmounts(order) function updateAmounts(order)
{ {
$('#total_products td:last').fadeOut('slow', function() { $('#total_products td.amount').fadeOut('slow', function() {
$(this).html(formatCurrency(parseFloat(order.total_products_wt), currency_format, currency_sign, currency_blank)); $(this).html(formatCurrency(parseFloat(order.total_products_wt), currency_format, currency_sign, currency_blank));
$(this).fadeIn('slow'); $(this).fadeIn('slow');
}); });
$('#total_discounts td:last').fadeOut('slow', function() { $('#total_discounts td.amount').fadeOut('slow', function() {
$(this).html(formatCurrency(parseFloat(order.total_discounts_tax_incl), currency_format, currency_sign, currency_blank)); $(this).html(formatCurrency(parseFloat(order.total_discounts_tax_incl), currency_format, currency_sign, currency_blank));
$(this).fadeIn('slow'); $(this).fadeIn('slow');
}); });
if (order.total_discounts_tax_incl > 0) if (order.total_discounts_tax_incl > 0)
$('#total_discounts').slideDown('slow'); $('#total_discounts').slideDown('slow');
$('#total_wrapping td:last').fadeOut('slow', function() { $('#total_wrapping td.amount').fadeOut('slow', function() {
$(this).html(formatCurrency(parseFloat(order.total_wrapping_tax_incl), currency_format, currency_sign, currency_blank)); $(this).html(formatCurrency(parseFloat(order.total_wrapping_tax_incl), currency_format, currency_sign, currency_blank));
$(this).fadeIn('slow'); $(this).fadeIn('slow');
}); });
if (order.total_wrapping_tax_incl > 0) if (order.total_wrapping_tax_incl > 0)
$('#total_wrapping').slideDown('slow'); $('#total_wrapping').slideDown('slow');
$('#total_shipping td:last').fadeOut('slow', function() { $('#total_shipping td.amount').fadeOut('slow', function() {
$(this).html(formatCurrency(parseFloat(order.total_shipping_tax_incl), currency_format, currency_sign, currency_blank)); $(this).html(formatCurrency(parseFloat(order.total_shipping_tax_incl), currency_format, currency_sign, currency_blank));
$(this).fadeIn('slow'); $(this).fadeIn('slow');
}); });
$('#total_order td:last').fadeOut('slow', function() { $('#total_order td.amount').fadeOut('slow', function() {
$(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank)); $(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank));
$(this).fadeIn('slow'); $(this).fadeIn('slow');
}); });