// BugFix with opc and multishipping
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10330 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+2
-11
@@ -51,9 +51,6 @@ class CartCore extends ObjectModel
|
||||
/** @var integer Language ID */
|
||||
public $id_lang;
|
||||
|
||||
/** @var integer Carrier ID */
|
||||
public $id_carrier;
|
||||
|
||||
/** @var boolean True if the customer wants a recycled package */
|
||||
public $recyclable = 1;
|
||||
|
||||
@@ -87,7 +84,7 @@ class CartCore extends ObjectModel
|
||||
protected $fieldsRequired = array('id_currency', 'id_lang');
|
||||
protected $fieldsValidate = array('id_address_delivery' => 'isUnsignedId', 'id_address_invoice' => 'isUnsignedId',
|
||||
'id_currency' => 'isUnsignedId', 'id_customer' => 'isUnsignedId', 'id_guest' => 'isUnsignedId', 'id_lang' => 'isUnsignedId',
|
||||
'id_carrier' => 'isUnsignedId', 'recyclable' => 'isBool', 'gift' => 'isBool', 'gift_message' => 'isMessage',
|
||||
'recyclable' => 'isBool', 'gift' => 'isBool', 'gift_message' => 'isMessage',
|
||||
'allow_seperated_package' => 'isBool');
|
||||
|
||||
protected $_products = null;
|
||||
@@ -107,7 +104,6 @@ class CartCore extends ObjectModel
|
||||
'id_customer' => array('xlink_resource' => 'customers'),
|
||||
'id_guest' => array('xlink_resource' => 'guests'),
|
||||
'id_lang' => array('xlink_resource' => 'languages'),
|
||||
'id_carrier' => array('xlink_resource' => 'carriers'),
|
||||
),
|
||||
'associations' => array(
|
||||
'cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array(
|
||||
@@ -140,7 +136,6 @@ class CartCore extends ObjectModel
|
||||
$fields['id_customer'] = (int)($this->id_customer);
|
||||
$fields['id_guest'] = (int)($this->id_guest);
|
||||
$fields['id_lang'] = (int)($this->id_lang);
|
||||
$fields['id_carrier'] = (int)($this->id_carrier);
|
||||
$fields['recyclable'] = (int)($this->recyclable);
|
||||
$fields['gift'] = (int)($this->gift);
|
||||
$fields['secure_key'] = pSQL($this->secure_key);
|
||||
@@ -1633,10 +1628,6 @@ class CartCore extends ObjectModel
|
||||
$id_zone = (int)$default_country->id_zone;
|
||||
}
|
||||
|
||||
// If no carrier, select default one
|
||||
if (!$id_carrier)
|
||||
$id_carrier = $this->id_carrier;
|
||||
|
||||
if ($id_carrier && !$this->isCarrierInRange($id_carrier, $id_zone))
|
||||
$id_carrier = '';
|
||||
|
||||
@@ -1890,7 +1881,7 @@ class CartCore extends ObjectModel
|
||||
'invoice' => $invoice,
|
||||
'invoice_state' => State::getNameById($invoice->id_state),
|
||||
'formattedAddresses' => $formattedAddresses,
|
||||
'carrier' => new Carrier($this->id_carrier, $id_lang),
|
||||
//'carrier' => new Carrier($this->id_carrier, $id_lang),
|
||||
'products' => $this->getProducts(false),
|
||||
'discounts' => $this->getCartRules(),
|
||||
'is_virtual_cart' => (int)$this->isVirtualCart(),
|
||||
|
||||
@@ -219,9 +219,7 @@ class FrontControllerCore extends Controller
|
||||
$cart->id_address_invoice = 0;
|
||||
}
|
||||
}
|
||||
if (!$cart->nbProducts())
|
||||
$cart->id_carrier = NULL;
|
||||
|
||||
|
||||
$locale = strtolower(Configuration::get('PS_LOCALE_LANGUAGE')).'_'.strtoupper(Configuration::get('PS_LOCALE_COUNTRY').'.UTF-8');
|
||||
setlocale(LC_COLLATE, $locale);
|
||||
setlocale(LC_CTYPE, $locale);
|
||||
|
||||
@@ -119,9 +119,15 @@ abstract class PaymentModuleCore extends Module
|
||||
$delivery_option_list = $cart->getDeliveryOptionList();
|
||||
$package_list = $cart->getPackageList();
|
||||
$cart_delivery_option = unserialize($cart->delivery_option);
|
||||
|
||||
// If some delivery options are not defined, or not valid, use the first valid option
|
||||
foreach ($delivery_option_list as $id_address => $package)
|
||||
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package))
|
||||
die('Error: delivery option for some addresses is not defined');
|
||||
foreach ($package as $key => $val)
|
||||
{
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
|
||||
@@ -273,7 +273,7 @@ class AuthControllerCore extends FrontController
|
||||
if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0))
|
||||
$this->context->cookie->id_cart = (int)Cart::lastNoneOrderedCart($this->context->customer->id);
|
||||
// Update cart address
|
||||
$this->context->cart->id_carrier = 0;
|
||||
$this->context->cart->delivery_option = '';
|
||||
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
|
||||
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
|
||||
$this->context->cart->update();
|
||||
|
||||
@@ -104,7 +104,7 @@ class CartControllerCore extends FrontController
|
||||
{
|
||||
if (!Cart::getNbProducts((int)($this->context->cart->id)))
|
||||
{
|
||||
$this->context->cart->id_carrier = 0;
|
||||
$this->context->cart->delivery_option = '';
|
||||
$this->context->cart->gift = 0;
|
||||
$this->context->cart->gift_message = '';
|
||||
$this->context->cart->update();
|
||||
@@ -248,7 +248,7 @@ class CartControllerCore extends FrontController
|
||||
$deliveryAddress = new Address($this->context->cart->id_address_delivery);
|
||||
$id_country = (isset($deliveryAddress) && $deliveryAddress->id) ? $deliveryAddress->id_country : Configuration::get('PS_COUNTRY_DEFAULT');
|
||||
$result['carriers'] = Carrier::getCarriersForOrder(Country::getIdZone($id_country), $groups);
|
||||
$result['checked'] = Carrier::getDefaultCarrierSelection($result['carriers'], (int)$this->cart->id_carrier);
|
||||
//$result['checked'] = Carrier::getDefaultCarrierSelection($result['carriers'], (int)$this->cart->id_carrier);
|
||||
}
|
||||
$result['summary'] = $this->context->cart->getSummaryDetails();
|
||||
$result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true);
|
||||
|
||||
@@ -190,7 +190,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
unset($this->context->cart->id_address_invoice);
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
else if ($this->step >= 3 && !$this->context->cart->id_carrier && !$isVirtualCart)
|
||||
else if ($this->step >= 3 && !$this->context->cart->delivery_option && !$isVirtualCart)
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
break;
|
||||
case 'updateCarrierAndGetPayments':
|
||||
if (Tools::isSubmit('id_carrier') AND Tools::isSubmit('recyclable') AND Tools::isSubmit('gift') AND Tools::isSubmit('gift_message'))
|
||||
if (Tools::isSubmit('delivery_option') AND Tools::isSubmit('recyclable') AND Tools::isSubmit('gift') AND Tools::isSubmit('gift_message'))
|
||||
{
|
||||
if ($this->_processCarrier())
|
||||
{
|
||||
@@ -343,7 +343,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
protected function _assignPayment()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Hook::exec('paymentTop') : ''),
|
||||
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Hook::exec('paymentTop') : ''),
|
||||
'HOOK_PAYMENT' => $this->_getPaymentMethods()
|
||||
));
|
||||
}
|
||||
@@ -360,14 +360,8 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$address_invoice = ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice));
|
||||
if (!$this->context->cart->id_address_delivery OR !$this->context->cart->id_address_invoice OR !Validate::isLoadedObject($address_delivery) OR !Validate::isLoadedObject($address_invoice) OR $address_invoice->deleted OR $address_delivery->deleted)
|
||||
return '<p class="warning">'.Tools::displayError('Error: please choose an address').'</p>';
|
||||
if (!$this->context->cart->id_carrier AND !$this->context->cart->isVirtualCart())
|
||||
if (!$this->context->cart->delivery_option AND !$this->context->cart->isVirtualCart())
|
||||
return '<p class="warning">'.Tools::displayError('Error: please choose a carrier').'</p>';
|
||||
elseif ($this->context->cart->id_carrier != 0)
|
||||
{
|
||||
$carrier = new Carrier((int)($this->context->cart->id_carrier));
|
||||
if (!Validate::isLoadedObject($carrier) OR $carrier->deleted OR !$carrier->active)
|
||||
return '<p class="warning">'.Tools::displayError('Error: the carrier is invalid').'</p>';
|
||||
}
|
||||
if (!$this->context->cart->id_currency)
|
||||
return '<p class="warning">'.Tools::displayError('Error: no currency has been selected').'</p>';
|
||||
if (!$this->context->cookie->checkedTOS AND Configuration::get('PS_CONDITIONS'))
|
||||
|
||||
@@ -227,6 +227,8 @@ class ParentOrderControllerCore extends FrontController
|
||||
|
||||
// Carrier has changed, so we check if the cart rules still apply
|
||||
CartRule::autoRemoveFromCart();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,8 +249,6 @@ class ParentOrderControllerCore extends FrontController
|
||||
|
||||
protected function _assignSummaryInformations()
|
||||
{
|
||||
if (file_exists(_PS_SHIP_IMG_DIR_.$this->context->cart->id_carrier.'.jpg'))
|
||||
$this->context->smarty->assign('carrierPicture', 1);
|
||||
$summary = $this->context->cart->getSummaryDetails();
|
||||
$customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
|
||||
|
||||
@@ -435,13 +435,15 @@ class ParentOrderControllerCore extends FrontController
|
||||
*/
|
||||
protected function setNoCarrier()
|
||||
{
|
||||
$this->context->cart->id_carrier = 0;
|
||||
$this->context->cart->delivery_option = 0;
|
||||
$this->context->cart->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides what the default carrier is and update the cart with it
|
||||
*
|
||||
* @todo this function must be modified - id_carrier is now delivery_option
|
||||
*
|
||||
* @param array $carriers
|
||||
* @return number the id of the default carrier
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,9 @@ class CarrierCompare extends Module
|
||||
return (count($carriers) ? $carriers : array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo this function must be modified - id_carrier is now delivery_option
|
||||
*/
|
||||
public function saveSelection($id_country, $id_state, $zipcode, $id_carrier)
|
||||
{
|
||||
$errors = array();
|
||||
|
||||
@@ -363,6 +363,7 @@ class Socolissimo extends CarrierModule
|
||||
|
||||
public function hookExtraCarrier($params)
|
||||
{
|
||||
global $cookie;
|
||||
$customer = new Customer($params['address']->id_customer);
|
||||
$gender = new Gender($customer->id_gender);
|
||||
$carrierSo = new Carrier((int)(Configuration::get('SOCOLISSIMO_CARRIER_ID')));
|
||||
@@ -458,10 +459,10 @@ class Socolissimo extends CarrierModule
|
||||
public function hookAdminOrder($params)
|
||||
{
|
||||
|
||||
$deliveryMode = array('DOM' => 'Livraison à domicile', 'BPR' => 'Livraison en Bureau de Poste',
|
||||
'A2P' => 'Livraison Commerce de proximité', 'MRL' => 'Livraison Commerce de proximité',
|
||||
'CIT' => 'Livraison en Cityssimo', 'ACP' => 'Agence ColiPoste', 'CDI' => 'Centre de distribution',
|
||||
'RDV' => 'Livraison sur Rendez-vous');
|
||||
$deliveryMode = array('DOM' => 'Livraison à domicile', 'BPR' => 'Livraison en Bureau de Poste',
|
||||
'A2P' => 'Livraison Commerce de proximité', 'MRL' => 'Livraison Commerce de proximité',
|
||||
'CIT' => 'Livraison en Cityssimo', 'ACP' => 'Agence ColiPoste', 'CDI' => 'Centre de distribution',
|
||||
'RDV' => 'Livraison sur Rendez-vous');
|
||||
|
||||
$order = new Order($params['id_order']);
|
||||
$addressDelivery = new Address((int)($order->id_address_delivery), (int)($params['cookie']->id_lang));
|
||||
@@ -583,9 +584,9 @@ class Socolissimo extends CarrierModule
|
||||
$zones = Zone::getZones(true);
|
||||
foreach ($zones as $zone)
|
||||
{
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_zone VALUE (\''.(int)($carrier->id).'\',\''.(int)($zone['id_zone']).'\')');
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'delivery VALUE (\'\',\''.(int)($carrier->id).'\',\''.(int)($rangePrice->id).'\',NULL,\''.(int)($zone['id_zone']).'\',\'1\')');
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'delivery VALUE (\'\',\''.(int)($carrier->id).'\',NULL,\''.(int)($rangeWeight->id).'\',\''.(int)($zone['id_zone']).'\',\'1\')');
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_zone (id_carrier, id_zone) VALUE (\''.(int)($carrier->id).'\',\''.(int)($zone['id_zone']).'\')');
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'delivery (id_carrier, id_range_price, id_range_weight, id_zone, price) VALUE (\''.(int)($carrier->id).'\',\''.(int)($rangePrice->id).'\',NULL,\''.(int)($zone['id_zone']).'\',\'1\')');
|
||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'delivery (id_carrier, id_range_price, id_range_weight, id_zone, price) VALUE (\''.(int)($carrier->id).'\',NULL,\''.(int)($rangeWeight->id).'\',\''.(int)($zone['id_zone']).'\',\'1\')');
|
||||
}
|
||||
//copy logo
|
||||
if (!copy(dirname(__FILE__).'/socolissimo.jpg',_PS_SHIP_IMG_DIR_.'/'.$carrier->id.'.jpg'))
|
||||
|
||||
@@ -1120,11 +1120,11 @@ tr.cart_total_price { font-weight: bold }
|
||||
width: 100%;
|
||||
margin: 1em 0
|
||||
}
|
||||
#order .delivery_options_address {
|
||||
#order .delivery_options_address, #orderopc .delivery_options_address {
|
||||
width: 541px;
|
||||
margin-left: 7px;
|
||||
}
|
||||
#order .delivery_options_address h3 {
|
||||
#order .delivery_options_address h3, #orderopc .delivery_options_address h3 {
|
||||
background: url("../img/table_header.gif") no-repeat;
|
||||
background: url("http://prestashop15.localhost/themes/prestashop/css/../img/table_header.gif") no-repeat;
|
||||
color: #374853;
|
||||
@@ -1133,46 +1133,46 @@ tr.cart_total_price { font-weight: bold }
|
||||
padding: 5px 10px;
|
||||
margin: 10px 0 0 0;
|
||||
}
|
||||
#order .delivery_option_radio {
|
||||
#order .delivery_option_radio, #orderopc .delivery_option_radio {
|
||||
float: left;
|
||||
margin-top: 12px;
|
||||
}
|
||||
#order .delivery_option label {
|
||||
#order .delivery_option label, #orderopc .delivery_option label {
|
||||
display: block;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
#order .delivery_option label > table.resume {
|
||||
#order .delivery_option label > table.resume, #orderopc .delivery_option label > table.resume {
|
||||
width: 522px;
|
||||
height: 40px;
|
||||
}
|
||||
#order .delivery_option.item {
|
||||
#order .delivery_option.item, #orderopc .delivery_option.item, #orderopc {
|
||||
background: #FAFAFA;
|
||||
}
|
||||
#order .delivery_option.alternate_item {
|
||||
#order .delivery_option.alternate_item, #orderopc .delivery_option.alternate_item {
|
||||
background: #F1F2F4;
|
||||
border-top: 1px solid #BDC2C9;
|
||||
}
|
||||
#order .delivery_option label > table.resume td {
|
||||
#order .delivery_option label > table.resume td, #orderopc .delivery_option label > table.resume td, #orderopc {
|
||||
padding: 0 8px;
|
||||
}
|
||||
#order .delivery_option label > table.resume td + td {
|
||||
#order .delivery_option label > table.resume td + td, #orderopc .delivery_option label > table.resume td + td {
|
||||
text-align: left;
|
||||
width: 380px;
|
||||
}
|
||||
#order .delivery_option label > table.resume td + td + td {
|
||||
#order .delivery_option label > table.resume td + td + td, #orderopc .delivery_option label > table.resume td + td + td {
|
||||
text-align: right;
|
||||
width: 100px;
|
||||
}
|
||||
#order .delivery_options_address .delivery_option_logo {
|
||||
#order .delivery_options_address .delivery_option_logo, #orderopc .delivery_options_address .delivery_option_logo {
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
}
|
||||
#order .delivery_option_icon {
|
||||
#order .delivery_option_icon, #orderopc .delivery_option_icon {
|
||||
}
|
||||
#order .delivery_option_price {
|
||||
#order .delivery_option_price, #orderopc .delivery_option_price {
|
||||
}
|
||||
#order .delivery_options_address .delivery_option_logo img { height: 40px; }
|
||||
#order .delivery_option_carrier {
|
||||
#order .delivery_options_address .delivery_option_logo img, #orderopc .delivery_options_address .delivery_option_logo img { height: 40px; }
|
||||
#order .delivery_option_carrier, #orderopc .delivery_option_carrier {
|
||||
border: 1px solid #BDC2C9;
|
||||
background: white;
|
||||
margin: 5px 20px;
|
||||
|
||||
@@ -120,43 +120,43 @@ function updateAddressSelection()
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateAddressesSelected&id_address_delivery=' + idAddress_delivery + '&id_address_invoice=' + idAddress_invoice + '&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCarrierList(jsonData);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(jsonData.gift_price);
|
||||
$('#opc_account-overlay').fadeOut('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateAddressesSelected&id_address_delivery=' + idAddress_delivery + '&id_address_invoice=' + idAddress_invoice + '&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCarrierList(jsonData);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(jsonData.gift_price);
|
||||
$('#opc_account-overlay').fadeOut('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_account-overlay').fadeOut('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,14 +164,14 @@ function getCarrierListAndUpdate()
|
||||
{
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getCarrierList&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getCarrierList&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
@@ -194,6 +194,12 @@ function updateCarrierSelectionAndGift()
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
var idCarrier = 0;
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
@@ -212,33 +218,33 @@ function updateCarrierSelectionAndGift()
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments&id_carrier=' + idCarrier + '&recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
@@ -305,18 +311,18 @@ function saveAddress(type)
|
||||
var result = false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: addressUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&submitAddress=true&type='+type+'&'+params+'&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
type: 'POST',
|
||||
url: addressUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&submitAddress=true&type='+type+'&'+params+'&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
for(error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error != 'indexOf')
|
||||
@@ -348,7 +354,7 @@ function saveAddress(type)
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -644,15 +650,15 @@ $(function() {
|
||||
$('#message').blur(function() {
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(error in jsonData.errors)
|
||||
@@ -661,14 +667,14 @@ $(function() {
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Recyclable checkbox
|
||||
@@ -695,7 +701,7 @@ $(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// TOS
|
||||
// Term Of Service (TOS)
|
||||
$('#cgv').click(function() {
|
||||
if ($('#cgv:checked').length != 0)
|
||||
var checked = 1;
|
||||
@@ -704,19 +710,19 @@ $(function() {
|
||||
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
type: 'POST',
|
||||
url: orderOpcUrl,
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
$('div#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
|
||||
$('#opc_payment_methods-content div#HOOK_PAYMENT').html(json.HOOK_PAYMENT);
|
||||
$('#opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#opc_account_form input,select,textarea').change(function() {
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<div class="delivery_options">
|
||||
{foreach $option_list as $key => $option}
|
||||
<div class="delivery_option {if ($option@index % 2)}alternate_{/if}item">
|
||||
<input class="delivery_option_radio" type="radio" name="delivery_option[{$id_address}]" id="delivery_option_{$id_address}_{$option@index}" value="{$key}" />
|
||||
<input class="delivery_option_radio" type="radio" name="delivery_option[{$id_address}]" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} id="delivery_option_{$id_address}_{$option@index}" value="{$key}" />
|
||||
<label for="delivery_option_{$id_address}_{$option@index}">
|
||||
<table class="resume">
|
||||
<tr>
|
||||
|
||||
@@ -350,7 +350,7 @@
|
||||
{$addresses_style.alias = 'address_title'}
|
||||
{/if}
|
||||
|
||||
{if (($carrier->id AND !isset($virtualCart)) OR $delivery->id OR $invoice->id) AND !$opc}
|
||||
{if ((!empty($delivery_option) AND !isset($virtualCart)) OR $delivery->id OR $invoice->id) AND !$opc}
|
||||
<div class="order_delivery">
|
||||
{if !isset($formattedAddresses)}
|
||||
{if $delivery->id}
|
||||
@@ -393,6 +393,7 @@
|
||||
{/foreach}
|
||||
<p class="clear" />
|
||||
{/if}
|
||||
{* @todo Replace the $carrier by using delivery_option *}
|
||||
{if $carrier->id AND !isset($virtualCart)}
|
||||
<div id="order_carrier">
|
||||
<h4>{l s='Carrier:'}</h4>
|
||||
|
||||
Reference in New Issue
Block a user