From 30cdc8b2771c520f4f0a48db658ca09bf60db53c Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Tue, 21 Feb 2012 10:02:56 +0000 Subject: [PATCH] // Don't preselect delivery options git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13488 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Cart.php | 5 ++++- controllers/front/OrderOpcController.php | 10 +++++----- controllers/front/ParentOrderController.php | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 1957292fc..85e3b9e44 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2038,7 +2038,7 @@ class CartCore extends ObjectModel * Get the delivery option seleted, or if no delivery option was selected, the cheapest option for each address * @return array delivery option */ - public function getDeliveryOption($default_country = null) + public function getDeliveryOption($default_country = null, $dontAutoSeletectOptions = false) { $delivery_option_list = $this->getDeliveryOptionList($default_country); @@ -2057,6 +2057,9 @@ class CartCore extends ObjectModel if ($validated) return $delivery_option; } + + if ($dontAutoSeletectOptions) + return false; // No delivery option selected or delivery option selected is not valid, get the better for all options $delivery_option = array(); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index b69794fd7..e3fe8c95f 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -376,7 +376,7 @@ class OrderOpcControllerCore extends ParentOrderController 'carriers' => $carriers, 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), - 'delivery_option' => $this->context->cart->getDeliveryOption() + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true) )) )); } @@ -411,7 +411,7 @@ class OrderOpcControllerCore extends ParentOrderController else return '

'.Tools::displayError('Error: There are no carriers available that deliver to this address').'

'; } - if (!$this->context->cart->getDeliveryOption() && !$this->context->cart->isVirtualCart()) + if (!$this->context->cart->getDeliveryOption(null, true) && !$this->context->cart->isVirtualCart()) return '

'.Tools::displayError('Error: please choose a carrier').'

'; if (!$this->context->cart->id_currency) return '

'.Tools::displayError('Error: no currency has been selected').'

'; @@ -464,13 +464,13 @@ class OrderOpcControllerCore extends ParentOrderController 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'carriers' => $carriers, 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), - 'delivery_option' => $this->context->cart->getDeliveryOption(), + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true), 'address_collection' => $this->context->cart->getAddressCollection(), 'opc' => true, 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array( 'carriers' => $carriers, 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), - 'delivery_option' => $this->context->cart->getDeliveryOption() + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true) )) ); @@ -488,7 +488,7 @@ class OrderOpcControllerCore extends ParentOrderController 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array( 'carriers' => $carriers, 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), - 'delivery_option' => $this->context->cart->getDeliveryOption() + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true) )), 'carrier_block' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-carrier.tpl') ); diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php index 30d3bc881..976d6d251 100644 --- a/controllers/front/ParentOrderController.php +++ b/controllers/front/ParentOrderController.php @@ -409,7 +409,7 @@ class ParentOrderControllerCore extends FrontController 'delivery_option_list' => $delivery_option_list, 'carriers' => $carriers, 'checked' => $checked, - 'delivery_option' => $this->context->cart->getDeliveryOption() + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true) )); $vars = array( @@ -417,7 +417,7 @@ class ParentOrderControllerCore extends FrontController 'carriers' => $carriers, 'checked' => $checked, 'delivery_option_list' => $delivery_option_list, - 'delivery_option' => $this->context->cart->getDeliveryOption() + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true) )) ); @@ -453,7 +453,7 @@ class ParentOrderControllerCore extends FrontController 'carriers' => $this->context->cart->simulateCarriersOutput(), 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), 'address_collection' => $this->context->cart->getAddressCollection(), - 'delivery_option' => $this->context->cart->getDeliveryOption(), + 'delivery_option' => $this->context->cart->getDeliveryOption(null, true), 'gift_wrapping_price' => (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE')), 'total_wrapping_cost' => Tools::convertPrice($wrapping_fees_tax_inc, $this->context->currency), 'total_wrapping_tax_exc_cost' => Tools::convertPrice($wrapping_fees, $this->context->currency)));