diff --git a/classes/Address.php b/classes/Address.php index bd2daea0e..616b44dac 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -337,12 +337,6 @@ class AddressCore extends ObjectModel */ public static function initialize($id_address = null) { - // set the default address - $address = new Address(); - $address->id_country = (int)Context::getContext()->country->id; - $address->id_state = 0; - $address->postcode = 0; - // if an id_address has been specified retrieve the address if ($id_address) { @@ -351,6 +345,14 @@ class AddressCore extends ObjectModel if (!Validate::isLoadedObject($address)) throw new PrestaShopException('Invalid address'); } + else + { + // set the default address + $address = new Address(); + $address->id_country = (int)Context::getContext()->country->id; + $address->id_state = 0; + $address->postcode = 0; + } return $address; } diff --git a/classes/Cart.php b/classes/Cart.php index 11641a80f..c821ffe58 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1509,9 +1509,8 @@ class CartCore extends ObjectModel // If the cart rule offers a reduction, the amount is prorated (with the products in the package) if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) - { $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 2); - } + } $order_total_discount = min(Tools::ps_round($order_total_discount, 2), $wrapping_fees + $order_total_products + $shipping_fees); @@ -2600,7 +2599,10 @@ class CartCore extends ObjectModel // Select carrier tax if ($use_tax && !Tax::excludeTaxeOption()) - $carrier_tax = $carrier->getTaxesRate(new Address((int)$address_id)); + { + $address = Address::initialize((int)$address_id); + $carrier_tax = $carrier->getTaxesRate($address); + } $configuration = Configuration::getMultiple(array( 'PS_SHIPPING_FREE_PRICE',