Version Notes
- Manage Regions & Cities in backend
- Show drop down in all address forms
Download this release
Release Info
Developer | Magebuzz |
Extension | magebuzz_region_city_manager |
Version | 0.1.1 |
Comparing to | |
See all releases |
Version 0.1.1
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City.php +13 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit.php +43 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Form.php +20 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Tab/Form.php +94 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Tabs.php +22 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Grid.php +128 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Customer/Edit/Renderer/City.php +68 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Customer/Edit/Tab/Addresses.php +122 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region.php +13 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit.php +43 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Form.php +20 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Tab/Form.php +75 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Tabs.php +22 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Grid.php +117 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Renderer/Name.php +32 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Sales/Order/Create/Billing/Address.php +21 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Sales/Order/Create/Shipping/Address.php +21 -0
- app/code/local/Magebuzz/Improvedaddress/Block/Improvedaddress.php +16 -0
- app/code/local/Magebuzz/Improvedaddress/Helper/Data.php +58 -0
- app/code/local/Magebuzz/Improvedaddress/Model/City.php +22 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Customer/Renderer/City.php +88 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Improvedaddress.php +10 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/City.php +9 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/City/Collection.php +22 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Improvedaddress.php +10 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Improvedaddress/Collection.php +10 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Region.php +7 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Region/Collection.php +7 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Subdistrict.php +9 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Subdistrict/Collection.php +22 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Observer.php +28 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Region.php +9 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Resource/Region.php +6 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Resource/Region/Collection.php +5 -0
- app/code/local/Magebuzz/Improvedaddress/Model/Status.php +15 -0
- app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/CityController.php +162 -0
- app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/DataController.php +33 -0
- app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/JsonController.php +44 -0
- app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/RegionController.php +155 -0
- app/code/local/Magebuzz/Improvedaddress/controllers/IndexController.php +10 -0
- app/code/local/Magebuzz/Improvedaddress/etc/adminhtml.xml +60 -0
- app/code/local/Magebuzz/Improvedaddress/etc/config.xml +168 -0
- app/code/local/Magebuzz/Improvedaddress/sql/improvedaddress_setup/mysql4-install-0.1.0.php +45 -0
- app/code/local/Magebuzz/Improvedaddress/sql/improvedaddress_setup/mysql4-upgrade-0.1.0-0.1.1.php +20 -0
- app/design/adminhtml/default/default/layout/improvedaddress.xml +32 -0
- app/design/adminhtml/default/default/template/improvedaddress/customer/tab/addresses.phtml +853 -0
- app/design/adminhtml/default/default/template/improvedaddress/sales/order/create/form/address.phtml +93 -0
- app/design/frontend/base/default/layout/improvedaddress.xml +35 -0
- app/design/frontend/base/default/template/improvedaddress/checkout/onepage.phtml +60 -0
- app/design/frontend/base/default/template/improvedaddress/checkout/onepage/billing.phtml +226 -0
- app/design/frontend/base/default/template/improvedaddress/checkout/onepage/shipping.phtml +167 -0
- app/design/frontend/base/default/template/improvedaddress/customer/address/edit.phtml +141 -0
- app/design/frontend/base/default/template/improvedaddress/customer/form/register.phtml +166 -0
- app/design/frontend/rwd/default/template/improvedaddress/checkout/onepage.phtml +61 -0
- app/design/frontend/rwd/default/template/improvedaddress/customer/form/register.phtml +166 -0
- app/etc/modules/Magebuzz_Improvedaddress.xml +9 -0
- js/magebuzz/improvedaddress.js +88 -0
- package.xml +19 -0
- skin/frontend/base/default/magebuzz/improvedaddress/js/opcheckout.js +988 -0
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City.php
ADDED
@@ -0,0 +1,13 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
6 |
+
public function __construct() {
|
7 |
+
$this->_controller = 'adminhtml_city';
|
8 |
+
$this->_blockGroup = 'improvedaddress';
|
9 |
+
$this->_headerText = Mage::helper('improvedaddress')->__('Manage City');
|
10 |
+
$this->_addButtonLabel = Mage::helper('improvedaddress')->__('Add City');
|
11 |
+
parent::__construct();
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit.php
ADDED
@@ -0,0 +1,43 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->_objectId = 'id';
|
9 |
+
$this->_blockGroup = 'improvedaddress';
|
10 |
+
$this->_controller = 'adminhtml_city';
|
11 |
+
|
12 |
+
$this->_updateButton('save', 'label', Mage::helper('improvedaddress')->__('Save Item'));
|
13 |
+
$this->_updateButton('delete', 'label', Mage::helper('improvedaddress')->__('Delete Item'));
|
14 |
+
|
15 |
+
$this->_addButton('saveandcontinue', array(
|
16 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
17 |
+
'onclick' => 'saveAndContinueEdit()',
|
18 |
+
'class' => 'save',
|
19 |
+
), -100);
|
20 |
+
|
21 |
+
$this->_formScripts[] = "
|
22 |
+
function toggleEditor() {
|
23 |
+
if (tinyMCE.getInstanceById('improvedaddress_content') == null) {
|
24 |
+
tinyMCE.execCommand('mceAddControl', false, 'improvedaddress_content');
|
25 |
+
} else {
|
26 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'improvedaddress_content');
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
function saveAndContinueEdit(){
|
31 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
32 |
+
}
|
33 |
+
";
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getHeaderText() {
|
37 |
+
if( Mage::registry('city_data') && Mage::registry('city_data')->getId() ) {
|
38 |
+
return Mage::helper('improvedaddress')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('city_data')->getDefaultName()));
|
39 |
+
} else {
|
40 |
+
return Mage::helper('improvedaddress')->__('Add Item');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
6 |
+
protected function _prepareForm() {
|
7 |
+
$form = new Varien_Data_Form(
|
8 |
+
array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
11 |
+
'method' => 'post',
|
12 |
+
'enctype' => 'multipart/form-data'
|
13 |
+
)
|
14 |
+
);
|
15 |
+
|
16 |
+
$form->setUseContainer(true);
|
17 |
+
$this->setForm($form);
|
18 |
+
return parent::_prepareForm();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,94 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
6 |
+
protected $_regionOptions = null;
|
7 |
+
|
8 |
+
protected function _prepareForm() {
|
9 |
+
$form = new Varien_Data_Form();
|
10 |
+
$this->setForm($form);
|
11 |
+
$countries = Mage::getSingleton('directory/country')->getCollection()
|
12 |
+
->loadData()->toOptionArray(false);
|
13 |
+
|
14 |
+
$regions = $this->getThaiRegions();
|
15 |
+
|
16 |
+
$fieldSet = $form->addFieldset('improvedaddress_form', array('legend'=>Mage::helper('improvedaddress')->__('City Information')));
|
17 |
+
|
18 |
+
$regionUrl = Mage::getUrl('*/*/reloadRegion');
|
19 |
+
$fieldSet->addField('country_id', 'select',
|
20 |
+
array(
|
21 |
+
'label' => Mage::helper('improvedaddress')->__('Country'),
|
22 |
+
'name' => 'country_id',
|
23 |
+
'required' => true,
|
24 |
+
'values' => $countries,
|
25 |
+
'onchange' => "reloadRegion(this.value, '$regionUrl')",
|
26 |
+
)
|
27 |
+
);
|
28 |
+
|
29 |
+
$fieldSet->addField('region_id', 'select',
|
30 |
+
array(
|
31 |
+
'label' => Mage::helper('improvedaddress')->__('Region'),
|
32 |
+
'name' => 'region_id',
|
33 |
+
'required' => true,
|
34 |
+
'values' => $regions,
|
35 |
+
//'onchange' => "alert('haa')"
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
+
$fieldSet->addField('code', 'text',
|
40 |
+
array(
|
41 |
+
'label' => Mage::helper('improvedaddress')->__('Code'),
|
42 |
+
'class' => 'required-entry',
|
43 |
+
'required' => true,
|
44 |
+
'name' => 'code',
|
45 |
+
)
|
46 |
+
);
|
47 |
+
$fieldSet->addField('default_name', 'text',
|
48 |
+
array(
|
49 |
+
'label' => Mage::helper('improvedaddress')->__('Default Name'),
|
50 |
+
'class' => 'required-entry',
|
51 |
+
'required' => true,
|
52 |
+
'name' => 'default_name',
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
// $fieldset->addField('status', 'select', array(
|
57 |
+
// 'label' => Mage::helper('improvedaddress')->__('Status'),
|
58 |
+
// 'name' => 'status',
|
59 |
+
// 'values' => array(
|
60 |
+
// array(
|
61 |
+
// 'value' => 1,
|
62 |
+
// 'label' => Mage::helper('improvedaddress')->__('Enabled'),
|
63 |
+
// ),
|
64 |
+
// array(
|
65 |
+
// 'value' => 2,
|
66 |
+
// 'label' => Mage::helper('improvedaddress')->__('Disabled'),
|
67 |
+
// ),
|
68 |
+
// ),
|
69 |
+
// ));
|
70 |
+
|
71 |
+
if (Mage::getSingleton('adminhtml/session')->getCityData()) {
|
72 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getCityData());
|
73 |
+
Mage::getSingleton('adminhtml/session')->setCityData(null);
|
74 |
+
} elseif ( Mage::registry('city_data') ) {
|
75 |
+
$form->setValues(Mage::registry('city_data')->getData());
|
76 |
+
}
|
77 |
+
return parent::_prepareForm();
|
78 |
+
}
|
79 |
+
|
80 |
+
public function getThaiRegions() {
|
81 |
+
if ($this->_regionOptions == null) {
|
82 |
+
$this->_regionOptions[] = array('value' => '', 'label' => '');
|
83 |
+
$regions = Mage::getSingleton('improvedaddress/region')->getCollection()
|
84 |
+
->addFieldToFilter('country_id', 'TH');
|
85 |
+
foreach ($regions as $region) {
|
86 |
+
$this->_regionOptions[] = array(
|
87 |
+
'value' => $region->getRegionId(),
|
88 |
+
'label' => $region->getDefaultName()
|
89 |
+
);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
return $this->_regionOptions;
|
93 |
+
}
|
94 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Edit/Tabs.php
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('improvedaddress_tabs');
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('improvedaddress')->__('City Information'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml() {
|
14 |
+
$this->addTab('form_section', array(
|
15 |
+
'label' => Mage::helper('improvedaddress')->__('City Information'),
|
16 |
+
'title' => Mage::helper('improvedaddress')->__('City Information'),
|
17 |
+
'content' => $this->getLayout()->createBlock('improvedaddress/adminhtml_city_edit_tab_form')->toHtml(),
|
18 |
+
));
|
19 |
+
|
20 |
+
return parent::_beforeToHtml();
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/City/Grid.php
ADDED
@@ -0,0 +1,128 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_City_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('cityGrid');
|
9 |
+
$this->setDefaultSort('city_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _addColumnFilterToCollection($column) {
|
15 |
+
$field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
|
16 |
+
if ($field == 'region_name') {
|
17 |
+
if ($this->getCollection()) {
|
18 |
+
$cond = $column->getFilter()->getCondition();
|
19 |
+
if ($field && isset($cond)) {
|
20 |
+
$this->getCollection()->addFieldToFilter('region.default_name' , $cond);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
else if ($field == 'country_id') {
|
25 |
+
$cond = $column->getFilter()->getCondition();
|
26 |
+
if ($field && isset($cond)) {
|
27 |
+
$this->getCollection()->addFieldToFilter('region.country_id' , $cond);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
return parent::_addColumnFilterToCollection();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function _prepareCollection() {
|
36 |
+
$collection = Mage::getModel('improvedaddress/city')->getCollection();
|
37 |
+
$collection->getSelect()->join(
|
38 |
+
array('region' => Mage::getSingleton('core/resource')->getTableName('directory_country_region')),
|
39 |
+
'main_table.region_id=region.region_id',
|
40 |
+
array('region.default_name as region_name', 'region.country_id as country_id')
|
41 |
+
);
|
42 |
+
//echo $collection->getSelect()->__toString();die('aa');
|
43 |
+
$this->setCollection($collection);
|
44 |
+
return parent::_prepareCollection();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _prepareColumns() {
|
48 |
+
$this->addColumn('city_id', array(
|
49 |
+
'header' => Mage::helper('improvedaddress')->__('ID'),
|
50 |
+
'align' =>'right',
|
51 |
+
'width' => '50px',
|
52 |
+
'index' => 'city_id',
|
53 |
+
));
|
54 |
+
|
55 |
+
$this->addColumn(
|
56 |
+
'country_id', array(
|
57 |
+
'header' => Mage::helper('improvedaddress')->__('Country Code'),
|
58 |
+
'align' => 'left',
|
59 |
+
'width' => '110px',
|
60 |
+
'index' => 'country_id',
|
61 |
+
'type' => 'country',
|
62 |
+
)
|
63 |
+
);
|
64 |
+
|
65 |
+
$this->addColumn('region_name', array(
|
66 |
+
'header' => Mage::helper('improvedaddress')->__('Region'),
|
67 |
+
'align' =>'right',
|
68 |
+
'width' => '50px',
|
69 |
+
'index' => 'region_name',
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('code', array(
|
73 |
+
'header' => Mage::helper('improvedaddress')->__('City Code'),
|
74 |
+
'align' => 'left',
|
75 |
+
'width' => '110px',
|
76 |
+
'index' => 'code',
|
77 |
+
//'editable' =>true,
|
78 |
+
'column_css_class' => 'code_td'
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('default_name', array(
|
82 |
+
'header' => Mage::helper('improvedaddress')->__('Default Name'),
|
83 |
+
'align' => 'left',
|
84 |
+
'width' => '110px',
|
85 |
+
'index' => 'default_name',
|
86 |
+
//'editable' =>true,
|
87 |
+
'column_css_class' => 'default_name'
|
88 |
+
));
|
89 |
+
|
90 |
+
$this->addColumn('action',
|
91 |
+
array(
|
92 |
+
'header' => Mage::helper('improvedaddress')->__('Action'),
|
93 |
+
'width' => '100',
|
94 |
+
'type' => 'action',
|
95 |
+
'getter' => 'getId',
|
96 |
+
'actions' => array(
|
97 |
+
array(
|
98 |
+
'caption' => Mage::helper('improvedaddress')->__('Edit'),
|
99 |
+
'url' => array('base'=> '*/*/edit'),
|
100 |
+
'field' => 'id'
|
101 |
+
)
|
102 |
+
),
|
103 |
+
'filter' => false,
|
104 |
+
'sortable' => false,
|
105 |
+
'index' => 'stores',
|
106 |
+
'is_system' => true,
|
107 |
+
));
|
108 |
+
|
109 |
+
return parent::_prepareColumns();
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function _prepareMassaction() {
|
113 |
+
$this->setMassactionIdField('city_id');
|
114 |
+
$this->getMassactionBlock()->setFormFieldName('city');
|
115 |
+
|
116 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
117 |
+
'label' => Mage::helper('improvedaddress')->__('Delete'),
|
118 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
119 |
+
'confirm' => Mage::helper('improvedaddress')->__('Are you sure?')
|
120 |
+
));
|
121 |
+
|
122 |
+
return $this;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function getRowUrl($row) {
|
126 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
127 |
+
}
|
128 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Customer/Edit/Renderer/City.php
ADDED
@@ -0,0 +1,68 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Customer_Edit_Renderer_City
|
6 |
+
extends Mage_Adminhtml_Block_Abstract
|
7 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Factory instance
|
11 |
+
*
|
12 |
+
* @var Mage_Core_Model_Abstract
|
13 |
+
*/
|
14 |
+
protected $_factory;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor for Mage_Adminhtml_Block_Customer_Edit_Renderer_Region class
|
18 |
+
*
|
19 |
+
* @param array $args
|
20 |
+
*/
|
21 |
+
public function __construct(array $args = array())
|
22 |
+
{
|
23 |
+
$this->_factory = !empty($args['factory']) ? $args['factory'] : Mage::getSingleton('core/factory');
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Output the city element and javasctipt that makes it dependent from region element
|
28 |
+
*
|
29 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
33 |
+
{
|
34 |
+
$country = $element->getForm()->getElement('country_id');
|
35 |
+
$region = $element->getForm()->getElement('region_id');
|
36 |
+
if (!is_null($region)) {
|
37 |
+
$regionId = $region->getValue();
|
38 |
+
} else {
|
39 |
+
return $element->getDefaultHtml();
|
40 |
+
}
|
41 |
+
|
42 |
+
$cityId = $element->getForm()->getElement('city_id')->getValue();
|
43 |
+
$quoteStoreId = $element->getEntityAttribute()->getStoreId();
|
44 |
+
|
45 |
+
$html = '<tr>';
|
46 |
+
$element->setClass('input-text');
|
47 |
+
$element->setRequired(true);
|
48 |
+
$html .= '<td class="label">' . $element->getLabelHtml() . '</td><td class="value">';
|
49 |
+
$html .= $element->getElementHtml();
|
50 |
+
|
51 |
+
$selectName = str_replace('city', 'city_id', $element->getName());
|
52 |
+
$selectId = $element->getHtmlId() . '_id';
|
53 |
+
$html .= '<select id="' . $selectId . '" name="' . $selectName
|
54 |
+
. '" class="select required-entry" style="display:none">';
|
55 |
+
$html .= '<option value="">' . $this->_factory->getHelper('customer')->__('Please select') . '</option>';
|
56 |
+
$html .= '</select>';
|
57 |
+
|
58 |
+
$html .= '<script type="text/javascript">' . "\n";
|
59 |
+
$html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $cityId.'");' . "\n";
|
60 |
+
$html .= 'new CityUpdater("' . $country->getHtmlId() . '", "' . $region->getHtmlId() . '", "' . $element->getHtmlId() . '", "' .
|
61 |
+
$selectId . '", ' . Mage::helper('improvedaddress')->getCityJson().');' . "\n";
|
62 |
+
$html .= '</script>' . "\n";
|
63 |
+
|
64 |
+
$html .= '</td></tr>' . "\n";
|
65 |
+
|
66 |
+
return $html;
|
67 |
+
}
|
68 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Customer/Edit/Tab/Addresses.php
ADDED
@@ -0,0 +1,122 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Customer_Edit_Tab_Addresses extends Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('improvedaddress/customer/tab/addresses.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getCitiesUrl() {
|
12 |
+
return $this->getUrl('adminhtml/improvedaddress_json/city');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function initForm() {
|
16 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
17 |
+
$customer = Mage::registry('current_customer');
|
18 |
+
|
19 |
+
$form = new Varien_Data_Form();
|
20 |
+
$fieldset = $form->addFieldset('address_fieldset', array(
|
21 |
+
'legend' => Mage::helper('customer')->__("Edit Customer's Address"))
|
22 |
+
);
|
23 |
+
|
24 |
+
$addressModel = Mage::getModel('customer/address');
|
25 |
+
$addressModel->setCountryId(Mage::helper('core')->getDefaultCountry($customer->getStore()));
|
26 |
+
/** @var $addressForm Mage_Customer_Model_Form */
|
27 |
+
$addressForm = Mage::getModel('customer/form');
|
28 |
+
$addressForm->setFormCode('adminhtml_customer_address')
|
29 |
+
->setEntity($addressModel)
|
30 |
+
->initDefaultValues();
|
31 |
+
$attributes = $addressForm->getAttributes();
|
32 |
+
if(isset($attributes['street'])) {
|
33 |
+
Mage::helper('adminhtml/addresses')
|
34 |
+
->processStreetAttribute($attributes['street']);
|
35 |
+
}
|
36 |
+
foreach ($attributes as $attribute) {
|
37 |
+
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
|
38 |
+
$attribute->setFrontendLabel(Mage::helper('customer')->__($attribute->getFrontend()->getLabel()));
|
39 |
+
$attribute->unsIsVisible();
|
40 |
+
}
|
41 |
+
$this->_setFieldset($attributes, $fieldset);
|
42 |
+
|
43 |
+
$regionElement = $form->getElement('region');
|
44 |
+
$regionElement->setRequired(true);
|
45 |
+
if ($regionElement) {
|
46 |
+
$regionElement->setRenderer(Mage::getModel('adminhtml/customer_renderer_region'));
|
47 |
+
}
|
48 |
+
|
49 |
+
$regionElement = $form->getElement('region_id');
|
50 |
+
if ($regionElement) {
|
51 |
+
$regionElement->setNoDisplay(true);
|
52 |
+
}
|
53 |
+
|
54 |
+
$cityElement = $form->getElement('city');
|
55 |
+
$cityElement->setRequired(true);
|
56 |
+
|
57 |
+
if ($cityElement) {
|
58 |
+
$cityElement->addClass('cities');
|
59 |
+
$cityElement->setRenderer(Mage::getModel('improvedaddress/customer_renderer_city'));
|
60 |
+
}
|
61 |
+
|
62 |
+
$cityElement = $form->getElement('city_id');
|
63 |
+
if ($cityElement) {
|
64 |
+
$cityElement->setNoDisplay(true);
|
65 |
+
}
|
66 |
+
|
67 |
+
$country = $form->getElement('country_id');
|
68 |
+
if ($country) {
|
69 |
+
$country->addClass('countries');
|
70 |
+
}
|
71 |
+
|
72 |
+
if ($this->isReadonly()) {
|
73 |
+
foreach ($addressModel->getAttributes() as $attribute) {
|
74 |
+
$element = $form->getElement($attribute->getAttributeCode());
|
75 |
+
if ($element) {
|
76 |
+
$element->setReadonly(true, true);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
$customerStoreId = null;
|
82 |
+
if ($customer->getId()) {
|
83 |
+
$customerStoreId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
|
84 |
+
}
|
85 |
+
|
86 |
+
$prefixElement = $form->getElement('prefix');
|
87 |
+
if ($prefixElement) {
|
88 |
+
$prefixOptions = $this->helper('customer')->getNamePrefixOptions($customerStoreId);
|
89 |
+
if (!empty($prefixOptions)) {
|
90 |
+
$fieldset->removeField($prefixElement->getId());
|
91 |
+
$prefixField = $fieldset->addField($prefixElement->getId(),
|
92 |
+
'select',
|
93 |
+
$prefixElement->getData(),
|
94 |
+
'^'
|
95 |
+
);
|
96 |
+
$prefixField->setValues($prefixOptions);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
$suffixElement = $form->getElement('suffix');
|
101 |
+
if ($suffixElement) {
|
102 |
+
$suffixOptions = $this->helper('customer')->getNameSuffixOptions($customerStoreId);
|
103 |
+
if (!empty($suffixOptions)) {
|
104 |
+
$fieldset->removeField($suffixElement->getId());
|
105 |
+
$suffixField = $fieldset->addField($suffixElement->getId(),
|
106 |
+
'select',
|
107 |
+
$suffixElement->getData(),
|
108 |
+
$form->getElement('lastname')->getId()
|
109 |
+
);
|
110 |
+
$suffixField->setValues($suffixOptions);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$addressCollection = $customer->getAddresses();
|
115 |
+
$this->assign('customer', $customer);
|
116 |
+
$this->assign('addressCollection', $addressCollection);
|
117 |
+
$form->setValues($addressModel->getData());
|
118 |
+
$this->setForm($form);
|
119 |
+
|
120 |
+
return $this;
|
121 |
+
}
|
122 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region.php
ADDED
@@ -0,0 +1,13 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
6 |
+
public function __construct() {
|
7 |
+
$this->_controller = 'adminhtml_region';
|
8 |
+
$this->_blockGroup = 'improvedaddress';
|
9 |
+
$this->_headerText = Mage::helper('improvedaddress')->__('Manage Region/States');
|
10 |
+
$this->_addButtonLabel = Mage::helper('improvedaddress')->__('Add Item');
|
11 |
+
parent::__construct();
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit.php
ADDED
@@ -0,0 +1,43 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->_objectId = 'id';
|
9 |
+
$this->_blockGroup = 'improvedaddress';
|
10 |
+
$this->_controller = 'adminhtml_region';
|
11 |
+
|
12 |
+
$this->_updateButton('save', 'label', Mage::helper('improvedaddress')->__('Save Item'));
|
13 |
+
$this->_updateButton('delete', 'label', Mage::helper('improvedaddress')->__('Delete Item'));
|
14 |
+
|
15 |
+
$this->_addButton('saveandcontinue', array(
|
16 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
17 |
+
'onclick' => 'saveAndContinueEdit()',
|
18 |
+
'class' => 'save',
|
19 |
+
), -100);
|
20 |
+
|
21 |
+
$this->_formScripts[] = "
|
22 |
+
function toggleEditor() {
|
23 |
+
if (tinyMCE.getInstanceById('improvedaddress_content') == null) {
|
24 |
+
tinyMCE.execCommand('mceAddControl', false, 'improvedaddress_content');
|
25 |
+
} else {
|
26 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'improvedaddress_content');
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
function saveAndContinueEdit(){
|
31 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
32 |
+
}
|
33 |
+
";
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getHeaderText() {
|
37 |
+
if( Mage::registry('improvedaddress_data') && Mage::registry('improvedaddress_data')->getId() ) {
|
38 |
+
return Mage::helper('improvedaddress')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('improvedaddress_data')->getTitle()));
|
39 |
+
} else {
|
40 |
+
return Mage::helper('improvedaddress')->__('Add Item');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
6 |
+
protected function _prepareForm() {
|
7 |
+
$form = new Varien_Data_Form(
|
8 |
+
array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
11 |
+
'method' => 'post',
|
12 |
+
'enctype' => 'multipart/form-data'
|
13 |
+
)
|
14 |
+
);
|
15 |
+
|
16 |
+
$form->setUseContainer(true);
|
17 |
+
$this->setForm($form);
|
18 |
+
return parent::_prepareForm();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,75 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
6 |
+
protected function _prepareForm() {
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$countries = Mage::getSingleton('directory/country')->getCollection()
|
10 |
+
->loadData()->toOptionArray(false);
|
11 |
+
$id = $this->getRequest()->getParam('region_id');
|
12 |
+
|
13 |
+
$fieldSet = $form->addFieldset('region_form', array('legend' => Mage::helper('improvedaddress')->__('State information')));
|
14 |
+
|
15 |
+
$fieldSet->addField('country_id', 'select',
|
16 |
+
array(
|
17 |
+
'label' => Mage::helper('improvedaddress')->__('Country'),
|
18 |
+
'name' => 'country_id',
|
19 |
+
'required' => true,
|
20 |
+
'values' => $countries
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
$fieldSet->addField('code', 'text',
|
25 |
+
array(
|
26 |
+
'label' => Mage::helper('improvedaddress')->__('Code'),
|
27 |
+
'class' => 'required-entry',
|
28 |
+
'required' => true,
|
29 |
+
'name' => 'code',
|
30 |
+
)
|
31 |
+
);
|
32 |
+
$fieldSet->addField('default_name', 'text',
|
33 |
+
array(
|
34 |
+
'label' => Mage::helper('improvedaddress')->__('Default Name'),
|
35 |
+
'class' => 'required-entry',
|
36 |
+
'required' => true,
|
37 |
+
'name' => 'default_name',
|
38 |
+
)
|
39 |
+
);
|
40 |
+
|
41 |
+
$locales = Mage::helper('improvedaddress')->getLocales();
|
42 |
+
foreach ($locales as $locale) {
|
43 |
+
$fieldSet{$locale} = $form->addFieldset('improvedaddress_form_' . $locale, array('legend' => Mage::helper('improvedaddress')->__('Locale ' . $locale)));
|
44 |
+
$fieldSet{$locale}->addField(
|
45 |
+
'name_'.$locale, 'text',
|
46 |
+
array(
|
47 |
+
'label' => Mage::helper('improvedaddress')->__('Name'),
|
48 |
+
'name' => 'name_'.$locale,
|
49 |
+
)
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
if (Mage::getSingleton('adminhtml/session')->getRegionData()) {
|
54 |
+
$data = Mage::getSingleton('adminhtml/session')->getRegionData();
|
55 |
+
$form->setValues($data);
|
56 |
+
Mage::getSingleton('adminhtml/session')->setRegionData(null);
|
57 |
+
} elseif (Mage::registry('region_data')) {
|
58 |
+
$data = Mage::registry('region_data')->getData();
|
59 |
+
$form->setValues($data);
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($id) {
|
63 |
+
$resource = Mage::getSingleton('core/resource');
|
64 |
+
$read = $resource->getConnection('core_read');
|
65 |
+
$regionName = $resource->getTableName('directory/country_region_name');
|
66 |
+
$select = $read->select()->from(array('region'=>$regionName))->where('region.region_id=?', $id);
|
67 |
+
$data =$read->fetchAll($select);
|
68 |
+
foreach($data as $row) {
|
69 |
+
$form->addValues(array('name_'.$row['locale']=> $row['name']));
|
70 |
+
}
|
71 |
+
}
|
72 |
+
return parent::_prepareForm();
|
73 |
+
|
74 |
+
}
|
75 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Edit/Tabs.php
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('improvedaddress_tabs');
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('improvedaddress')->__('Item Information'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml() {
|
14 |
+
$this->addTab('form_section', array(
|
15 |
+
'label' => Mage::helper('improvedaddress')->__('Region Information'),
|
16 |
+
'title' => Mage::helper('improvedaddress')->__('Region Information'),
|
17 |
+
'content' => $this->getLayout()->createBlock('improvedaddress/adminhtml_region_edit_tab_form')->toHtml(),
|
18 |
+
));
|
19 |
+
|
20 |
+
return parent::_beforeToHtml();
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Grid.php
ADDED
@@ -0,0 +1,117 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
6 |
+
public function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('regionGrid');
|
9 |
+
$this->setDefaultSort('region_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection() {
|
15 |
+
$collection = Mage::getModel('improvedaddress/region')->getCollection();
|
16 |
+
$this->setCollection($collection);
|
17 |
+
|
18 |
+
$this->setLocales(Mage::helper('improvedaddress')->getLocales());
|
19 |
+
|
20 |
+
return parent::_prepareCollection();
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareColumns() {
|
24 |
+
$this->addColumn('region_id', array(
|
25 |
+
'header' => Mage::helper('improvedaddress')->__('ID'),
|
26 |
+
'align' =>'right',
|
27 |
+
'width' => '50px',
|
28 |
+
'index' => 'region_id',
|
29 |
+
));
|
30 |
+
|
31 |
+
$this->addColumn(
|
32 |
+
'country_id', array(
|
33 |
+
'header' => Mage::helper('improvedaddress')->__('Country Code'),
|
34 |
+
'align' => 'left',
|
35 |
+
'width' => '110px',
|
36 |
+
'index' => 'country_id',
|
37 |
+
'type' => 'country',
|
38 |
+
)
|
39 |
+
);
|
40 |
+
|
41 |
+
$this->addColumn(
|
42 |
+
'code', array(
|
43 |
+
'header' => Mage::helper('improvedaddress')->__('Region Code'),
|
44 |
+
'align' => 'left',
|
45 |
+
'width' => '110px',
|
46 |
+
'index' => 'code',
|
47 |
+
//'editable' =>true,
|
48 |
+
'column_css_class' => 'code_td'
|
49 |
+
)
|
50 |
+
);
|
51 |
+
|
52 |
+
$this->addColumn(
|
53 |
+
'default_name', array(
|
54 |
+
'header' => Mage::helper('improvedaddress')->__('Default Name'),
|
55 |
+
'align' => 'left',
|
56 |
+
'width' => '110px',
|
57 |
+
'index' => 'default_name',
|
58 |
+
//'editable' =>true,
|
59 |
+
'column_css_class' => 'default_name'
|
60 |
+
)
|
61 |
+
);
|
62 |
+
$this->addColumn(
|
63 |
+
'name_locale', array(
|
64 |
+
'header' => Mage::helper('improvedaddress')->__('Name in Locale'),
|
65 |
+
'align' => 'left',
|
66 |
+
'width' => '110px',
|
67 |
+
'index' => 'region_id',
|
68 |
+
'sortable' => false,
|
69 |
+
'filter' => false,
|
70 |
+
'renderer' => 'Magebuzz_Improvedaddress_Block_Adminhtml_Region_Renderer_Name',
|
71 |
+
//'editable' =>true,
|
72 |
+
'column_css_class' => 'name_locale'
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
|
77 |
+
$this->addColumn('action',
|
78 |
+
array(
|
79 |
+
'header' => Mage::helper('improvedaddress')->__('Action'),
|
80 |
+
'width' => '100',
|
81 |
+
'type' => 'action',
|
82 |
+
'getter' => 'getId',
|
83 |
+
'actions' => array(
|
84 |
+
array(
|
85 |
+
'caption' => Mage::helper('improvedaddress')->__('Edit'),
|
86 |
+
'url' => array('base'=> '*/*/edit'),
|
87 |
+
'field' => 'region_id'
|
88 |
+
)
|
89 |
+
),
|
90 |
+
'filter' => false,
|
91 |
+
'sortable' => false,
|
92 |
+
'index' => 'stores',
|
93 |
+
'is_system' => true,
|
94 |
+
));
|
95 |
+
|
96 |
+
return parent::_prepareColumns();
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function _prepareMassaction() {
|
100 |
+
$this->setMassactionIdField('region_id');
|
101 |
+
$this->getMassactionBlock()->setFormFieldName('region');
|
102 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
103 |
+
$this->getMassactionBlock()->addItem(
|
104 |
+
'delete',
|
105 |
+
array(
|
106 |
+
'label' => Mage::helper('improvedaddress')->__('Delete'),
|
107 |
+
'url' => $this->getUrl('*/*/massDelete', array('_current' => true)),
|
108 |
+
)
|
109 |
+
);
|
110 |
+
|
111 |
+
return $this;
|
112 |
+
}
|
113 |
+
|
114 |
+
public function getRowUrl($row) {
|
115 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getRegionId()));
|
116 |
+
}
|
117 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Region/Renderer/Name.php
ADDED
@@ -0,0 +1,32 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Region_Renderer_Name extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action {
|
3 |
+
public function render(Varien_Object $row) {
|
4 |
+
$html = '';
|
5 |
+
$locales = Mage::helper('improvedaddress')->getLocales();
|
6 |
+
|
7 |
+
$resource = Mage::getSingleton('core/resource');
|
8 |
+
$read = $resource->getConnection('core_read');
|
9 |
+
$regionName = $resource->getTableName('directory/country_region_name');
|
10 |
+
|
11 |
+
$select = $read->select()->from(array('region' => $regionName))->where('region.region_id=?', $row->getRegionId());
|
12 |
+
$data = $read->fetchAll($select);
|
13 |
+
foreach ($data as $row) {
|
14 |
+
$arr[$row['locale']] = $row['name'];
|
15 |
+
}
|
16 |
+
foreach ($locales as $locale) {
|
17 |
+
$name = $arr[$locale];
|
18 |
+
if (!$name) {
|
19 |
+
$name = 'EMPTY';
|
20 |
+
}
|
21 |
+
$html[] = '<span>' . $locale . '</span> => <span class="' . $locale . '_name">' . $name . '</span>';
|
22 |
+
}
|
23 |
+
$html = implode('<br />', $html);
|
24 |
+
|
25 |
+
if ($html == '') {
|
26 |
+
$html = ' ';
|
27 |
+
}
|
28 |
+
|
29 |
+
return $html;
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Sales/Order/Create/Billing/Address.php
ADDED
@@ -0,0 +1,21 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Sales_Order_Create_Billing_Address extends Mage_Adminhtml_Block_Sales_Order_Create_Billing_Address {
|
3 |
+
protected function _prepareForm() {
|
4 |
+
parent::_prepareForm();
|
5 |
+
|
6 |
+
$cityElement = $this->_form->getElement('city');
|
7 |
+
$cityElement->setRequired(true);
|
8 |
+
|
9 |
+
if ($cityElement) {
|
10 |
+
$cityElement->addClass('select');
|
11 |
+
$cityElement->setRenderer($this->getLayout()->createBlock('improvedaddress/adminhtml_customer_edit_renderer_city'));
|
12 |
+
}
|
13 |
+
|
14 |
+
$cityElement = $this->_form->getElement('city_id');
|
15 |
+
if ($cityElement) {
|
16 |
+
$cityElement->setNoDisplay(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Adminhtml/Sales/Order/Create/Shipping/Address.php
ADDED
@@ -0,0 +1,21 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Block_Adminhtml_Sales_Order_Create_Shipping_Address extends Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Address {
|
3 |
+
protected function _prepareForm() {
|
4 |
+
parent::_prepareForm();
|
5 |
+
|
6 |
+
$cityElement = $this->_form->getElement('city');
|
7 |
+
$cityElement->setRequired(true);
|
8 |
+
|
9 |
+
if ($cityElement) {
|
10 |
+
$cityElement->addClass('select');
|
11 |
+
$cityElement->setRenderer($this->getLayout()->createBlock('improvedaddress/adminhtml_customer_edit_renderer_city'));
|
12 |
+
}
|
13 |
+
|
14 |
+
$cityElement = $this->_form->getElement('city_id');
|
15 |
+
if ($cityElement) {
|
16 |
+
$cityElement->setNoDisplay(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Block/Improvedaddress.php
ADDED
@@ -0,0 +1,16 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Block_Improvedaddress extends Mage_Core_Block_Template {
|
6 |
+
public function _prepareLayout() {
|
7 |
+
return parent::_prepareLayout();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getImprovedaddress() {
|
11 |
+
if (!$this->hasData('improvedaddress')) {
|
12 |
+
$this->setData('improvedaddress', Mage::registry('improvedaddress'));
|
13 |
+
}
|
14 |
+
return $this->getData('improvedaddress');
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Helper/Data.php
ADDED
@@ -0,0 +1,58 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Helper_Data extends Mage_Core_Helper_Abstract {
|
6 |
+
protected $_cityJson;
|
7 |
+
protected $_subdistrictJson;
|
8 |
+
|
9 |
+
public function getLocales() {
|
10 |
+
$stores = Mage::app()->getStores();
|
11 |
+
$locales = array();
|
12 |
+
foreach ($stores as $store) {
|
13 |
+
$v = Mage::getStoreConfig('general/locale/code', $store->getId());
|
14 |
+
$locales[$v] = $v;
|
15 |
+
}
|
16 |
+
return $locales;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getCityJson() {
|
20 |
+
Varien_Profiler::start('TEST: '.__METHOD__);
|
21 |
+
$storeId = Mage::app()->getStore()->getId();
|
22 |
+
if (!$this->_cityJson) {
|
23 |
+
$cacheKey = 'IMPROVEDADDRESS_CITY_JSON_STORE' . (string)$storeId;
|
24 |
+
if (Mage::app()->useCache('config')) {
|
25 |
+
$json = Mage::app()->loadCache($cacheKey);
|
26 |
+
}
|
27 |
+
if (empty($json)) {
|
28 |
+
$cities = $this->_getCities($storeId);
|
29 |
+
$helper = Mage::helper('core');
|
30 |
+
$json = $helper->jsonEncode($cities);
|
31 |
+
|
32 |
+
if (Mage::app()->useCache('config')) {
|
33 |
+
Mage::app()->saveCache($json, $cacheKey, array('config'));
|
34 |
+
}
|
35 |
+
}
|
36 |
+
$this->_cityJson = $json;
|
37 |
+
}
|
38 |
+
|
39 |
+
Varien_Profiler::stop('TEST: ' . __METHOD__);
|
40 |
+
return $this->_cityJson;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function _getCities($storeId) {
|
44 |
+
$cities = array();
|
45 |
+
|
46 |
+
$collection = Mage::getSingleton('improvedaddress/city')->getCollection();
|
47 |
+
//->addFieldToFilter('region_id', $regionId);
|
48 |
+
|
49 |
+
foreach ($collection as $item) {
|
50 |
+
$itemData = $item->getData();
|
51 |
+
$cities[$itemData['region_id']][$itemData['city_id']] = array(
|
52 |
+
'code' => $itemData['city_id'],
|
53 |
+
'name' => $itemData['default_name']
|
54 |
+
);
|
55 |
+
}
|
56 |
+
return $cities;
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/City.php
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_City extends Mage_Core_Model_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('improvedaddress/city');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function toOptionArray() {
|
12 |
+
$options = $this->_toOptionArray('region_id', 'default_name', array('title' => 'default_name'));
|
13 |
+
if (count($options) > 0) {
|
14 |
+
array_unshift($options, array(
|
15 |
+
'title '=> null,
|
16 |
+
'value' => "",
|
17 |
+
'label' => Mage::helper('directory')->__('-- Please select --')
|
18 |
+
));
|
19 |
+
}
|
20 |
+
return $options;
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Customer/Renderer/City.php
ADDED
@@ -0,0 +1,88 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Model_Customer_Renderer_City implements Varien_Data_Form_Element_Renderer_Interface
|
3 |
+
{
|
4 |
+
static protected $_cityCollections;
|
5 |
+
|
6 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
7 |
+
{
|
8 |
+
$html = '<tr>'."\n";
|
9 |
+
|
10 |
+
$regionId = false;
|
11 |
+
if ($region = $element->getForm()->getElement('region_id')) {
|
12 |
+
$regionId = $region->getValue();
|
13 |
+
}
|
14 |
+
$cityCollection = false;
|
15 |
+
if ($regionId) {
|
16 |
+
if (!isset(self::$_cityCollections[$regionId])) {
|
17 |
+
self::$_cityCollections[$regionId] = Mage::getModel('improvedaddress/city')
|
18 |
+
->getCollection()
|
19 |
+
->addFieldToFilter('region_id', $regionId)
|
20 |
+
->load()
|
21 |
+
->toOptionArray();
|
22 |
+
}
|
23 |
+
$cityCollection = self::$_cityCollections[$regionId];
|
24 |
+
}
|
25 |
+
|
26 |
+
$cityId = intval($element->getForm()->getElement('city_id')->getValue());
|
27 |
+
|
28 |
+
if(empty($cityId) || $cityId < 1){
|
29 |
+
$cityId = "";
|
30 |
+
}
|
31 |
+
|
32 |
+
$htmlAttributes = $element->getHtmlAttributes();
|
33 |
+
foreach ($htmlAttributes as $key => $attribute) {
|
34 |
+
if ('type' === $attribute) {
|
35 |
+
unset($htmlAttributes[$key]);
|
36 |
+
break;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
$cityHtmlName = $element->getName();
|
41 |
+
$cityIdHtmlName = str_replace('city', 'city_id', $cityHtmlName);
|
42 |
+
$cityHtmlId = $element->getHtmlId();
|
43 |
+
$cityIdHtmlId = str_replace('city', 'city_id', $cityHtmlId);
|
44 |
+
|
45 |
+
if ($cityCollection && count($cityCollection) > 0) {
|
46 |
+
$elementClass = $element->getClass();
|
47 |
+
$html.= '<td class="label">'.$element->getLabelHtml().'</td>';
|
48 |
+
$html.= '<td class="value">';
|
49 |
+
|
50 |
+
$html .= '<select id="' . $cityIdHtmlId . '" name="' . $cityIdHtmlName . '" '
|
51 |
+
. 'class="cities" >' . "\n";
|
52 |
+
//. $element->serialize($htmlAttributes) .'>' . "\n";
|
53 |
+
|
54 |
+
$selectedtext = '';
|
55 |
+
foreach ($cityCollection as $city) {
|
56 |
+
//$selected = ($cityId==$city['value']) ? ' selected="selected"' : '';
|
57 |
+
$selected = '';
|
58 |
+
$value = $city['value'];
|
59 |
+
$value = empty($value) ? '' : ' value="'.$city['value'].'" ';
|
60 |
+
if($cityId == $city['value']) {
|
61 |
+
$selected = ' selected="selected" ';
|
62 |
+
$selectedtext = $city['label'];
|
63 |
+
}
|
64 |
+
$html.= '<option '.$value.$selected.'>'.$city['label'].'</option>';
|
65 |
+
}
|
66 |
+
$html.= '</select>' . "\n";
|
67 |
+
|
68 |
+
$html .= '<input type="hidden" name="' . $cityHtmlName . '" id="' . $cityHtmlId . '" value="'.$selectedtext .'"/>';
|
69 |
+
|
70 |
+
$html.= '</td>';
|
71 |
+
$element->setClass($elementClass);
|
72 |
+
} else {
|
73 |
+
$element->setClass('input-text');
|
74 |
+
$html.= '<td class="label"><label for="'.$element->getHtmlId().'">'
|
75 |
+
. $element->getLabel()
|
76 |
+
. ' <span class="required" style="display:none">*</span></label></td>';
|
77 |
+
|
78 |
+
$element->setRequired(false);
|
79 |
+
$html.= '<td class="value">';
|
80 |
+
$html .= '<input id="' . $cityHtmlId . '" name="' . $cityHtmlName
|
81 |
+
. '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n";
|
82 |
+
$html .= '<input type="hidden" name="' . $cityIdHtmlName . '" id="' . $cityIdHtmlId . '" value=""/>';
|
83 |
+
$html .= '</td>'."\n";
|
84 |
+
}
|
85 |
+
$html.= '</tr>'."\n";
|
86 |
+
return $html;
|
87 |
+
}
|
88 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Improvedaddress.php
ADDED
@@ -0,0 +1,10 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Improvedaddress extends Mage_Core_Model_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('improvedaddress/improvedaddress');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/City.php
ADDED
@@ -0,0 +1,9 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_City extends Mage_Core_Model_Mysql4_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
$this->_init('improvedaddress/city', 'city_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/City/Collection.php
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_City_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('improvedaddress/city');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function toOptionArray() {
|
12 |
+
$options = $this->_toOptionArray('city_id', 'default_name', array('title' => 'default_name'));
|
13 |
+
if (count($options) > 0) {
|
14 |
+
array_unshift($options, array(
|
15 |
+
'title '=> null,
|
16 |
+
'value' => "",
|
17 |
+
'label' => Mage::helper('improvedaddress')->__('-- Please select --')
|
18 |
+
));
|
19 |
+
}
|
20 |
+
return $options;
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Improvedaddress.php
ADDED
@@ -0,0 +1,10 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_Improvedaddress extends Mage_Core_Model_Mysql4_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
// Note that the improvedaddress_id refers to the key field in your database table.
|
8 |
+
$this->_init('improvedaddress/improvedaddress', 'improvedaddress_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Improvedaddress/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_Improvedaddress_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('improvedaddress/improvedaddress');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Region.php
ADDED
@@ -0,0 +1,7 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_Region extends Magebuzz_Improvedaddress_Model_Resource_Region {
|
6 |
+
|
7 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Region/Collection.php
ADDED
@@ -0,0 +1,7 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Mysql4_Region_Collection extends Magebuzz_Improvedaddress_Model_Resource_Region_Collection {
|
6 |
+
|
7 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Subdistrict.php
ADDED
@@ -0,0 +1,9 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Customaddress_Model_Mysql4_Subdistrict extends Mage_Core_Model_Mysql4_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
$this->_init('customaddress/subdistrict', 'subdistrict_id');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Mysql4/Subdistrict/Collection.php
ADDED
@@ -0,0 +1,22 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Customaddress_Model_Mysql4_Subdistrict_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('customaddress/subdistrict');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function toOptionArray() {
|
12 |
+
$options = $this->_toOptionArray('subdistrict_id', 'default_name', array('title' => 'default_name'));
|
13 |
+
if (count($options) > 0) {
|
14 |
+
array_unshift($options, array(
|
15 |
+
'title '=> null,
|
16 |
+
'value' => "",
|
17 |
+
'label' => Mage::helper('customaddress')->__('-- Please select --')
|
18 |
+
));
|
19 |
+
}
|
20 |
+
return $options;
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Observer.php
ADDED
@@ -0,0 +1,28 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Model_Observer {
|
3 |
+
public function addressSaveBefore(Varien_Event_Observer $observer) {
|
4 |
+
$address = $observer->getEvent()->getCustomerAddress();
|
5 |
+
$cityId = Mage::app()->getRequest()->getParam('city_id');
|
6 |
+
$city = Mage::app()->getRequest()->getParam('city');
|
7 |
+
if ($cityId && $cityId != 0){
|
8 |
+
$city = Mage::getModel('improvedaddress/city')->load($cityId)->getDefaultName();
|
9 |
+
}
|
10 |
+
$address->setData('city', $city);
|
11 |
+
}
|
12 |
+
|
13 |
+
public function addAdditionalDataToAddress(Varien_Event_Observer $observer) {
|
14 |
+
$address = $observer->getAddress();
|
15 |
+
$regionId = $address->getRegionId();
|
16 |
+
|
17 |
+
if ($regionId = $address->getRegionId()) {
|
18 |
+
if ($cityId = $address->getCityId()) {
|
19 |
+
$json = Mage::helper('improvedaddress')->getCityJson();
|
20 |
+
$data = json_decode($json, true);
|
21 |
+
if(isset($data[$regionId][$cityId])) {
|
22 |
+
$address->setCity($data[$regionId][$cityId]['name']);
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Region.php
ADDED
@@ -0,0 +1,9 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Region extends Mage_Core_Model_Abstract {
|
6 |
+
public function _construct() {
|
7 |
+
$this->_init('improvedaddress/region');
|
8 |
+
}
|
9 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Resource/Region.php
ADDED
@@ -0,0 +1,6 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Model_Resource_Region extends Mage_Core_Model_Resource_Db_Abstract {
|
3 |
+
protected function _construct() {
|
4 |
+
$this->_init('improvedaddress/region', 'region_id');
|
5 |
+
}
|
6 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Resource/Region/Collection.php
ADDED
@@ -0,0 +1,5 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Model_Resource_Region_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Model_Status extends Varien_Object {
|
6 |
+
const STATUS_ENABLED = 1;
|
7 |
+
const STATUS_DISABLED = 2;
|
8 |
+
|
9 |
+
static public function getOptionArray() {
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('improvedaddress')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('improvedaddress')->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|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Adminhtml_Improvedaddress_CityController extends Mage_Adminhtml_Controller_Action {
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('improvedaddress/city')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('improvedaddress/city')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('city_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('improvedaddress/city');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('improvedaddress/adminhtml_city_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('improvedaddress/adminhtml_city_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('improvedaddress')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
$request = $this->getRequest();
|
55 |
+
if ($this->getRequest()->getPost()) {
|
56 |
+
$id = $request->getParam('id');
|
57 |
+
$code = $request->getParam('code');
|
58 |
+
$name = $request->getParam('default_name');
|
59 |
+
$regionId = $request->getParam('region_id');
|
60 |
+
if (!$name || !$code) {
|
61 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please fill the required fields'));
|
62 |
+
$this->_redirect('*/*/');
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
$cities = Mage::getModel('improvedaddress/city')->getCollection()
|
66 |
+
->addFieldToFilter('code', $code)
|
67 |
+
->addFieldToFilter('region_id', $regionId)
|
68 |
+
->getAllIds();
|
69 |
+
if (count($cities) > 0 && !in_array($id, $cities)) {
|
70 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('City/Region combination must be unique'));
|
71 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
try {
|
76 |
+
$city = Mage::getModel('improvedaddress/city');
|
77 |
+
$city->setCityId($id)
|
78 |
+
->setCode($code)
|
79 |
+
->setRegionId($regionId)
|
80 |
+
->setDefaultName($name)
|
81 |
+
->save();
|
82 |
+
|
83 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('City was successfully saved'));
|
84 |
+
Mage::getSingleton('adminhtml/session')->setCityData(false);
|
85 |
+
$this->_redirect('*/*/');
|
86 |
+
return;
|
87 |
+
} catch (Exception $e) {
|
88 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
89 |
+
Mage::getSingleton('adminhtml/session')->setStateData($this->getRequest()->getPost());
|
90 |
+
$this->_redirect('*/*/edit', array('region_id' => $this->getRequest()->getParam('id')));
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
$this->_redirect('*/*/');
|
95 |
+
}
|
96 |
+
|
97 |
+
public function deleteAction() {
|
98 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
99 |
+
try {
|
100 |
+
$model = Mage::getModel('improvedaddress/city');
|
101 |
+
|
102 |
+
$model->setId($this->getRequest()->getParam('id'))
|
103 |
+
->delete();
|
104 |
+
|
105 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
106 |
+
$this->_redirect('*/*/');
|
107 |
+
} catch (Exception $e) {
|
108 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
}
|
111 |
+
}
|
112 |
+
$this->_redirect('*/*/');
|
113 |
+
}
|
114 |
+
|
115 |
+
public function massDeleteAction() {
|
116 |
+
$cityIds = $this->getRequest()->getParam('city');
|
117 |
+
if(!is_array($cityIds)) {
|
118 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
119 |
+
} else {
|
120 |
+
try {
|
121 |
+
foreach ($cityIds as $cityId) {
|
122 |
+
$city = Mage::getModel('improvedaddress/city')->load($cityId);
|
123 |
+
$city->delete();
|
124 |
+
}
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
126 |
+
Mage::helper('adminhtml')->__(
|
127 |
+
'Total of %d record(s) were successfully deleted', count($cityIds)
|
128 |
+
)
|
129 |
+
);
|
130 |
+
} catch (Exception $e) {
|
131 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
132 |
+
}
|
133 |
+
}
|
134 |
+
$this->_redirect('*/*/index');
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function _isAllowed() {
|
138 |
+
return Mage::getSingleton('admin/session')->isAllowed('improvedaddress/city');
|
139 |
+
}
|
140 |
+
|
141 |
+
public function reloadRegionAction() {
|
142 |
+
$countryId = $this->getRequest()->getParam('country_id', false);
|
143 |
+
$options = '';
|
144 |
+
$result = array('success' => false);
|
145 |
+
if ($countryId) {
|
146 |
+
$collection = Mage::getModel('improvedaddress/region')->getCollection()
|
147 |
+
->addFieldToFilter('country_id', $countryId);
|
148 |
+
if (count($collection)) {
|
149 |
+
$options .= '<option value="">'.Mage::helper('adminhtml')->__("Please Select").'</option>';
|
150 |
+
foreach ($collection as $region) {
|
151 |
+
$code = $region->getRegionId();
|
152 |
+
$regionName = $region->getDefaultName();
|
153 |
+
$options .= "<option value='$code'>$regionName</option>";
|
154 |
+
}
|
155 |
+
$result['success'] = true;
|
156 |
+
$result['options'] = $options;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
161 |
+
}
|
162 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/DataController.php
ADDED
@@ -0,0 +1,33 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Customaddress_Adminhtml_Customaddress_DataController extends Mage_Adminhtml_Controller_Action {
|
3 |
+
public function importAction() {
|
4 |
+
// $filePath = getcwd() . 'app'.DS.'code'.DS.'local'.DS.'Magebuzz'.DS.'Customaddress'.DS.'sql'.DS.'test.sql';
|
5 |
+
|
6 |
+
// //$dumpFile = $sample_data_path . "magento_sample_data_for_1.6.1.0.sql";
|
7 |
+
// try {
|
8 |
+
// $file = file_get_contents($filePath, true);
|
9 |
+
// echo $file;die();
|
10 |
+
// $adapter = $this->_writeConnection();
|
11 |
+
// $adapter->query($file);
|
12 |
+
// }
|
13 |
+
// catch (Exception $e) {
|
14 |
+
// echo $e->getMessage();
|
15 |
+
// die('xxxeee');
|
16 |
+
// }
|
17 |
+
|
18 |
+
// echo $file;die('xxxx');
|
19 |
+
Mage::getSingleton('core/session')->addError('Importing function is not working in this version. Please import thai_address.sql directly using phpmyadmin.');
|
20 |
+
//Mage::getSingleton('core/session')->addSuccess('Successfully import Thai address data.');
|
21 |
+
$this->_redirect('adminhtml/system_config/index', array('section' => 'customaddress'));
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _isAllowed() {
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _writeConnection() {
|
30 |
+
$resource = Mage::getSingleton('core/resource');
|
31 |
+
return $resource->getConnection('core_write');
|
32 |
+
}
|
33 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/JsonController.php
ADDED
@@ -0,0 +1,44 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class Magebuzz_Improvedaddress_Adminhtml_Improvedaddress_JsonController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function cityAction() {
|
5 |
+
|
6 |
+
$arrCity = array();
|
7 |
+
$regionId = $this->getRequest()->getParam('parent');
|
8 |
+
$arrCities = Mage::getModel('improvedaddress/city')
|
9 |
+
->getCollection()
|
10 |
+
->addFieldToFilter('region_id', $regionId)
|
11 |
+
->load()
|
12 |
+
->toOptionArray();
|
13 |
+
if (!empty($arrCities)) {
|
14 |
+
foreach ($arrCities as $city) {
|
15 |
+
$arrCity[] = $city;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($arrCity));
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
// use in order edit address
|
23 |
+
public function cityOrderAction(){
|
24 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
25 |
+
$arrCity = array();
|
26 |
+
$regionId = $this->getRequest()->getParam('parent');
|
27 |
+
$arrCities = Mage::getModel('improvedaddress/city')
|
28 |
+
->getCollection()
|
29 |
+
->addRegionFilter($regionId)
|
30 |
+
->load()
|
31 |
+
->toOptionArray();
|
32 |
+
if (!empty($arrCities)) {
|
33 |
+
foreach ($arrCities as $city) {
|
34 |
+
$arrCity[] = $city;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($arrCity));
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _isAllowed() {
|
42 |
+
return true;
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/controllers/Adminhtml/Improvedaddress/RegionController.php
ADDED
@@ -0,0 +1,155 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_Adminhtml_Improvedaddress_RegionController extends Mage_Adminhtml_Controller_Action {
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('improvedaddress/region')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('improvedaddress/region')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('region_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('improvedaddress/region');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('improvedaddress/adminhtml_region_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('improvedaddress/adminhtml_region_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('improvedaddress')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
$request = $this->getRequest();
|
55 |
+
if ($this->getRequest()->getPost()) {
|
56 |
+
$id = $request->getParam('id');
|
57 |
+
$code = $request->getParam('code');
|
58 |
+
$name = $request->getParam('default_name');
|
59 |
+
$countryId = $request->getParam('country_id');
|
60 |
+
if (!$name || !$code) {
|
61 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please fill the required fields'));
|
62 |
+
$this->_redirect('*/*/');
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
$state = Mage::getModel('improvedaddress/region')->getCollection()
|
66 |
+
->addFieldToFilter('code', $code)
|
67 |
+
->addFieldToFilter('country_id', $countryId)
|
68 |
+
->getAllIds();
|
69 |
+
if (count($state) > 0 && !in_array($id, $state)) {
|
70 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('State/Country combination must be unique'));
|
71 |
+
$this->_redirect('*/*/edit', array('id' => $id));
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
try {
|
76 |
+
$state = Mage::getModel('improvedaddress/region');
|
77 |
+
$state->setRegionId($id)
|
78 |
+
->setCode($code)
|
79 |
+
->setCountryId($countryId)
|
80 |
+
->setDefaultName($name)
|
81 |
+
->save();
|
82 |
+
if ($state->getRegionId()) {
|
83 |
+
$locales = Mage::helper('improvedaddress')->getLocales();
|
84 |
+
$resource = Mage::getSingleton('core/resource');
|
85 |
+
$write = $resource->getConnection('core_write');
|
86 |
+
$regionName = $resource->getTableName('directory/country_region_name');
|
87 |
+
$write->delete($regionName, array('region_id =' . $state->getRegionId()));
|
88 |
+
foreach ($locales as $locale) {
|
89 |
+
$localeName = $request->getParam('name_' . $locale);
|
90 |
+
if ($localeName == '' && $locale == 'en_US') {
|
91 |
+
$localeName = $name;
|
92 |
+
}
|
93 |
+
if ($localeName) {
|
94 |
+
$write->insert($regionName, array('region_id' => $state->getRegionId(), 'locale' => $locale, 'name' => trim($localeName)));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
|
99 |
+
Mage::getSingleton('adminhtml/session')->setRegionData(false);
|
100 |
+
$this->_redirect('*/*/');
|
101 |
+
return;
|
102 |
+
} catch (Exception $e) {
|
103 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
104 |
+
Mage::getSingleton('adminhtml/session')->setRegionData($this->getRequest()->getPost());
|
105 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
$this->_redirect('*/*/');
|
110 |
+
}
|
111 |
+
|
112 |
+
public function deleteAction() {
|
113 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
114 |
+
try {
|
115 |
+
$model = Mage::getModel('improvedaddress/region');
|
116 |
+
|
117 |
+
$model->setId($this->getRequest()->getParam('id'))
|
118 |
+
->delete();
|
119 |
+
|
120 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
121 |
+
$this->_redirect('*/*/');
|
122 |
+
} catch (Exception $e) {
|
123 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
124 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
125 |
+
}
|
126 |
+
}
|
127 |
+
$this->_redirect('*/*/');
|
128 |
+
}
|
129 |
+
|
130 |
+
public function massDeleteAction() {
|
131 |
+
$regionIds = $this->getRequest()->getParam('region');
|
132 |
+
if(!is_array($regionIds)) {
|
133 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
134 |
+
} else {
|
135 |
+
try {
|
136 |
+
foreach ($regionIds as $regionId) {
|
137 |
+
$region = Mage::getModel('improvedaddress/region')->load($regionId);
|
138 |
+
$region->delete();
|
139 |
+
}
|
140 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
141 |
+
Mage::helper('adminhtml')->__(
|
142 |
+
'Total of %d record(s) were successfully deleted', count($regionIds)
|
143 |
+
)
|
144 |
+
);
|
145 |
+
} catch (Exception $e) {
|
146 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
147 |
+
}
|
148 |
+
}
|
149 |
+
$this->_redirect('*/*/index');
|
150 |
+
}
|
151 |
+
|
152 |
+
protected function _isAllowed() {
|
153 |
+
return Mage::getSingleton('admin/session')->isAllowed('improvedaddress/region');
|
154 |
+
}
|
155 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/controllers/IndexController.php
ADDED
@@ -0,0 +1,10 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2015 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
class Magebuzz_Improvedaddress_IndexController extends Mage_Core_Controller_Front_Action {
|
6 |
+
public function indexAction() {
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Magebuzz/Improvedaddress/etc/adminhtml.xml
ADDED
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<improvedaddress module="improvedaddress">
|
5 |
+
<title>Custom Address</title>
|
6 |
+
<sort_order>60</sort_order>
|
7 |
+
<children>
|
8 |
+
<region module="improvedaddress">
|
9 |
+
<title>Manage Regions</title>
|
10 |
+
<sort_order>10</sort_order>
|
11 |
+
<action>adminhtml/improvedaddress_region</action>
|
12 |
+
</region>
|
13 |
+
<city module="improvedaddress">
|
14 |
+
<title>Manage City</title>
|
15 |
+
<sort_order>20</sort_order>
|
16 |
+
<action>adminhtml/improvedaddress_city</action>
|
17 |
+
</city>
|
18 |
+
</children>
|
19 |
+
</improvedaddress>
|
20 |
+
</menu>
|
21 |
+
<acl>
|
22 |
+
<resources>
|
23 |
+
<all>
|
24 |
+
<title>Allow Everything</title>
|
25 |
+
</all>
|
26 |
+
<admin>
|
27 |
+
<children>
|
28 |
+
<system>
|
29 |
+
<children>
|
30 |
+
<config>
|
31 |
+
<children>
|
32 |
+
<improvedaddress>
|
33 |
+
<title>Custom Address</title>
|
34 |
+
<sort_order>250</sort_order>
|
35 |
+
</improvedaddress>
|
36 |
+
</children>
|
37 |
+
</config>
|
38 |
+
</children>
|
39 |
+
</system>
|
40 |
+
<improvedaddress module="improvedaddress">
|
41 |
+
<title>Custom Address</title>
|
42 |
+
<sort_order>60</sort_order>
|
43 |
+
<children>
|
44 |
+
<region module="improvedaddress">
|
45 |
+
<title>Manage Regions</title>
|
46 |
+
<sort_order>10</sort_order>
|
47 |
+
<action>adminhtml/improvedaddress_region</action>
|
48 |
+
</region>
|
49 |
+
<city module="improvedaddress">
|
50 |
+
<title>Manage City</title>
|
51 |
+
<sort_order>20</sort_order>
|
52 |
+
<action>adminhtml/improvedaddress_city</action>
|
53 |
+
</city>
|
54 |
+
</children>
|
55 |
+
</improvedaddress>
|
56 |
+
</children>
|
57 |
+
</admin>
|
58 |
+
</resources>
|
59 |
+
</acl>
|
60 |
+
</config>
|
app/code/local/Magebuzz/Improvedaddress/etc/config.xml
ADDED
@@ -0,0 +1,168 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magebuzz_Improvedaddress>
|
5 |
+
<version>0.1.1</version>
|
6 |
+
</Magebuzz_Improvedaddress>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<improvedaddress>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Magebuzz_Improvedaddress</module>
|
14 |
+
<frontName>improvedaddress</frontName>
|
15 |
+
</args>
|
16 |
+
</improvedaddress>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<improvedaddress>
|
21 |
+
<file>improvedaddress.xml</file>
|
22 |
+
</improvedaddress>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
<translate>
|
26 |
+
<modules>
|
27 |
+
<Magebuzz_Improvedaddress>
|
28 |
+
<files>
|
29 |
+
<default>Magebuzz_Improvedaddress.csv</default>
|
30 |
+
</files>
|
31 |
+
</Magebuzz_Improvedaddress>
|
32 |
+
</modules>
|
33 |
+
</translate>
|
34 |
+
<events>
|
35 |
+
<customer_address_save_before>
|
36 |
+
<observers>
|
37 |
+
<improvedaddress_address_save_before>
|
38 |
+
<type>singleton</type>
|
39 |
+
<class>improvedaddress/observer</class>
|
40 |
+
<method>addressSaveBefore</method>
|
41 |
+
</improvedaddress_address_save_before>
|
42 |
+
</observers>
|
43 |
+
</customer_address_save_before>
|
44 |
+
</events>
|
45 |
+
</frontend>
|
46 |
+
<admin>
|
47 |
+
<routers>
|
48 |
+
<adminhtml>
|
49 |
+
<args>
|
50 |
+
<modules><Magebuzz_Improvedaddress after="Mage_Adminhtml">Magebuzz_Improvedaddress_Adminhtml</Magebuzz_Improvedaddress></modules>
|
51 |
+
</args>
|
52 |
+
</adminhtml>
|
53 |
+
</routers>
|
54 |
+
</admin>
|
55 |
+
<adminhtml>
|
56 |
+
<layout>
|
57 |
+
<updates>
|
58 |
+
<improvedaddress>
|
59 |
+
<file>improvedaddress.xml</file>
|
60 |
+
</improvedaddress>
|
61 |
+
</updates>
|
62 |
+
</layout>
|
63 |
+
<translate>
|
64 |
+
<modules>
|
65 |
+
<Magebuzz_Improvedaddress>
|
66 |
+
<files>
|
67 |
+
<default>Magebuzz_Improvedaddress.csv</default>
|
68 |
+
</files>
|
69 |
+
</Magebuzz_Improvedaddress>
|
70 |
+
</modules>
|
71 |
+
</translate>
|
72 |
+
</adminhtml>
|
73 |
+
<global>
|
74 |
+
<models>
|
75 |
+
<improvedaddress>
|
76 |
+
<class>Magebuzz_Improvedaddress_Model</class>
|
77 |
+
<resourceModel>improvedaddress_mysql4</resourceModel>
|
78 |
+
</improvedaddress>
|
79 |
+
<improvedaddress_mysql4>
|
80 |
+
<class>Magebuzz_Improvedaddress_Model_Mysql4</class>
|
81 |
+
<entities>
|
82 |
+
<region>
|
83 |
+
<table>directory_country_region</table>
|
84 |
+
</region>
|
85 |
+
<city>
|
86 |
+
<table>directory_region_city</table>
|
87 |
+
</city>
|
88 |
+
</entities>
|
89 |
+
</improvedaddress_mysql4>
|
90 |
+
</models>
|
91 |
+
<resources>
|
92 |
+
<improvedaddress_setup>
|
93 |
+
<setup>
|
94 |
+
<module>Magebuzz_Improvedaddress</module>
|
95 |
+
</setup>
|
96 |
+
<connection>
|
97 |
+
<use>core_setup</use>
|
98 |
+
</connection>
|
99 |
+
</improvedaddress_setup>
|
100 |
+
<improvedaddress_write>
|
101 |
+
<connection>
|
102 |
+
<use>core_write</use>
|
103 |
+
</connection>
|
104 |
+
</improvedaddress_write>
|
105 |
+
<improvedaddress_read>
|
106 |
+
<connection>
|
107 |
+
<use>core_read</use>
|
108 |
+
</connection>
|
109 |
+
</improvedaddress_read>
|
110 |
+
</resources>
|
111 |
+
<blocks>
|
112 |
+
<improvedaddress>
|
113 |
+
<class>Magebuzz_Improvedaddress_Block</class>
|
114 |
+
</improvedaddress>
|
115 |
+
<adminhtml>
|
116 |
+
<rewrite>
|
117 |
+
<customer_edit_tab_addresses>Magebuzz_Improvedaddress_Block_Adminhtml_Customer_Edit_Tab_Addresses</customer_edit_tab_addresses>
|
118 |
+
<sales_order_create_billing_address>Magebuzz_Improvedaddress_Block_Adminhtml_Sales_Order_Create_Billing_Address</sales_order_create_billing_address>
|
119 |
+
<sales_order_create_shipping_address>Magebuzz_Improvedaddress_Block_Adminhtml_Sales_Order_Create_Shipping_Address</sales_order_create_shipping_address>
|
120 |
+
</rewrite>
|
121 |
+
</adminhtml>
|
122 |
+
</blocks>
|
123 |
+
<helpers>
|
124 |
+
<improvedaddress>
|
125 |
+
<class>Magebuzz_Improvedaddress_Helper</class>
|
126 |
+
</improvedaddress>
|
127 |
+
</helpers>
|
128 |
+
<fieldsets>
|
129 |
+
<customer_address>
|
130 |
+
<city_id>
|
131 |
+
<to_quote_address>*</to_quote_address>
|
132 |
+
</city_id>
|
133 |
+
</customer_address>
|
134 |
+
<sales_convert_quote_address>
|
135 |
+
<city_id>
|
136 |
+
<to_order_address>*</to_order_address>
|
137 |
+
<to_customer_address>*</to_customer_address>
|
138 |
+
</city_id>
|
139 |
+
</sales_convert_quote_address>
|
140 |
+
<sales_convert_order_address>
|
141 |
+
<city_id>
|
142 |
+
<to_quote_address>*</to_quote_address>
|
143 |
+
</city_id>
|
144 |
+
</sales_convert_order_address>
|
145 |
+
<sales_copy_order_billing_address>
|
146 |
+
<city_id>
|
147 |
+
<to_order>*</to_order>
|
148 |
+
</city_id>
|
149 |
+
</sales_copy_order_billing_address>
|
150 |
+
<sales_copy_order_shipping_address>
|
151 |
+
<city_id>
|
152 |
+
<to_order>*</to_order>
|
153 |
+
</city_id>
|
154 |
+
</sales_copy_order_shipping_address>
|
155 |
+
</fieldsets>
|
156 |
+
<events>
|
157 |
+
<customer_address_format>
|
158 |
+
<observers>
|
159 |
+
<improvedaddress_customer_address_format>
|
160 |
+
<type>model</type>
|
161 |
+
<class>improvedaddress/observer</class>
|
162 |
+
<method>addAdditionalDataToAddress</method>
|
163 |
+
</improvedaddress_customer_address_format>
|
164 |
+
</observers>
|
165 |
+
</customer_address_format>
|
166 |
+
</events>
|
167 |
+
</global>
|
168 |
+
</config>
|
app/code/local/Magebuzz/Improvedaddress/sql/improvedaddress_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,45 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2016 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
|
6 |
+
$installer = $this;
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
$installer->run("
|
11 |
+
|
12 |
+
DROP TABLE IF EXISTS {$this->getTable('directory_region_city')};
|
13 |
+
CREATE TABLE {$this->getTable('directory_region_city')} (
|
14 |
+
`city_id` int(11) unsigned NOT NULL auto_increment,
|
15 |
+
`code` varchar(32) NOT NULL,
|
16 |
+
`default_name` varchar(255) NOT NULL,
|
17 |
+
`region_id` int(11) unsigned NULL,
|
18 |
+
PRIMARY KEY (`city_id`),
|
19 |
+
CONSTRAINT `FK_DIRECTORY_REGION_CITY_DIRECTORY_COUNTRY_REGION` FOREIGN KEY (`region_id`) REFERENCES `{$this->getTable('directory_country_region')}` (`region_id`) ON UPDATE CASCADE ON DELETE CASCADE
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
|
22 |
+
ALTER TABLE {$this->getTable('sales_flat_quote_address')} ADD COLUMN `city_id` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
|
23 |
+
ALTER TABLE {$this->getTable('sales_flat_order_address')} ADD COLUMN `city_id` VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL AFTER `fax`;
|
24 |
+
|
25 |
+
");
|
26 |
+
|
27 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
28 |
+
$entityTypeId = $setup->getEntityTypeId('customer_address');
|
29 |
+
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
|
30 |
+
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
|
31 |
+
|
32 |
+
$setup->addAttribute('customer_address', 'city_id', array(
|
33 |
+
'input' => 'hidden',
|
34 |
+
'type' => 'int',
|
35 |
+
'label' => 'City ID',
|
36 |
+
'visible' => 1,
|
37 |
+
'required' => 0,
|
38 |
+
'user_defined' => 0,
|
39 |
+
));
|
40 |
+
|
41 |
+
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'city_id');
|
42 |
+
$oAttribute->setData('used_in_forms', array('customer_register_address','customer_address_edit','adminhtml_customer_address'));
|
43 |
+
$oAttribute->save();
|
44 |
+
|
45 |
+
$installer->endSetup();
|
app/code/local/Magebuzz/Improvedaddress/sql/improvedaddress_setup/mysql4-upgrade-0.1.0-0.1.1.php
ADDED
@@ -0,0 +1,20 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Copyright (c) 2016 www.magebuzz.com
|
4 |
+
*/
|
5 |
+
|
6 |
+
$installer = $this;
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
//Update attribute sort order
|
11 |
+
$attribute_region = Mage::getModel('eav/entity_attribute')->loadByCode('2', 'region');
|
12 |
+
$attribute_city = Mage::getModel('eav/entity_attribute')->loadByCode('2', 'city');
|
13 |
+
$table_name = Mage::getSingleton('core/resource')->getTableName('customer_eav_attribute');
|
14 |
+
|
15 |
+
$installer->run("
|
16 |
+
UPDATE {$table_name} SET `sort_order`= 103 WHERE `attribute_id` = {$attribute_region->getId()};
|
17 |
+
UPDATE {$table_name} SET `sort_order`= 104 WHERE `attribute_id` = {$attribute_city->getId()};
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/improvedaddress.xml
ADDED
@@ -0,0 +1,32 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<adminhtml_improvedaddress_region_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="improvedaddress/adminhtml_region" name="improvedaddress_region" />
|
6 |
+
</reference>
|
7 |
+
</adminhtml_improvedaddress_region_index>
|
8 |
+
|
9 |
+
<adminhtml_improvedaddress_city_index>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="improvedaddress/adminhtml_city" name="improvedaddress_city" />
|
12 |
+
</reference>
|
13 |
+
</adminhtml_improvedaddress_city_index>
|
14 |
+
|
15 |
+
<adminhtml_improvedaddress_city_edit>
|
16 |
+
<reference name="head">
|
17 |
+
<action method="addJs"><file>magebuzz/improvedaddress.js</file></action>
|
18 |
+
</reference>
|
19 |
+
</adminhtml_improvedaddress_city_edit>
|
20 |
+
|
21 |
+
<adminhtml_improvedaddress_subdistrict_index>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="improvedaddress/adminhtml_subdistrict" name="improvedaddress_subdistrict" />
|
24 |
+
</reference>
|
25 |
+
</adminhtml_improvedaddress_subdistrict_index>
|
26 |
+
|
27 |
+
<adminhtml_sales_order_create_index>
|
28 |
+
<reference name="head">
|
29 |
+
<action method="addJs"><file>magebuzz/improvedaddress.js</file></action>
|
30 |
+
</reference>
|
31 |
+
</adminhtml_sales_order_create_index>
|
32 |
+
</layout>
|
app/design/adminhtml/default/default/template/improvedaddress/customer/tab/addresses.phtml
ADDED
@@ -0,0 +1,853 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<!-- Addresses list -->
|
28 |
+
<table cellspacing="0" class="form-edit">
|
29 |
+
<tr>
|
30 |
+
<td class="address-list">
|
31 |
+
<div class="entry-edit-head">
|
32 |
+
<h4
|
33 |
+
class="icon-head head-customer-address-list"><?php echo Mage::helper('customer')->__('Customer Addresses') ?></h4>
|
34 |
+
</div>
|
35 |
+
<div class="sub-btn-set"><?php echo $this->getAddNewButtonHtml() ?></div>
|
36 |
+
<ul id="address_list">
|
37 |
+
<?php $_iterator = 0; ?>
|
38 |
+
<?php if (count($addressCollection)): ?>
|
39 |
+
<?php foreach ($addressCollection as $_address): ?>
|
40 |
+
<li id="address_item_<?php echo $_address->getId() ?>">
|
41 |
+
<?php if (!$this->isReadonly()): ?>
|
42 |
+
<a href="#" class="btn-remove-address">
|
43 |
+
<img src="<?php echo $this->getSkinUrl('images/cancel_icon.gif') ?>" alt="Remove address"
|
44 |
+
id="delete_button<?php echo ++$_iterator ?>"/>
|
45 |
+
</a>
|
46 |
+
<a href="#" id="select_button_<?php echo $_address->getId() ?>" class="select_button btn-edit-address">
|
47 |
+
<img src="<?php echo $this->getSkinUrl('images/edit_icon.gif') ?>" alt="Edit address"/>
|
48 |
+
</a>
|
49 |
+
<?php endif; ?>
|
50 |
+
<address>
|
51 |
+
<?php echo $_address->format('html') ?>
|
52 |
+
</address>
|
53 |
+
<div class="address-type">
|
54 |
+
<span class="address-type-line">
|
55 |
+
<input type="radio" <?php if ($this->isReadonly()): ?> disabled="disabled"<?php endif; ?>
|
56 |
+
value="<?php echo $_address->getId() ?>"
|
57 |
+
id="address_item_billing<?php echo $_address->getId() ?>" name="account[default_billing]"
|
58 |
+
title="<?php echo Mage::helper('customer')->__('Set as Default Billing Address') ?>"<?php if ($_address->getId() == $customer->getDefaultBilling()): ?> checked="checked"<?php endif; ?>/>
|
59 |
+
<label
|
60 |
+
for="address_item_billing<?php echo $_address->getId() ?>"><?php echo Mage::helper('customer')->__('Default Billing Address') ?></label>
|
61 |
+
</span>
|
62 |
+
<span class="address-type-line">
|
63 |
+
<input type="radio" <?php if ($this->isReadonly()): ?> disabled="disabled"<?php endif; ?>
|
64 |
+
value="<?php echo $_address->getId() ?>"
|
65 |
+
id="address_item_shipping<?php echo $_address->getId() ?>" name="account[default_shipping]"
|
66 |
+
title="<?php echo Mage::helper('customer')->__('Set as Default Shipping Address') ?>"<?php if ($_address->getId() == $customer->getDefaultShipping()): ?> checked="checked"<?php endif; ?>/>
|
67 |
+
<label
|
68 |
+
for="address_item_shipping<?php echo $_address->getId() ?>"><?php echo Mage::helper('customer')->__('Default Shipping Address') ?></label>
|
69 |
+
</span>
|
70 |
+
</div>
|
71 |
+
</li>
|
72 |
+
<?php endforeach; ?>
|
73 |
+
<?php endif; ?>
|
74 |
+
</ul>
|
75 |
+
</td>
|
76 |
+
<td>
|
77 |
+
<!-- Template for adding address item to list -->
|
78 |
+
<?php $_templatePrefix = $this->getTemplatePrefix() ?>
|
79 |
+
<div id="address_item_template" class="no-display template">
|
80 |
+
<?php if (!$this->isReadonly()): ?>
|
81 |
+
<a href="#" class="btn-remove-address">
|
82 |
+
<img src="<?php echo $this->getSkinUrl('images/cancel_icon.gif') ?>" alt="Remove address"
|
83 |
+
id="delete_button<?php echo ++$_iterator ?>"/>
|
84 |
+
</a>
|
85 |
+
<a href="#" id="select_button_" class="select_button btn-edit-address">
|
86 |
+
<img src="<?php echo $this->getSkinUrl('images/edit_icon.gif') ?>" alt="Edit address"/>
|
87 |
+
</a>
|
88 |
+
<?php endif; ?>
|
89 |
+
<address><?php echo Mage::helper('customer')->__('New Customer Address') ?></address>
|
90 |
+
<div class="address-type">
|
91 |
+
<span class="address-type-line">
|
92 |
+
<input <?php if ($this->isReadonly()): ?> disabled="disabled"<?php endif; ?> type="radio"
|
93 |
+
value="<?php echo $_templatePrefix ?>"
|
94 |
+
id="address_item_billing<?php echo $_templatePrefix ?>"
|
95 |
+
name="account[default_billing]"
|
96 |
+
title="<?php echo Mage::helper('customer')->__('Set as Default Billing Address') ?>"/>
|
97 |
+
<label
|
98 |
+
for="address_item_billing<?php echo $_templatePrefix ?>"><?php echo Mage::helper('customer')->__('Default Billing Address') ?></label>
|
99 |
+
</span>
|
100 |
+
<span class="address-type-line">
|
101 |
+
<input <?php if ($this->isReadonly()): ?> disabled="disabled"<?php endif; ?> type="radio"
|
102 |
+
value="<?php echo $_templatePrefix ?>"
|
103 |
+
id="address_item_shipping<?php echo $_templatePrefix ?>"
|
104 |
+
name="account[default_shipping]"
|
105 |
+
title="<?php echo Mage::helper('customer')->__('Set as Default Shipping Address') ?>"/>
|
106 |
+
<label
|
107 |
+
for="address_item_shipping<?php echo $_templatePrefix ?>"><?php echo Mage::helper('customer')->__('Default Shipping Address') ?></label>
|
108 |
+
</span>
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
|
112 |
+
<!-- Address form template -->
|
113 |
+
<div id="address_form_template" class="no-display template">
|
114 |
+
<?php
|
115 |
+
// Set form template elements prefix
|
116 |
+
$this->getForm()->setHtmlIdPrefix($_templatePrefix)
|
117 |
+
->setFieldNameSuffix('address[' . $_templatePrefix . ']');
|
118 |
+
?>
|
119 |
+
<?php echo $this->getForm()->getHtml() ?>
|
120 |
+
<?php echo $this->getCancelButtonHtml() ?>
|
121 |
+
</div>
|
122 |
+
<!-- -->
|
123 |
+
|
124 |
+
<!-- Addresses forms -->
|
125 |
+
<div class="entry-edit" id="address_form_container">
|
126 |
+
<?php if (count($addressCollection)): ?>
|
127 |
+
<?php foreach ($addressCollection as $_address): ?>
|
128 |
+
<div id="form_address_item_<?php echo $_address->getId() ?>" style="display:none">
|
129 |
+
<?php
|
130 |
+
$this->getForm()->addValues($_address->getData())
|
131 |
+
->setHtmlIdPrefix("_item{$_address->getId()}")
|
132 |
+
->setFieldNameSuffix('address[' . $_address->getId() . ']');
|
133 |
+
$this->addValuesToNamePrefixElement($_address->getPrefix())
|
134 |
+
->addValuesToNameSuffixElement($_address->getSuffix());
|
135 |
+
?>
|
136 |
+
<?php echo $this->getForm()->getHtml() ?>
|
137 |
+
<input type="hidden" name="address[<?php echo $_address->getId() ?>][_deleted]"
|
138 |
+
id="deleted_address_item_<?php echo $_address->getId() ?>"/>
|
139 |
+
</div>
|
140 |
+
<?php endforeach; ?>
|
141 |
+
<?php else: ?>
|
142 |
+
<div
|
143 |
+
id="no_address_message"><?php echo Mage::helper('customer')->__('This customer has no saved addresses.') ?></div>
|
144 |
+
<?php endif; ?>
|
145 |
+
</div>
|
146 |
+
|
147 |
+
<script type="text/javascript">
|
148 |
+
//<![CDATA[
|
149 |
+
var deleteButtonId = <?php echo $_iterator ?>;
|
150 |
+
|
151 |
+
var addressesModel = Class.create();
|
152 |
+
addressesModel.prototype = {
|
153 |
+
initialize: function () {
|
154 |
+
|
155 |
+
this.activeItem = null;
|
156 |
+
this.itemTemplate = $('address_item_template');
|
157 |
+
this.formTemplate = $('address_form_template');
|
158 |
+
this.itemContainer = $('address_list');
|
159 |
+
this.formContainer = $('address_form_container');
|
160 |
+
this.baseItemId = 'new_item';
|
161 |
+
|
162 |
+
this.defaultCountries = <?php echo $this->getDefaultCountriesJson(); ?>;
|
163 |
+
this.itemContentTemplate = new Template('<?php echo $this->helper('customer/address')->getFormat('js_template')?>');
|
164 |
+
|
165 |
+
this.onNewAddressClick = this.addNewAddress.bindAsEventListener(this);
|
166 |
+
this.onItemMouseOver = this.itemMouseOver.bindAsEventListener(this);
|
167 |
+
this.onItemMouseOut = this.itemMouseOut.bindAsEventListener(this);
|
168 |
+
this.onItemMouseClick = this.itemMouseClick.bindAsEventListener(this);
|
169 |
+
this.onItemFormFieldChange = this.syncFormData.bindAsEventListener(this);
|
170 |
+
|
171 |
+
this.loader = new varienLoader(true);
|
172 |
+
this.regionsUrl = '<?php echo $this->getRegionsUrl() ?>';
|
173 |
+
// set Ajax controller url - Harry
|
174 |
+
this.citiesUrl = '<?php echo $this->getCitiesUrl() ?>';
|
175 |
+
|
176 |
+
this.requiredStateForCountries = <?php echo $this->helper('directory')->getCountriesWithStatesRequired(true) ?>;
|
177 |
+
this.showAllRegions = <?php echo (string)$this->helper('directory')->getShowNonRequiredState() ? 1 : 0; ?>;
|
178 |
+
|
179 |
+
this.reloadItemList(1);
|
180 |
+
|
181 |
+
for (var i = 0, n = this.itemList.length; i < n; i++) {
|
182 |
+
if (this.itemList[i].id) {
|
183 |
+
this.addItemObservers(this.itemList[i]);
|
184 |
+
this.initItem(this.itemList[i]);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
if ($('add_new_address_button')) {
|
188 |
+
Event.observe('add_new_address_button', 'click', this.onNewAddressClick)
|
189 |
+
}
|
190 |
+
|
191 |
+
this.setActiveItem(this.itemList[0]);
|
192 |
+
this.setAddressAsDefault();
|
193 |
+
this.bindCountryRegionRelation();
|
194 |
+
|
195 |
+
// set action for region, city - Harry
|
196 |
+
this.bindRegionCityRelation();
|
197 |
+
},
|
198 |
+
|
199 |
+
reloadItemList: function (initial) {
|
200 |
+
this.itemList = $$('#address_list li');
|
201 |
+
if (initial) {
|
202 |
+
this.itemCount = this.itemList.length;
|
203 |
+
}
|
204 |
+
if (!this.itemList.length) {
|
205 |
+
if ($('no_address_message')) {
|
206 |
+
$('no_address_message').show();
|
207 |
+
}
|
208 |
+
else {
|
209 |
+
this.formContainer.innerHTML += '<div id="no_address_message"><?php echo addslashes(Mage::helper('customer')->__('This customer has no saved addresses.')) ?></div>'
|
210 |
+
}
|
211 |
+
}
|
212 |
+
},
|
213 |
+
|
214 |
+
initItem: function (item) {
|
215 |
+
if (item && $('form_' + item.id)) {
|
216 |
+
item.formBlock = $('form_' + item.id);
|
217 |
+
Element.hide($('form_' + item.id));
|
218 |
+
$('form_' + item.id).statusBar = item;
|
219 |
+
$('form_' + item.id).addressItem = item;
|
220 |
+
|
221 |
+
// set Zip optional/required
|
222 |
+
var countryElement = $('_item' + item.id.replace(/address_item_/, '') + 'country_id');
|
223 |
+
varienGlobalEvents.fireEvent("address_country_changed", countryElement);
|
224 |
+
}
|
225 |
+
},
|
226 |
+
|
227 |
+
addItemObservers: function (item) {
|
228 |
+
if (item.id) {
|
229 |
+
Event.observe(item, 'mouseover', this.onItemMouseOver);
|
230 |
+
Event.observe(item, 'mouseout', this.onItemMouseOut);
|
231 |
+
Event.observe(item, 'click', this.onItemMouseClick);
|
232 |
+
}
|
233 |
+
},
|
234 |
+
|
235 |
+
addNewAddress: function (event) {
|
236 |
+
if (this.canCreateNewAddress) {
|
237 |
+
this.itemCount++;
|
238 |
+
if ($('no_address_message')) {
|
239 |
+
$('no_address_message').hide();
|
240 |
+
}
|
241 |
+
// preventing duplication of ids for fields and blocks
|
242 |
+
while ($$("div[id='form_address_item_" + this.itemCount + "']").length) {
|
243 |
+
this.itemCount++;
|
244 |
+
}
|
245 |
+
// create new form elements
|
246 |
+
Element.insert(this.formContainer, {
|
247 |
+
bottom: '<div id="' + 'form_' + this.baseItemId + this.itemCount + '">'
|
248 |
+
+ this.prepareTemplate(this.formTemplate.innerHTML)
|
249 |
+
+ '</div>'
|
250 |
+
});
|
251 |
+
|
252 |
+
var newForm = $('form_' + this.baseItemId + this.itemCount);
|
253 |
+
|
254 |
+
$('_item' + this.itemCount + 'firstname').value = $('_accountfirstname').value;
|
255 |
+
$('_item' + this.itemCount + 'lastname').value = $('_accountlastname').value;
|
256 |
+
|
257 |
+
if ($('_accountwebsite_id').value !== '' && undefined !== this.defaultCountries[$('_accountwebsite_id').value]) {
|
258 |
+
$('_item' + this.itemCount + 'country_id').value = this.defaultCountries[$('_accountwebsite_id').value];
|
259 |
+
}
|
260 |
+
|
261 |
+
Element.hide(newForm);
|
262 |
+
var template = '<li id="' + this.baseItemId + this.itemCount + '">';
|
263 |
+
deleteButtonId++;
|
264 |
+
template += this.prepareTemplate(this.itemTemplate.innerHTML).replace('delete_button', 'delete_button' + deleteButtonId);
|
265 |
+
template += '</li>';
|
266 |
+
Element.insert(this.itemContainer, {bottom: template});
|
267 |
+
var newItem = $(this.baseItemId + this.itemCount);
|
268 |
+
newItem.isNewAddress = true;
|
269 |
+
newItem.formBlock = newForm;
|
270 |
+
|
271 |
+
|
272 |
+
newForm.statusBar = newItem;
|
273 |
+
newForm.addressItem = newItem;
|
274 |
+
|
275 |
+
this.addItemObservers(newItem);
|
276 |
+
this.setActiveItem(newItem);
|
277 |
+
this.bindCountryRegionRelation(newForm.id);
|
278 |
+
this.bindRegionCityRelation(newForm.id);
|
279 |
+
|
280 |
+
if ($('_item' + this.itemCount + 'firstname').value) this.syncFormData($('_item' + this.itemCount + 'firstname'));
|
281 |
+
if ($('_item' + this.itemCount + 'lastname').value) this.syncFormData($('_item' + this.itemCount + 'lastname'));
|
282 |
+
}
|
283 |
+
this.reloadItemList();
|
284 |
+
//Event.stop(event);
|
285 |
+
},
|
286 |
+
|
287 |
+
prepareTemplate: function (template) {
|
288 |
+
return template
|
289 |
+
.replace(/<?php echo $_templatePrefix ?>/g, '_item'+this.itemCount)
|
290 |
+
.replace(/_counted="undefined"/g, '')
|
291 |
+
.replace(/"select_button_"/g, 'select_button_' + this.itemCount)
|
292 |
+
;
|
293 |
+
},
|
294 |
+
|
295 |
+
canCreateNewAddress: function () {
|
296 |
+
return true;
|
297 |
+
},
|
298 |
+
|
299 |
+
itemMouseOver: function (event) {
|
300 |
+
var element = Event.findElement(event, 'li');
|
301 |
+
Element.addClassName(element, 'over');
|
302 |
+
},
|
303 |
+
|
304 |
+
itemMouseOut: function (event) {
|
305 |
+
var element = Event.findElement(event, 'li');
|
306 |
+
Element.removeClassName(element, 'over');
|
307 |
+
},
|
308 |
+
|
309 |
+
itemMouseClick: function (event) {
|
310 |
+
if (!Event) {
|
311 |
+
return;
|
312 |
+
}
|
313 |
+
var element = Event.findElement(event, 'li'); // find top item
|
314 |
+
var elem = Event.element(event); // exact element clicked
|
315 |
+
|
316 |
+
if (((elem.tagName.toUpperCase() == 'A') && elem.id.match(/^delete_button([0-9]*?)$/)) || ((elem.tagName.toUpperCase() == 'IMG') && elem.id.match(/^delete_button([0-9]*?)$/))) {
|
317 |
+
this.deleteAddress(element);
|
318 |
+
Event.stop(event);
|
319 |
+
}
|
320 |
+
else if (elem.tagName.toUpperCase() == 'INPUT') {
|
321 |
+
this.setAddressAsDefault(element);
|
322 |
+
}
|
323 |
+
else {
|
324 |
+
this.setActiveItem(element);
|
325 |
+
}
|
326 |
+
},
|
327 |
+
|
328 |
+
setAddressAsDefault: function () {
|
329 |
+
for (var i = 0; i < this.itemList.length; i++) {
|
330 |
+
if (this.itemList[i].id) {
|
331 |
+
var inputs = $(this.itemList[i].id).getElementsBySelector('input');
|
332 |
+
var isActive = false;
|
333 |
+
for (var j in inputs) {
|
334 |
+
if (inputs[j].type == 'radio' && inputs[j].checked && this.itemList.length > 1) {
|
335 |
+
isActive = true;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
this.toggleDeleteButton(this.itemList[i], !isActive);
|
339 |
+
}
|
340 |
+
}
|
341 |
+
},
|
342 |
+
|
343 |
+
toggleDeleteButton: function (item, flag) {
|
344 |
+
if (flag) {
|
345 |
+
$(item).select('.btn-remove-address').each(Element.show);
|
346 |
+
$(item.formBlock).getElementsBySelector('.delete-address').each(Element.show);
|
347 |
+
} else {
|
348 |
+
$(item).select('.btn-remove-address').each(Element.hide);
|
349 |
+
$(item.formBlock).getElementsBySelector('.delete-address').each(Element.hide);
|
350 |
+
}
|
351 |
+
},
|
352 |
+
|
353 |
+
setActiveItem: function (item) {
|
354 |
+
if (this.activeItem) {
|
355 |
+
Element.removeClassName(this.activeItem, 'on');
|
356 |
+
if ($('form_' + this.activeItem.id)) {
|
357 |
+
Element.hide($('form_' + this.activeItem.id));
|
358 |
+
}
|
359 |
+
}
|
360 |
+
Element.addClassName(item, 'on');
|
361 |
+
|
362 |
+
if (item && $('form_' + item.id)) {
|
363 |
+
$('form_' + item.id).changeRelation = item;
|
364 |
+
$('form_' + item.id).addressItem = item;
|
365 |
+
Element.show($('form_' + item.id));
|
366 |
+
//new Effect.Appear($('form_'+item.id), {duration : 0.3 });
|
367 |
+
//$('form_'+item.id).focus();
|
368 |
+
this.addFieldChangeObserver($('form_' + item.id));
|
369 |
+
var regionIdElement = $('_item' + item.id.replace(/address_item_/, '') + 'region_id');
|
370 |
+
var regionElement = $('_item' + item.id.replace(/address_item_/, '') + 'region');
|
371 |
+
this.countryEl = $('_item' + item.id.replace(/address_item_/, '') + 'country_id');
|
372 |
+
if (regionIdElement && regionElement) {
|
373 |
+
var actualId = regionElement.id;
|
374 |
+
if (('select' == regionIdElement.tagName.toLowerCase()) && regionIdElement) {
|
375 |
+
actualId = regionIdElement.id;
|
376 |
+
}
|
377 |
+
this._checkRegionRequired([regionIdElement, regionElement], actualId);
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
this.activeItem = item;
|
382 |
+
},
|
383 |
+
|
384 |
+
getFormContainerFields: function (container) {
|
385 |
+
var fields = $$('#' + container.id + ' input', '#' + container.id + ' select', '#' + container.id + ' textarea');
|
386 |
+
return fields;
|
387 |
+
},
|
388 |
+
|
389 |
+
addFieldChangeObserver: function (container) {
|
390 |
+
var fields = this.getFormContainerFields(container);
|
391 |
+
for (var i = 0; i < fields.length; i++) {
|
392 |
+
Event.observe(fields[i], 'change', this.onItemFormFieldChange);
|
393 |
+
}
|
394 |
+
|
395 |
+
},
|
396 |
+
|
397 |
+
syncFormData: function (evt) {
|
398 |
+
var container = false;
|
399 |
+
|
400 |
+
if (!evt.addClassName) {
|
401 |
+
var elm = Event.element(evt);
|
402 |
+
} else {
|
403 |
+
var elm = evt;
|
404 |
+
}
|
405 |
+
|
406 |
+
// Update postcode_id or city_id value to hidden input - Harry
|
407 |
+
if(elm.id.include('postcode_id')){
|
408 |
+
var zipcodeHtmlId = $(elm.id.replace(/postcode_id/, 'postcode'));
|
409 |
+
$(zipcodeHtmlId).value = elm.value;
|
410 |
+
}else if(elm.id.include('city_id')){
|
411 |
+
var cityHtmlId = $(elm.id.replace(/city_id/, 'city'));
|
412 |
+
$(cityHtmlId).value = elm[elm.selectedIndex].text;
|
413 |
+
}
|
414 |
+
|
415 |
+
elm = $(elm);
|
416 |
+
while (elm.tagName.toUpperCase() != 'BODY') {
|
417 |
+
if (elm.addressItem) {
|
418 |
+
container = elm;
|
419 |
+
}
|
420 |
+
elm = $(elm.parentNode);
|
421 |
+
}
|
422 |
+
|
423 |
+
|
424 |
+
if (container) {
|
425 |
+
var data = {};
|
426 |
+
var fields = this.getFormContainerFields(container);
|
427 |
+
for (var i = 0; i < fields.size(); i++) {
|
428 |
+
if (fields[i].id) {
|
429 |
+
var id = fields[i].id.replace(/^(_item)?[0-9]+/, '');
|
430 |
+
var id = id.replace(/^(id)?[0-9]+/, '');
|
431 |
+
var value = fields[i].getValue();
|
432 |
+
var tagName = fields[i].tagName.toLowerCase();
|
433 |
+
if (tagName == 'select') {
|
434 |
+
try{
|
435 |
+
if (fields[i].multiple) {
|
436 |
+
var values = $([]);
|
437 |
+
var l = fields[i].options.length;
|
438 |
+
for (j = 0; j < l; j++) {
|
439 |
+
var o = fields[i].options[j];
|
440 |
+
if (o.selected === true) {
|
441 |
+
values[values.length] = o.text.escapeHTML();
|
442 |
+
}
|
443 |
+
}
|
444 |
+
data[id] = values.join(', ');
|
445 |
+
} else {
|
446 |
+
data[id] = fields[i].options[fields[i].selectedIndex].text.escapeHTML();
|
447 |
+
}
|
448 |
+
} catch(ex) {}
|
449 |
+
} else if (value !== null) {
|
450 |
+
data[id] = value.escapeHTML();
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
|
456 |
+
// Set name of state to 'region' if list of states are in 'region_id' selectbox
|
457 |
+
if (!data['region'] && data['region_id']) {
|
458 |
+
data['region'] = data['region_id'];
|
459 |
+
delete data['region_id'];
|
460 |
+
}
|
461 |
+
|
462 |
+
// Set name of state to 'city' if list of states are in 'city_id' selectbox - Harry
|
463 |
+
if (!data['city'] && data['city_id']) {
|
464 |
+
data['city'] = data['city_id'];
|
465 |
+
delete data['city_id'];
|
466 |
+
}
|
467 |
+
|
468 |
+
// Set data to html
|
469 |
+
var itemContainer = container.addressItem.getElementsBySelector('address');
|
470 |
+
if (itemContainer[0]) {
|
471 |
+
var html = this.itemContentTemplate.evaluate(data);
|
472 |
+
html = html.replace(new RegExp('(<br\\s*/?>\\s*){2,}', 'img'), '<br/>');
|
473 |
+
html = html.replace(new RegExp('<br\\s*/?>(\\s*,){1,}\\s*<br\\s*/?>', 'ig'), '<br/>');
|
474 |
+
html = html.replace(new RegExp('<br\\s*/?>(\\s*,){1,}(.*)<br\\s*/?>', 'ig'), '<br/>$2<br/>');
|
475 |
+
html = html.replace(new RegExp('<br\\s*/?>(.*?)(,\\s*){1,}<br\\s*/?>', 'ig'), '<br/>$1<br/>');
|
476 |
+
html = html.replace(new RegExp('<br\\s*/?>(.*?)(,\\s*){2,}(.*?)<br\\s*/?>', 'ig'), '<br/>$1, $3<br/>');
|
477 |
+
html = html.replace(new RegExp('t:\\s*<br\\s*/?>', 'ig'), '');
|
478 |
+
html = html.replace(new RegExp('f:\\s*<br\\s*/?>', 'ig'), '');
|
479 |
+
html = html.replace(new RegExp('vat:\\s*$', 'ig'), '');
|
480 |
+
itemContainer[0].innerHTML = html;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
},
|
484 |
+
|
485 |
+
deleteAddress: function (item) {
|
486 |
+
if (confirm('<?php echo Mage::helper('customer')->__('Are you sure you want to delete this address?') ?>')) {
|
487 |
+
if (!item.isNewAddress && $('deleted_' + item.id)) {
|
488 |
+
$('deleted_' + item.id).value = 1;
|
489 |
+
if (item.formBlock) {
|
490 |
+
item.formBlock.addClassName('ignore-validation');
|
491 |
+
}
|
492 |
+
}
|
493 |
+
if (this.activeItem == item && item != this.itemList[0]) this.setActiveItem(this.itemList[0]);
|
494 |
+
if (item == this.itemList[0] && (this.itemList[1])) this.setActiveItem(this.itemList[1]);
|
495 |
+
|
496 |
+
this.formContainer.removeChild(item.formBlock);
|
497 |
+
this.itemContainer.removeChild(item);
|
498 |
+
this.reloadItemList();
|
499 |
+
this.setAddressAsDefault();
|
500 |
+
}
|
501 |
+
},
|
502 |
+
|
503 |
+
cancelAdd: function (button) {
|
504 |
+
if (confirm('<?php echo addslashes(Mage::helper('customer')->__('Are you sure you want to cancel adding of this address?')) ?>')) {
|
505 |
+
var item = $(this.baseItemId + button.id.replace(new RegExp('[a-z_]*', ''), ''));
|
506 |
+
|
507 |
+
if (item.isNewAddress) {
|
508 |
+
if (this.activeItem == item) this.formContainer.removeChild(item.formBlock);
|
509 |
+
}
|
510 |
+
if (this.activeItem == item && item != this.itemList[0]) this.setActiveItem(this.itemList[0]);
|
511 |
+
if (item == this.itemList[0] && (this.itemList[1])) this.setActiveItem(this.itemList[1]);
|
512 |
+
|
513 |
+
this.itemContainer.removeChild(item);
|
514 |
+
|
515 |
+
this.reloadItemList();
|
516 |
+
this.setAddressAsDefault();
|
517 |
+
}
|
518 |
+
},
|
519 |
+
|
520 |
+
bindCountryRegionRelation: function (parentId) {
|
521 |
+
//alert('OK');
|
522 |
+
if (parentId) {
|
523 |
+
var countryElements = $(parentId).getElementsByClassName('countries');
|
524 |
+
}
|
525 |
+
else {
|
526 |
+
var countryElements = $$('.countries');
|
527 |
+
}
|
528 |
+
|
529 |
+
for (var i = 0; i <= countryElements.length; i++) {
|
530 |
+
if (countryElements[i]) {
|
531 |
+
if (!countryElements[i].bindRegions || !countryElements[i].parentBindId || countryElements[i].parentBindId != parentId) {
|
532 |
+
//if(!countryElements[i].bindRegions || !countryElements[i].parentBindId){
|
533 |
+
Event.observe(countryElements[i], 'change', this.reloadRegionField.bind(this));
|
534 |
+
|
535 |
+
countryElements[i].bindRegions = true;
|
536 |
+
countryElements[i].parentBindId = parentId;
|
537 |
+
}
|
538 |
+
}
|
539 |
+
}
|
540 |
+
},
|
541 |
+
|
542 |
+
reloadRegionField: function (event) {
|
543 |
+
var countryElement = Event.element(event);
|
544 |
+
if (countryElement.id) {
|
545 |
+
var regionElement = $(countryElement.id.replace(/country_id/, 'region'));
|
546 |
+
if (regionElement) {
|
547 |
+
this.regionElement = regionElement;
|
548 |
+
this.countryEl = countryElement;
|
549 |
+
if (countryElement.value) {
|
550 |
+
var url = this.regionsUrl + 'parent/' + countryElement.value;
|
551 |
+
this.loader.load(url, {}, this.refreshRegionField.bind(this));
|
552 |
+
} else {
|
553 |
+
// Set empty text field in region
|
554 |
+
this.refreshRegionField('[]');
|
555 |
+
}
|
556 |
+
|
557 |
+
//ipune: refresh all sub
|
558 |
+
this.cityElement = $(countryElement.id.replace(/country_id/, 'city'));
|
559 |
+
this.refreshCityField('[]');
|
560 |
+
|
561 |
+
}
|
562 |
+
// set Zip optional/required
|
563 |
+
varienGlobalEvents.fireEvent("address_country_changed", countryElement);
|
564 |
+
}
|
565 |
+
},
|
566 |
+
|
567 |
+
refreshRegionField: function (serverResponse) {
|
568 |
+
if (!serverResponse)
|
569 |
+
return;
|
570 |
+
var data = eval('(' + serverResponse + ')');
|
571 |
+
|
572 |
+
var row = Element.previous(this.regionElement.parentNode, 0);
|
573 |
+
var reqLabel = Element.select(row, '.required');
|
574 |
+
|
575 |
+
// Set regions and refresh controls
|
576 |
+
// We use a pair of 'region' and 'region_id' to properly submit data:
|
577 |
+
// manually entered text goes in 'region' and selected option id goes in 'region_id'
|
578 |
+
var regionHtmlName = this.regionElement.name;
|
579 |
+
var regionIdHtmlName = regionHtmlName.replace(/region/, 'region_id');
|
580 |
+
var regionHtmlId = this.regionElement.id;
|
581 |
+
var regionIdHtmlId = regionHtmlId.replace(/region/, 'region_id');
|
582 |
+
var newInputId = null; // id of imput that was added to a page - filled below
|
583 |
+
|
584 |
+
if (true || data.length) {
|
585 |
+
// Create visible selectbox 'region_id' and hidden 'region'
|
586 |
+
var html = '<select name="' + regionIdHtmlName + '" id="' + regionIdHtmlId + '" class="regions required-entry select" title="' + this.regionElement.title + '">';
|
587 |
+
//html += '<option value=""></option>';
|
588 |
+
for (var i in data) {
|
589 |
+
if (data[i].label) {
|
590 |
+
html += '<option value="' + data[i].value + '"';
|
591 |
+
if (this.regionElement.value && (this.regionElement.value == data[i].value || this.regionElement.value == data[i].label)) {
|
592 |
+
html += ' selected="selected"';
|
593 |
+
}
|
594 |
+
html += '>' + data[i].label + '</option>';
|
595 |
+
}
|
596 |
+
}
|
597 |
+
html += '</select>';
|
598 |
+
|
599 |
+
html += '<input type="hidden" name="' + regionHtmlName + '" id="' + regionHtmlId + '"/>';
|
600 |
+
|
601 |
+
if (reqLabel) {
|
602 |
+
reqLabel.each(function (item) {
|
603 |
+
Element.show(item)
|
604 |
+
});
|
605 |
+
}
|
606 |
+
|
607 |
+
newInputId = regionIdHtmlId;
|
608 |
+
} else {
|
609 |
+
// Create visible text input 'region' and hidden 'region_id'
|
610 |
+
var html = '<input type="text" name="' + regionHtmlName + '" id="' + regionHtmlId + '" class="regions input-text" title="' + this.regionElement.title + '" />';
|
611 |
+
html += '<input type="hidden" name="' + regionIdHtmlName + '" id="' + regionIdHtmlId + '"/>';
|
612 |
+
|
613 |
+
if (reqLabel) {
|
614 |
+
reqLabel.each(function (item) {
|
615 |
+
Element.hide(item)
|
616 |
+
});
|
617 |
+
}
|
618 |
+
|
619 |
+
newInputId = regionHtmlId;
|
620 |
+
}
|
621 |
+
|
622 |
+
var parentNode = this.regionElement.parentNode;
|
623 |
+
parentNode.innerHTML = html;
|
624 |
+
this.regionElement = $(regionHtmlId);
|
625 |
+
|
626 |
+
this.bindRegionCityRelation();
|
627 |
+
|
628 |
+
|
629 |
+
// Updating in address info
|
630 |
+
var newInput = $(newInputId);
|
631 |
+
Event.observe(newInput, 'change', this.onItemFormFieldChange); // Restore observing to update address info
|
632 |
+
this.syncFormData(newInput); // Update address info now
|
633 |
+
var activeElementId = regionHtmlId;
|
634 |
+
if (('select' == $(regionIdHtmlId).tagName.toLowerCase()) && regionIdHtmlId) {
|
635 |
+
activeElementId = regionIdHtmlId;
|
636 |
+
}
|
637 |
+
this._checkRegionRequired([$(regionHtmlId), $(regionIdHtmlId)], activeElementId);
|
638 |
+
},
|
639 |
+
|
640 |
+
_checkRegionRequired: function (elements, activeElementId) {
|
641 |
+
var label, wildCard;
|
642 |
+
var that = this;
|
643 |
+
var regionRequired = this.requiredStateForCountries.indexOf(this.countryEl.value) >= 0;
|
644 |
+
|
645 |
+
elements.each(function (currentElement) {
|
646 |
+
Validation.reset(currentElement);
|
647 |
+
label = $$('label[for="' + currentElement.id + '"]')[0];
|
648 |
+
if (label) {
|
649 |
+
wildCard = label.down('em') || label.down('span.required');
|
650 |
+
if (!that.showAllRegions) {
|
651 |
+
if (regionRequired) {
|
652 |
+
label.up('tr').show();
|
653 |
+
} else {
|
654 |
+
label.up('tr').hide();
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
if (label && wildCard) {
|
660 |
+
if (!regionRequired) {
|
661 |
+
wildCard.hide();
|
662 |
+
} else {
|
663 |
+
wildCard.show();
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
if (!regionRequired) {
|
668 |
+
if (currentElement.hasClassName('required-entry')) {
|
669 |
+
currentElement.removeClassName('required-entry');
|
670 |
+
}
|
671 |
+
if ('select' == currentElement.tagName.toLowerCase() &&
|
672 |
+
currentElement.hasClassName('validate-select')
|
673 |
+
) {
|
674 |
+
currentElement.removeClassName('validate-select');
|
675 |
+
}
|
676 |
+
} else if (activeElementId == currentElement.id) {
|
677 |
+
if (!currentElement.hasClassName('required-entry')) {
|
678 |
+
currentElement.addClassName('required-entry');
|
679 |
+
}
|
680 |
+
if ('select' == currentElement.tagName.toLowerCase() && !currentElement.hasClassName('validate-select')
|
681 |
+
) {
|
682 |
+
currentElement.addClassName('validate-select');
|
683 |
+
}
|
684 |
+
}
|
685 |
+
});
|
686 |
+
},
|
687 |
+
|
688 |
+
// reload City field after select Region - Harry
|
689 |
+
bindRegionCityRelation: function (parentId) {
|
690 |
+
if (parentId) {
|
691 |
+
// var regionElements = $(parentId).getElementsByClassName('regions');
|
692 |
+
var regionElements = $$("[id*=region_id]");
|
693 |
+
}
|
694 |
+
else {
|
695 |
+
var regionElements = $$("[id*=region_id]");
|
696 |
+
}
|
697 |
+
|
698 |
+
for (var i = 0; i <= regionElements.length; i++) {
|
699 |
+
if (regionElements[i]) {
|
700 |
+
|
701 |
+
if (!regionElements[i].bindCities || !regionElements[i].parentBindId || regionElements[i].parentBindId != parentId) {
|
702 |
+
Event.observe(regionElements[i], 'change', this.reloadCityField.bind(this));
|
703 |
+
|
704 |
+
regionElements[i].bindCities = true;
|
705 |
+
regionElements[i].parentBindId = parentId;
|
706 |
+
}
|
707 |
+
}
|
708 |
+
}
|
709 |
+
},
|
710 |
+
|
711 |
+
reloadCityField: function (event) {
|
712 |
+
var regionElement = Event.element(event);
|
713 |
+
if (regionElement.id) {
|
714 |
+
var cityElement = $(regionElement.id.replace(/region_id/, 'city'));
|
715 |
+
if (cityElement) {
|
716 |
+
this.cityElement = cityElement;
|
717 |
+
this.regionEl = regionElement;
|
718 |
+
|
719 |
+
if (regionElement.value) {
|
720 |
+
var url = this.citiesUrl + 'parent/' + regionElement.value;
|
721 |
+
this.loader.load(url, {}, this.refreshCityField.bind(this));
|
722 |
+
} else {
|
723 |
+
// Set empty text field in region
|
724 |
+
this.refreshCityField('[]');
|
725 |
+
}
|
726 |
+
}
|
727 |
+
}
|
728 |
+
},
|
729 |
+
|
730 |
+
refreshCityField: function (serverResponse) {
|
731 |
+
if (!serverResponse)
|
732 |
+
return;
|
733 |
+
var data = eval('(' + serverResponse + ')');
|
734 |
+
|
735 |
+
var row = Element.previous(this.cityElement.parentNode, 0);
|
736 |
+
var reqLabel = Element.select(row, '.required');
|
737 |
+
|
738 |
+
var cityHtmlName = this.cityElement.name;
|
739 |
+
var cityIdHtmlName = cityHtmlName.replace(/city/, 'city_id');
|
740 |
+
var cityHtmlId = this.cityElement.id;
|
741 |
+
var cityIdHtmlId = cityHtmlId.replace(/city/, 'city_id');
|
742 |
+
var newInputId = null; // id of imput that was added to a page - filled below
|
743 |
+
|
744 |
+
if (data.length) {
|
745 |
+
// Create visible selectbox 'region_id' and hidden 'region'
|
746 |
+
var html = '<select name="' + cityIdHtmlName + '" id="' + cityIdHtmlId + '" class="cities required-entry select" title="' + this.cityElement.title + '">';
|
747 |
+
//html += '<option value=""></option>';
|
748 |
+
for (var i in data) {
|
749 |
+
if (data[i].label) {
|
750 |
+
html += '<option value="' + data[i].value + '"';
|
751 |
+
if (this.cityElement.value && (this.cityElement.value == data[i].value || this.cityElement.value == data[i].label)) {
|
752 |
+
html += ' selected="selected"';
|
753 |
+
}
|
754 |
+
html += '>' + data[i].label + '</option>';
|
755 |
+
}
|
756 |
+
}
|
757 |
+
html += '</select>';
|
758 |
+
|
759 |
+
html += '<input type="hidden" name="' + cityHtmlName + '" id="' + cityHtmlId + '"/>';
|
760 |
+
|
761 |
+
if (reqLabel) {
|
762 |
+
reqLabel.each(function (item) {
|
763 |
+
Element.show(item)
|
764 |
+
});
|
765 |
+
}
|
766 |
+
|
767 |
+
newInputId = cityIdHtmlId;
|
768 |
+
} else {
|
769 |
+
// Create visible text input 'region' and hidden 'region_id'
|
770 |
+
var html = '<input type="text" name="' + cityHtmlName + '" id="' + cityHtmlId + '" class="cities input-text" title="' + this.cityElement.title + '" />';
|
771 |
+
html += '<input type="hidden" name="' + cityIdHtmlName + '" id="' + cityIdHtmlId + '"/>';
|
772 |
+
|
773 |
+
if (reqLabel) {
|
774 |
+
reqLabel.each(function (item) {
|
775 |
+
Element.hide(item)
|
776 |
+
});
|
777 |
+
}
|
778 |
+
|
779 |
+
newInputId = cityHtmlId;
|
780 |
+
}
|
781 |
+
|
782 |
+
var parentNode = this.cityElement.parentNode;
|
783 |
+
parentNode.innerHTML = html;
|
784 |
+
this.cityElement = $(cityHtmlId);
|
785 |
+
|
786 |
+
// Updating in address info
|
787 |
+
var newInput = $(newInputId);
|
788 |
+
Event.observe(newInput, 'change', this.onItemFormFieldChange); // Restore observing to update address info
|
789 |
+
this.syncFormData(newInput); // Update address info now
|
790 |
+
var activeElementId = cityHtmlId;
|
791 |
+
if (('select' == $(cityIdHtmlId).tagName.toLowerCase()) && cityIdHtmlId) {
|
792 |
+
activeElementId = cityIdHtmlId;
|
793 |
+
}
|
794 |
+
this._checkCityRequired([$(cityHtmlId), $(cityIdHtmlId)], activeElementId);
|
795 |
+
},
|
796 |
+
|
797 |
+
_checkCityRequired: function(elements, activeElementId)
|
798 |
+
{
|
799 |
+
var label, wildCard;
|
800 |
+
var that = this;
|
801 |
+
var cityRequired = true;
|
802 |
+
|
803 |
+
elements.each(function(currentElement) {
|
804 |
+
Validation.reset(currentElement);
|
805 |
+
label = $$('label[for="' + currentElement.id + '"]')[0];
|
806 |
+
if (label) {
|
807 |
+
label.update('City<span class="required">*</span>');
|
808 |
+
label.innerHTML;
|
809 |
+
wildCard = label.down('em') || label.down('span.required');
|
810 |
+
if (cityRequired) {
|
811 |
+
label.up('tr').show();
|
812 |
+
} else {
|
813 |
+
label.up('tr').hide();
|
814 |
+
}
|
815 |
+
}
|
816 |
+
|
817 |
+
if (label && wildCard) {
|
818 |
+
if (!cityRequired) {
|
819 |
+
wildCard.hide();
|
820 |
+
} else {
|
821 |
+
wildCard.show();
|
822 |
+
}
|
823 |
+
}
|
824 |
+
|
825 |
+
if (!cityRequired) {
|
826 |
+
if (currentElement.hasClassName('required-entry')) {
|
827 |
+
currentElement.removeClassName('required-entry');
|
828 |
+
}
|
829 |
+
if ('select' == currentElement.tagName.toLowerCase() &&
|
830 |
+
currentElement.hasClassName('validate-select')
|
831 |
+
) {
|
832 |
+
currentElement.removeClassName('validate-select');
|
833 |
+
}
|
834 |
+
} else if (activeElementId == currentElement.id) {
|
835 |
+
if (!currentElement.hasClassName('required-entry')) {
|
836 |
+
// currentElement.addClassName('required-entry');
|
837 |
+
}
|
838 |
+
if ('select' == currentElement.tagName.toLowerCase() &&
|
839 |
+
!currentElement.hasClassName('validate-select')
|
840 |
+
) {
|
841 |
+
currentElement.addClassName('validate-select');
|
842 |
+
}
|
843 |
+
}
|
844 |
+
});
|
845 |
+
}
|
846 |
+
}
|
847 |
+
|
848 |
+
customerAddresses = new addressesModel();
|
849 |
+
//]]>
|
850 |
+
</script>
|
851 |
+
</td>
|
852 |
+
</tr>
|
853 |
+
</table>
|
app/design/adminhtml/default/default/template/improvedaddress/sales/order/create/form/address.phtml
ADDED
@@ -0,0 +1,93 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
if($this->getIsShipping()):
|
27 |
+
$_fieldsContainerId = 'order-shipping_address_fields';
|
28 |
+
$_addressChoiceContainerId = 'order-shipping_address_choice';
|
29 |
+
?>
|
30 |
+
<script type="text/javascript">
|
31 |
+
order.shippingAddressContainer = '<?php echo $_fieldsContainerId ?>';
|
32 |
+
order.setAddresses(<?php echo $this->getAddressCollectionJson() ?>);
|
33 |
+
</script>
|
34 |
+
<?php
|
35 |
+
else:
|
36 |
+
$_fieldsContainerId = 'order-billing_address_fields';
|
37 |
+
$_addressChoiceContainerId = 'order-billing_address_choice';
|
38 |
+
?>
|
39 |
+
<script type="text/javascript">
|
40 |
+
order.billingAddressContainer = '<?php echo $_fieldsContainerId ?>';
|
41 |
+
</script>
|
42 |
+
<?php
|
43 |
+
endif; ?>
|
44 |
+
<div class="entry-edit">
|
45 |
+
|
46 |
+
<div class="entry-edit-head">
|
47 |
+
<h4 class="icon-head fieldset-legend <?php echo $this->getHeaderCssClass() ?>"><?php echo $this->getHeaderText() ?></h4>
|
48 |
+
</div>
|
49 |
+
|
50 |
+
<fieldset class="np">
|
51 |
+
<div id = "<?php echo $_addressChoiceContainerId ?>" class="order-choose-address">
|
52 |
+
<?php echo Mage::helper('sales')->__('Select from existing customer addresses:') ?><br/>
|
53 |
+
<?php $_id = $this->getForm()->getHtmlIdPrefix() . 'customer_address_id' ?>
|
54 |
+
<select id="<?php echo $_id ?>" name="<?php echo $this->getForm()->getHtmlNamePrefix()?>[customer_address_id]" style="width:97.5%;" onchange="order.selectAddress(this, '<?php echo $_fieldsContainerId ?>')">
|
55 |
+
<option value=""><?php echo Mage::helper('sales')->__('Add New Address') ?></option>
|
56 |
+
<?php foreach ($this->getAddressCollection() as $_address): ?>
|
57 |
+
<?php //if($this->getAddressAsString($_address)!=$this->getAddressAsString($this->getAddress())): ?>
|
58 |
+
<option value="<?php echo $_address->getId() ?>"<?php if ($_address->getId()==$this->getAddressId()): ?> selected="selected"<?php endif; ?>>
|
59 |
+
<?php echo $this->getAddressAsString($_address) ?>
|
60 |
+
</option>
|
61 |
+
<?php //endif; ?>
|
62 |
+
<?php endforeach; ?>
|
63 |
+
|
64 |
+
</select>
|
65 |
+
<br/>
|
66 |
+
<?php if($this->getIsShipping()): ?>
|
67 |
+
<input type="checkbox" id="order-shipping_as_billing" name="shipping_as_billing" value="1" onclick="order.setShippingAsBilling(this.checked)" <?php if($this->getIsAsBilling()): ?>checked<?php endif; ?>/>
|
68 |
+
<label for="order-shipping_as_billing" class="no-float"><?php echo Mage::helper('sales')->__('Same As Billing Address') ?></label>
|
69 |
+
<?php else: ?>
|
70 |
+
|
71 |
+
<?php endif; ?>
|
72 |
+
</div>
|
73 |
+
|
74 |
+
<div class="order-address" id="<?php echo $_fieldsContainerId ?>">
|
75 |
+
<div class="content">
|
76 |
+
<?php echo $this->getForm()->toHtml() ?>
|
77 |
+
</div>
|
78 |
+
<div class="order-save-in-address-book">
|
79 |
+
<input name="<?php echo $this->getForm()->getHtmlNamePrefix()?>[save_in_address_book]" type="checkbox" id="<?php echo $this->getForm()->getHtmlIdPrefix()?>save_in_address_book" value="1" <?php if (!$this->getDontSaveInAddressBook() && $this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?>/>
|
80 |
+
<label for="<?php echo $this->getForm()->getHtmlIdPrefix()?>save_in_address_book"><?php echo Mage::helper('sales')->__('Save in address book') ?></label>
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
+
<?php $hideElement = 'address-' . ($this->getIsShipping() ? 'shipping' : 'billing') . '-overlay'; ?>
|
84 |
+
<div style="display:none;" id="<?php echo $hideElement ?>" class="overlay"><span><?php echo $this->__('Shipping address selection is not applicable') ?></span></div>
|
85 |
+
<script type="text/javascript">
|
86 |
+
order.bindAddressFields('<?php echo $_fieldsContainerId ?>');
|
87 |
+
order.bindAddressFields('<?php echo $_addressChoiceContainerId ?>');
|
88 |
+
<?php if($this->getIsShipping() && $this->getIsAsBilling()): ?>
|
89 |
+
order.disableShippingAddress(true);
|
90 |
+
<?php endif; ?>
|
91 |
+
</script>
|
92 |
+
</fieldset>
|
93 |
+
</div>
|
app/design/frontend/base/default/layout/improvedaddress.xml
ADDED
@@ -0,0 +1,35 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<checkout_onepage_index translate="label">
|
6 |
+
<reference name="head">
|
7 |
+
<action method="addJs"><script>magebuzz/improvedaddress.js</script></action>
|
8 |
+
</reference>
|
9 |
+
<reference name="checkout.onepage">
|
10 |
+
<action method="setTemplate"><template>improvedaddress/checkout/onepage.phtml</template></action>
|
11 |
+
</reference>
|
12 |
+
<reference name="checkout.onepage.billing">
|
13 |
+
<action method="setTemplate"><template>improvedaddress/checkout/onepage/billing.phtml</template></action>
|
14 |
+
</reference>
|
15 |
+
<reference name="checkout.onepage.shipping">
|
16 |
+
<action method="setTemplate"><template>improvedaddress/checkout/onepage/shipping.phtml</template></action>
|
17 |
+
</reference>
|
18 |
+
</checkout_onepage_index>
|
19 |
+
<customer_account_create translate="label">
|
20 |
+
<reference name="head">
|
21 |
+
<action method="addJs"><script>magebuzz/improvedaddress.js</script></action>
|
22 |
+
</reference>
|
23 |
+
<reference name="customer_form_register">
|
24 |
+
<action method="setTemplate"><template>improvedaddress/customer/form/register.phtml</template></action>
|
25 |
+
</reference>
|
26 |
+
</customer_account_create>
|
27 |
+
<customer_address_form>
|
28 |
+
<reference name="head">
|
29 |
+
<action method="addJs"><script>magebuzz/improvedaddress.js</script></action>
|
30 |
+
</reference>
|
31 |
+
<reference name="customer_address_edit">
|
32 |
+
<action method="setTemplate"><template>improvedaddress/customer/address/edit.phtml</template></action>
|
33 |
+
</reference>
|
34 |
+
</customer_address_form>
|
35 |
+
</layout>
|
app/design/frontend/base/default/template/improvedaddress/checkout/onepage.phtml
ADDED
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="page-title">
|
28 |
+
<h1><?php echo $this->__('Checkout') ?></h1>
|
29 |
+
</div>
|
30 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script>
|
31 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('magebuzz/improvedaddress/js/opcheckout.js') ?>"></script>
|
32 |
+
<ol class="opc" id="checkoutSteps">
|
33 |
+
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
|
34 |
+
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
|
35 |
+
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>">
|
36 |
+
<div class="step-title">
|
37 |
+
<span class="number"><?php echo $i ?></span>
|
38 |
+
<h2><?php echo $_stepInfo['label'] ?></h2>
|
39 |
+
<a href="#"><?php echo $this->__('Edit') ?></a>
|
40 |
+
</div>
|
41 |
+
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;">
|
42 |
+
<?php echo $this->getChildHtml($_stepId) ?>
|
43 |
+
</div>
|
44 |
+
</li>
|
45 |
+
<?php endforeach ?>
|
46 |
+
</ol>
|
47 |
+
<script type="text/javascript">
|
48 |
+
//<![CDATA[
|
49 |
+
var accordion = new Accordion('checkoutSteps', '.step-title', true);
|
50 |
+
<?php if($this->getActiveStep()): ?>
|
51 |
+
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
|
52 |
+
<?php endif ?>
|
53 |
+
var checkout = new Checkout(accordion,{
|
54 |
+
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
|
55 |
+
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
|
56 |
+
saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
|
57 |
+
failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
|
58 |
+
);
|
59 |
+
//]]>
|
60 |
+
</script>
|
app/design/frontend/base/default/template/improvedaddress/checkout/onepage/billing.phtml
ADDED
@@ -0,0 +1,226 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<form id="co-billing-form" action="">
|
28 |
+
<fieldset>
|
29 |
+
<ul class="form-list">
|
30 |
+
<?php if ($this->customerHasAddresses()): ?>
|
31 |
+
<li class="wide">
|
32 |
+
<label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
|
33 |
+
<div class="input-box">
|
34 |
+
<?php echo $this->getAddressesHtmlSelect('billing') ?>
|
35 |
+
</div>
|
36 |
+
</li>
|
37 |
+
<?php endif; ?>
|
38 |
+
<li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
|
39 |
+
<fieldset>
|
40 |
+
<input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
|
41 |
+
<ul>
|
42 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
|
43 |
+
<li class="fields">
|
44 |
+
<div class="field">
|
45 |
+
<label for="billing:company"><?php echo $this->__('Company') ?></label>
|
46 |
+
<div class="input-box">
|
47 |
+
<input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
48 |
+
</div>
|
49 |
+
</div>
|
50 |
+
<?php if(!$this->isCustomerLoggedIn()): ?>
|
51 |
+
<div class="field">
|
52 |
+
<label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
53 |
+
<div class="input-box">
|
54 |
+
<input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" />
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
<?php endif; ?>
|
58 |
+
</li>
|
59 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
60 |
+
<li class="wide">
|
61 |
+
<label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
64 |
+
</div>
|
65 |
+
</li>
|
66 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
67 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
68 |
+
<li class="wide">
|
69 |
+
<div class="input-box">
|
70 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" name="billing[street][]" id="billing:street<?php echo $_i ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
71 |
+
</div>
|
72 |
+
</li>
|
73 |
+
<?php endfor; ?>
|
74 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
75 |
+
<li class="wide">
|
76 |
+
<label for="billing:vat_id"><?php echo $this->__('VAT Number') ?></label>
|
77 |
+
<div class="input-box">
|
78 |
+
<input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('VAT Number')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
|
79 |
+
</div>
|
80 |
+
</li>
|
81 |
+
<?php endif; ?>
|
82 |
+
<li class="fields">
|
83 |
+
<div class="field">
|
84 |
+
<label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
85 |
+
<div class="input-box">
|
86 |
+
<select id="billing:region_id" name="billing[region_id]" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
|
87 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
88 |
+
</select>
|
89 |
+
<script type="text/javascript">
|
90 |
+
//<![CDATA[
|
91 |
+
$('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
92 |
+
//]]>
|
93 |
+
</script>
|
94 |
+
<input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
<div class="field">
|
98 |
+
<label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
99 |
+
<div class="input-box">
|
100 |
+
<select id="billing:city_id" name="billing[city_id]" title="<?php echo $this->__('City') ?>" class="validate-select" style="display:none;">
|
101 |
+
<option value=""><?php echo $this->__('Please select City') ?></option>
|
102 |
+
</select>
|
103 |
+
<script type="text/javascript">
|
104 |
+
//<![CDATA[
|
105 |
+
$('billing:city_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getCityId() ?>");
|
106 |
+
//]]>
|
107 |
+
</script>
|
108 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" name="billing[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="billing:city" />
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
</li>
|
112 |
+
<li class="fields">
|
113 |
+
<div class="field">
|
114 |
+
<label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
115 |
+
<div class="input-box">
|
116 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<div class="field">
|
120 |
+
<label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
121 |
+
<div class="input-box">
|
122 |
+
<?php echo $this->getCountryHtmlSelect('billing') ?>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</li>
|
126 |
+
<li class="fields">
|
127 |
+
<div class="field">
|
128 |
+
<label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
129 |
+
<div class="input-box">
|
130 |
+
<input type="text" name="billing[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="billing:telephone" />
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
<div class="field">
|
134 |
+
<label for="billing:fax"><?php echo $this->__('Fax') ?></label>
|
135 |
+
<div class="input-box">
|
136 |
+
<input type="text" name="billing[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Fax')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="billing:fax" />
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
</li>
|
140 |
+
<?php if(!$this->isCustomerLoggedIn()): ?>
|
141 |
+
|
142 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
143 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
144 |
+
<?php if ($_dob->isEnabled() || $_gender->isEnabled()): ?>
|
145 |
+
<li class="fields">
|
146 |
+
<?php if ($_dob->isEnabled()): ?>
|
147 |
+
<div class="field">
|
148 |
+
<?php echo $_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
|
149 |
+
</div>
|
150 |
+
<?php endif; ?>
|
151 |
+
<?php if ($_gender->isEnabled()): ?>
|
152 |
+
<div class="field">
|
153 |
+
<?php echo $_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
|
154 |
+
</div>
|
155 |
+
<?php endif ?>
|
156 |
+
</li>
|
157 |
+
<?php endif ?>
|
158 |
+
|
159 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
160 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
161 |
+
<li>
|
162 |
+
<?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
|
163 |
+
</li>
|
164 |
+
<?php endif ?>
|
165 |
+
|
166 |
+
<li class="fields" id="register-customer-password">
|
167 |
+
<div class="field">
|
168 |
+
<label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
169 |
+
<div class="input-box">
|
170 |
+
<input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
<div class="field">
|
174 |
+
<label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
|
175 |
+
<div class="input-box">
|
176 |
+
<input type="password" name="billing[confirm_password]" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Confirm Password')) ?>" id="billing:confirm_password" class="input-text required-entry validate-cpassword" />
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
+
</li>
|
180 |
+
<?php endif; ?>
|
181 |
+
<?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
|
182 |
+
<li class="control">
|
183 |
+
<input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Save in address book')) ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="billing:save_in_address_book"><?php echo $this->__('Save in address book') ?></label>
|
184 |
+
</li>
|
185 |
+
<?php else:?>
|
186 |
+
<li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>
|
187 |
+
<?php endif; ?>
|
188 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
189 |
+
</ul>
|
190 |
+
</fieldset>
|
191 |
+
</li>
|
192 |
+
<?php /* Extensions placeholder */ ?>
|
193 |
+
<?php echo $this->getChildHtml('checkout.onepage.billing.extra')?>
|
194 |
+
<?php if ($this->canShip()): ?>
|
195 |
+
<li class="control">
|
196 |
+
<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo Mage::helper('core')->quoteEscape($this->__('Ship to this address')) ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo $this->__('Ship to this address') ?></label></li>
|
197 |
+
<li class="control">
|
198 |
+
<input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo Mage::helper('core')->quoteEscape($this->__('Ship to different address')) ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
|
199 |
+
</li>
|
200 |
+
<?php endif; ?>
|
201 |
+
</ul>
|
202 |
+
<?php if (!$this->canShip()): ?>
|
203 |
+
<input type="hidden" name="billing[use_for_shipping]" value="1" />
|
204 |
+
<?php endif; ?>
|
205 |
+
<div class="buttons-set" id="billing-buttons-container">
|
206 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
207 |
+
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue')) ?>" class="button" onclick="billing.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
208 |
+
<span class="please-wait" id="billing-please-wait" style="display:none;">
|
209 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
|
210 |
+
</span>
|
211 |
+
</div>
|
212 |
+
</fieldset>
|
213 |
+
</form>
|
214 |
+
<script type="text/javascript">
|
215 |
+
//<![CDATA[
|
216 |
+
var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
|
217 |
+
var billingForm = new VarienForm('co-billing-form');
|
218 |
+
|
219 |
+
//billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
|
220 |
+
$('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
|
221 |
+
|
222 |
+
var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
|
223 |
+
|
224 |
+
new CityUpdater('billing:country_id', 'billing:region_id', 'billing:city', 'billing:city_id', <?php echo Mage::helper('improvedaddress')->getCityJson() ?>);
|
225 |
+
//]]>
|
226 |
+
</script>
|
app/design/frontend/base/default/template/improvedaddress/checkout/onepage/shipping.phtml
ADDED
@@ -0,0 +1,167 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
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*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<form action="" id="co-shipping-form">
|
28 |
+
<ul class="form-list">
|
29 |
+
<?php if ($this->customerHasAddresses()): ?>
|
30 |
+
<li class="wide">
|
31 |
+
<label for="shipping-address-select"><?php echo $this->__('Select a shipping address from your address book or enter a new address.') ?></label>
|
32 |
+
<div class="input-box">
|
33 |
+
<?php echo $this->getAddressesHtmlSelect('shipping') ?>
|
34 |
+
</div>
|
35 |
+
</li>
|
36 |
+
<?php endif ?>
|
37 |
+
<li id="shipping-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif ?>>
|
38 |
+
<fieldset>
|
39 |
+
<input type="hidden" name="shipping[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="shipping:address_id" />
|
40 |
+
<ul>
|
41 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?></li>
|
42 |
+
<li class="fields">
|
43 |
+
<div class="fields">
|
44 |
+
<label for="shipping:company"><?php echo $this->__('Company') ?></label>
|
45 |
+
<div class="input-box">
|
46 |
+
<input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" onchange="shipping.setSameAsBilling(false);" />
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
+
</li>
|
50 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
51 |
+
<li class="wide">
|
52 |
+
<label for="shipping:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
53 |
+
<div class="input-box">
|
54 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" name="shipping[street][]" id="shipping:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" onchange="shipping.setSameAsBilling(false);" />
|
55 |
+
</div>
|
56 |
+
</li>
|
57 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
58 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
59 |
+
<li class="wide">
|
60 |
+
<div class="input-box">
|
61 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" name="shipping[street][]" id="shipping:street<?php echo $_i ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" onchange="shipping.setSameAsBilling(false);" />
|
62 |
+
</div>
|
63 |
+
</li>
|
64 |
+
<?php endfor; ?>
|
65 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
66 |
+
<li class="wide">
|
67 |
+
<label for="billing:vat_id"><?php echo $this->__('VAT Number'); ?></label>
|
68 |
+
<div class="input-box">
|
69 |
+
<input type="text" id="shipping:vat_id" name="shipping[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()); ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('VAT Number')); ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
|
70 |
+
</div>
|
71 |
+
</li>
|
72 |
+
<?php endif; ?>
|
73 |
+
<li class="fields">
|
74 |
+
<div class="field">
|
75 |
+
<label for="shipping:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
76 |
+
<div class="input-box">
|
77 |
+
<select id="shipping:city_id" name="shipping[city_id]" title="<?php echo $this->__('City') ?>" class="validate-select" style="display:none;">
|
78 |
+
<option value=""><?php echo $this->__('Please select City') ?></option>
|
79 |
+
</select>
|
80 |
+
<script type="text/javascript">
|
81 |
+
//<![CDATA[
|
82 |
+
$('shipping:city_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getCityId() ?>");
|
83 |
+
//]]>
|
84 |
+
</script>
|
85 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" name="shipping[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="shipping:city" onchange="shipping.setSameAsBilling(false);" />
|
86 |
+
</div>
|
87 |
+
</div>
|
88 |
+
<div class="field">
|
89 |
+
<label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
90 |
+
<div class="input-box">
|
91 |
+
<select id="shipping:region_id" name="shipping[region_id]" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
|
92 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
93 |
+
</select>
|
94 |
+
<script type="text/javascript">
|
95 |
+
//<![CDATA[
|
96 |
+
$('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
97 |
+
//]]>
|
98 |
+
</script>
|
99 |
+
<input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
</li>
|
103 |
+
<li class="fields">
|
104 |
+
<div class="field">
|
105 |
+
<label for="shipping:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
106 |
+
<div class="input-box">
|
107 |
+
<input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" onchange="shipping.setSameAsBilling(false);" />
|
108 |
+
</div>
|
109 |
+
</div>
|
110 |
+
<div class="field">
|
111 |
+
<label for="shipping:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
112 |
+
<div class="input-box">
|
113 |
+
<?php echo $this->getCountryHtmlSelect('shipping') ?>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
</li>
|
117 |
+
<li class="fields">
|
118 |
+
<div class="field">
|
119 |
+
<label for="shipping:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
120 |
+
<div class="input-box">
|
121 |
+
<input type="text" name="shipping[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
<div class="field">
|
125 |
+
<label for="shipping:fax"><?php echo $this->__('Fax') ?></label>
|
126 |
+
<div class="input-box">
|
127 |
+
<input type="text" name="shipping[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Fax')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="shipping:fax" onchange="shipping.setSameAsBilling(false);" />
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
</li>
|
131 |
+
<?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
|
132 |
+
<li class="control">
|
133 |
+
<input type="checkbox" name="shipping[save_in_address_book]" value="1" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Save in address book')) ?>" id="shipping:save_in_address_book" onchange="shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="shipping:save_in_address_book"><?php echo $this->__('Save in address book') ?></label></li>
|
134 |
+
<?php else:?>
|
135 |
+
<li class="no-display"><input type="hidden" name="shipping[save_in_address_book]" value="1" /></li>
|
136 |
+
<?php endif;?>
|
137 |
+
</ul>
|
138 |
+
</fieldset>
|
139 |
+
</li>
|
140 |
+
<li class="control">
|
141 |
+
<input type="checkbox" name="shipping[same_as_billing]" id="shipping:same_as_billing" value="1"<?php if($this->getAddress()->getSameAsBilling()): ?> checked="checked"<?php endif; ?> title="<?php echo $this->__('Use Billing Address') ?>" onclick="shipping.setSameAsBilling(this.checked)" class="checkbox" /><label for="shipping:same_as_billing"><?php echo $this->__('Use Billing Address') ?></label>
|
142 |
+
</li>
|
143 |
+
</ul>
|
144 |
+
<div class="buttons-set" id="shipping-buttons-container">
|
145 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
146 |
+
<p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
147 |
+
<button type="button" class="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue')) ?>" onclick="shipping.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
148 |
+
<span id="shipping-please-wait" class="please-wait" style="display:none;">
|
149 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Loading next step...')) ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
|
150 |
+
</span>
|
151 |
+
</div>
|
152 |
+
</form>
|
153 |
+
<script type="text/javascript">
|
154 |
+
//<![CDATA[
|
155 |
+
var shipping = new Shipping('co-shipping-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveShipping') ?>',
|
156 |
+
'<?php echo $this->getUrl('checkout/onepage/shippingMethod') ?>');
|
157 |
+
var shippingForm = new VarienForm('co-shipping-form');
|
158 |
+
shippingForm.extraChildParams = ' onchange="shipping.setSameAsBilling(false);"';
|
159 |
+
//shippingForm.setElementsRelation('shipping:country_id', 'shipping:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo Mage::helper('core')->jsQuoteEscape($this->__('Select State/Province...')) ?>');
|
160 |
+
$('shipping-address-select') && shipping.newAddress(!$('shipping-address-select').value);
|
161 |
+
|
162 |
+
var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'shipping:postcode');
|
163 |
+
|
164 |
+
var shippingCityUpdater = new CityUpdater('shipping:country_id', 'shipping:region_id', 'shipping:city', 'shipping:city_id', <?php echo Mage::helper('improvedaddress')->getCityJson() ?>);
|
165 |
+
|
166 |
+
//]]>
|
167 |
+
</script>
|
app/design/frontend/base/default/template/improvedaddress/customer/address/edit.phtml
ADDED
@@ -0,0 +1,141 @@
|
|
Â
|
|
Â
|
|
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echo $this->getTitle() ?></h1>
|
4 |
+
</div>
|
5 |
+
<?php endif; ?>
|
6 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
7 |
+
<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="form-validate">
|
8 |
+
<div class="fieldset">
|
9 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
10 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
|
11 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
|
12 |
+
<h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
|
13 |
+
<ul class="form-list">
|
14 |
+
<li class="fields">
|
15 |
+
<?php echo $this->getNameBlockHtml() ?>
|
16 |
+
</li>
|
17 |
+
<li class="wide">
|
18 |
+
<label for="company"><?php echo $this->__('Company') ?></label>
|
19 |
+
<div class="input-box">
|
20 |
+
<input type="text" name="company" id="company" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
21 |
+
</div>
|
22 |
+
</li>
|
23 |
+
<li class="fields">
|
24 |
+
<div class="field">
|
25 |
+
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
26 |
+
<div class="input-box">
|
27 |
+
<input type="text" name="telephone" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="telephone" />
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<div class="field">
|
31 |
+
<label for="fax"><?php echo $this->__('Fax') ?></label>
|
32 |
+
<div class="input-box">
|
33 |
+
<input type="text" name="fax" id="fax" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Fax')) ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" />
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
</li>
|
37 |
+
</ul>
|
38 |
+
</div>
|
39 |
+
<div class="fieldset">
|
40 |
+
<h2 class="legend"><?php echo $this->__('Address') ?></h2>
|
41 |
+
<ul class="form-list">
|
42 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
43 |
+
<li class="wide">
|
44 |
+
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
45 |
+
<div class="input-box">
|
46 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
|
47 |
+
</div>
|
48 |
+
</li>
|
49 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
50 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
51 |
+
<li class="wide">
|
52 |
+
<div class="input-box">
|
53 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
54 |
+
</div>
|
55 |
+
</li>
|
56 |
+
<?php endfor; ?>
|
57 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
58 |
+
<li class="wide">
|
59 |
+
<label for="vat_id"><?php echo $this->__('VAT Number') ?></label>
|
60 |
+
<div class="input-box">
|
61 |
+
<input type="text" name="vat_id" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('VAT Number')) ?>" id="vat_id" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
|
62 |
+
</div>
|
63 |
+
</li>
|
64 |
+
<?php endif; ?>
|
65 |
+
<li class="fields">
|
66 |
+
<div class="field">
|
67 |
+
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
68 |
+
<div class="input-box">
|
69 |
+
<select id="region_id" name="region_id" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
|
70 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
71 |
+
</select>
|
72 |
+
<script type="text/javascript">
|
73 |
+
//<![CDATA[
|
74 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
75 |
+
//]]>
|
76 |
+
</script>
|
77 |
+
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
<div class="field">
|
81 |
+
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
82 |
+
<div class="input-box">
|
83 |
+
<select id="city_id" name="city_id" title="<?php echo $this->__('City') ?>" class="validate-select" style="display:none;">
|
84 |
+
<option value=""><?php echo $this->__('Please select City') ?></option>
|
85 |
+
</select>
|
86 |
+
<script type="text/javascript">
|
87 |
+
//<![CDATA[
|
88 |
+
$('city_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getCityId() ?>");
|
89 |
+
//]]>
|
90 |
+
</script>
|
91 |
+
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
</li>
|
95 |
+
<li class="fields">
|
96 |
+
<div class="field">
|
97 |
+
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
98 |
+
<div class="input-box">
|
99 |
+
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
<div class="field">
|
103 |
+
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
104 |
+
<div class="input-box">
|
105 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
106 |
+
</div>
|
107 |
+
</div>
|
108 |
+
</li>
|
109 |
+
<li<?php if($this->canSetAsDefaultBilling()) echo ' class="control"' ?>>
|
110 |
+
<?php if($this->isDefaultBilling()): ?>
|
111 |
+
<strong><?php echo $this->__('Default Billing Address') ?></strong>
|
112 |
+
<?php elseif($this->canSetAsDefaultBilling()): ?>
|
113 |
+
<input type="checkbox" id="primary_billing" name="default_billing" value="1" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Use as My Default Billing Address')) ?>" class="checkbox" /><label for="primary_billing"><?php echo $this->__('Use as my default billing address') ?></label>
|
114 |
+
<?php else: ?>
|
115 |
+
<input type="hidden" name="default_billing" value="1" />
|
116 |
+
<?php endif; ?>
|
117 |
+
</li>
|
118 |
+
<li<?php if($this->canSetAsDefaultShipping()) echo ' class="control"' ?>>
|
119 |
+
<?php if($this->isDefaultShipping()): ?>
|
120 |
+
<strong><?php echo $this->__('Default Shipping Address') ?></strong>
|
121 |
+
<?php elseif($this->canSetAsDefaultShipping()): ?>
|
122 |
+
<input type="checkbox" id="primary_shipping" name="default_shipping" value="1" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Use as My Default Shipping Address')) ?>" class="checkbox" /><label for="primary_shipping"><?php echo $this->__('Use as my default shipping address') ?></label>
|
123 |
+
<?php else: ?>
|
124 |
+
<input type="hidden" name="default_shipping" value="1" />
|
125 |
+
<?php endif; ?>
|
126 |
+
</li>
|
127 |
+
</ul>
|
128 |
+
</div>
|
129 |
+
<div class="buttons-set">
|
130 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
131 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
132 |
+
<button data-action="save-customer-address" type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Save Address')) ?>" class="button"><span><span><?php echo $this->__('Save Address') ?></span></span></button>
|
133 |
+
</div>
|
134 |
+
</form>
|
135 |
+
<script type="text/javascript">
|
136 |
+
//<![CDATA[
|
137 |
+
var dataForm = new VarienForm('form-validate', true);
|
138 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
|
139 |
+
new CityUpdater('country', 'region_id', 'city', 'city_id', <?php echo Mage::helper('improvedaddress')->getCityJson() ?>);
|
140 |
+
//]]>
|
141 |
+
</script>
|
app/design/frontend/base/default/template/improvedaddress/customer/form/register.phtml
ADDED
@@ -0,0 +1,166 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<div class="account-create">
|
2 |
+
<div class="page-title">
|
3 |
+
<h1><?php echo $this->__('Create an Account') ?></h1>
|
4 |
+
</div>
|
5 |
+
<?php echo $this->getChildHtml('form_fields_before')?>
|
6 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
7 |
+
<?php /* Extensions placeholder */ ?>
|
8 |
+
<?php echo $this->getChildHtml('customer.form.register.extra')?>
|
9 |
+
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
10 |
+
<div class="fieldset">
|
11 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
|
12 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
|
13 |
+
<h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
|
14 |
+
<ul class="form-list">
|
15 |
+
<li class="fields">
|
16 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
|
17 |
+
</li>
|
18 |
+
<li>
|
19 |
+
<label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
20 |
+
<div class="input-box">
|
21 |
+
<input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" />
|
22 |
+
</div>
|
23 |
+
</li>
|
24 |
+
<?php if ($this->isNewsletterEnabled()): ?>
|
25 |
+
<li class="control">
|
26 |
+
<div class="input-box">
|
27 |
+
<input type="checkbox" name="is_subscribed" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sign Up for Newsletter')) ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
|
28 |
+
</div>
|
29 |
+
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
30 |
+
<?php /* Extensions placeholder */ ?>
|
31 |
+
<?php echo $this->getChildHtml('customer.form.register.newsletter')?>
|
32 |
+
</li>
|
33 |
+
<?php endif ?>
|
34 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
35 |
+
<?php if ($_dob->isEnabled()): ?>
|
36 |
+
<li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
37 |
+
<?php endif ?>
|
38 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
39 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
40 |
+
<li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
41 |
+
<?php endif ?>
|
42 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
43 |
+
<?php if ($_gender->isEnabled()): ?>
|
44 |
+
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
|
45 |
+
<?php endif ?>
|
46 |
+
</ul>
|
47 |
+
</div>
|
48 |
+
<?php if($this->getShowAddressFields()): ?>
|
49 |
+
<div class="fieldset">
|
50 |
+
<input type="hidden" name="create_address" value="1" />
|
51 |
+
<h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
|
52 |
+
<ul class="form-list">
|
53 |
+
<li class="fields">
|
54 |
+
<div class="field">
|
55 |
+
<label for="company"><?php echo $this->__('Company') ?></label>
|
56 |
+
<div class="input-box">
|
57 |
+
<input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
<div class="field">
|
61 |
+
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
</li>
|
67 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
68 |
+
<li class="wide">
|
69 |
+
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
70 |
+
<div class="input-box">
|
71 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
|
72 |
+
</div>
|
73 |
+
</li>
|
74 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
75 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
76 |
+
<li class="wide">
|
77 |
+
<div class="input-box">
|
78 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
79 |
+
</div>
|
80 |
+
</li>
|
81 |
+
<?php endfor; ?>
|
82 |
+
<li class="fields">
|
83 |
+
<div class="field">
|
84 |
+
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
85 |
+
<div class="input-box">
|
86 |
+
<select id="region_id" name="region_id" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
|
87 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
88 |
+
</select>
|
89 |
+
<script type="text/javascript">
|
90 |
+
//<![CDATA[
|
91 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
|
92 |
+
//]]>
|
93 |
+
</script>
|
94 |
+
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
<div class="field">
|
98 |
+
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
99 |
+
<div class="input-box">
|
100 |
+
<select id="city_id" name="city_id" title="<?php echo $this->__('City') ?>" class="validate-select" style="display:none;">
|
101 |
+
<option value=""><?php echo $this->__('Please select City') ?></option>
|
102 |
+
</select>
|
103 |
+
<script type="text/javascript">
|
104 |
+
//<![CDATA[
|
105 |
+
$('city_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getCityId() ?>");
|
106 |
+
//]]>
|
107 |
+
</script>
|
108 |
+
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
</li>
|
112 |
+
<li class="fields">
|
113 |
+
<div class="field">
|
114 |
+
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
115 |
+
<div class="input-box">
|
116 |
+
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<div class="field">
|
120 |
+
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
121 |
+
<div class="input-box">
|
122 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</li>
|
126 |
+
</ul>
|
127 |
+
<input type="hidden" name="default_billing" value="1" />
|
128 |
+
<input type="hidden" name="default_shipping" value="1" />
|
129 |
+
</div>
|
130 |
+
<?php endif; ?>
|
131 |
+
<div class="fieldset">
|
132 |
+
<h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
|
133 |
+
<ul class="form-list">
|
134 |
+
<li class="fields">
|
135 |
+
<div class="field">
|
136 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
137 |
+
<div class="input-box">
|
138 |
+
<input type="password" name="password" id="password" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
|
139 |
+
</div>
|
140 |
+
</div>
|
141 |
+
<div class="field">
|
142 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
|
143 |
+
<div class="input-box">
|
144 |
+
<input type="password" name="confirmation" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
</li>
|
148 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
149 |
+
</ul>
|
150 |
+
</div>
|
151 |
+
<div class="buttons-set">
|
152 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
153 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
154 |
+
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Submit')) ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
|
155 |
+
</div>
|
156 |
+
</form>
|
157 |
+
<script type="text/javascript">
|
158 |
+
//<![CDATA[
|
159 |
+
var dataForm = new VarienForm('form-validate', true);
|
160 |
+
<?php if($this->getShowAddressFields()): ?>
|
161 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
|
162 |
+
new CityUpdater('country', 'region_id', 'city', 'city_id', <?php echo Mage::helper('improvedaddress')->getCityJson() ?>);
|
163 |
+
<?php endif; ?>
|
164 |
+
//]]>
|
165 |
+
</script>
|
166 |
+
</div>
|
app/design/frontend/rwd/default/template/improvedaddress/checkout/onepage.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package rwd_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="page-title">
|
28 |
+
<h1><?php echo $this->__('Checkout') ?></h1>
|
29 |
+
</div>
|
30 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script>
|
31 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('magebuzz/improvedaddress/js/opcheckout.js') ?>"></script>
|
32 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout_rwd.js') ?>"></script>
|
33 |
+
<ol class="opc opc-firststep-<?php echo $this->getActiveStep() ?>" id="checkoutSteps">
|
34 |
+
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
|
35 |
+
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
|
36 |
+
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>">
|
37 |
+
<div class="step-title">
|
38 |
+
<span class="number"><?php echo $i ?></span>
|
39 |
+
<h2><?php echo $_stepInfo['label'] ?></h2>
|
40 |
+
<a href="#"><?php echo $this->__('Edit') ?></a>
|
41 |
+
</div>
|
42 |
+
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;">
|
43 |
+
<?php echo $this->getChildHtml($_stepId) ?>
|
44 |
+
</div>
|
45 |
+
</li>
|
46 |
+
<?php endforeach ?>
|
47 |
+
</ol>
|
48 |
+
<script type="text/javascript">
|
49 |
+
//<![CDATA[
|
50 |
+
var accordion = new Accordion('checkoutSteps', '.step-title', true);
|
51 |
+
<?php if($this->getActiveStep()): ?>
|
52 |
+
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
|
53 |
+
<?php endif ?>
|
54 |
+
var checkout = new Checkout(accordion,{
|
55 |
+
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
|
56 |
+
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
|
57 |
+
saveMethod: '<?php echo $this->getUrl('checkout/onepage/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
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<div class="account-create">
|
2 |
+
<div class="page-title">
|
3 |
+
<h1><?php echo $this->__('Create an Account') ?></h1>
|
4 |
+
</div>
|
5 |
+
<?php echo $this->getChildHtml('form_fields_before')?>
|
6 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
7 |
+
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate" class="scaffold-form" enctype="multipart/form-data">
|
8 |
+
<div class="fieldset">
|
9 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
|
10 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
|
11 |
+
<p class="form-instructions"><?php echo $this->__('Please enter the following information to create your account.') ?></p>
|
12 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
13 |
+
<ul class="form-list">
|
14 |
+
<li class="fields">
|
15 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
|
16 |
+
</li>
|
17 |
+
<li>
|
18 |
+
<label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
19 |
+
<div class="input-box">
|
20 |
+
<input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" />
|
21 |
+
</div>
|
22 |
+
</li>
|
23 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
24 |
+
<?php if ($_dob->isEnabled()): ?>
|
25 |
+
<li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
26 |
+
<?php endif ?>
|
27 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
28 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
29 |
+
<li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
30 |
+
<?php endif ?>
|
31 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
32 |
+
<?php if ($_gender->isEnabled()): ?>
|
33 |
+
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
|
34 |
+
<?php endif ?>
|
35 |
+
|
36 |
+
<?php if(true): ?>
|
37 |
+
<li class="hidden">
|
38 |
+
<input type="hidden" name="create_address" value="1" />
|
39 |
+
</li>
|
40 |
+
<li class="fields">
|
41 |
+
<div class="field">
|
42 |
+
<label for="company"><?php echo $this->__('Company') ?></label>
|
43 |
+
<div class="input-box">
|
44 |
+
<input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
<div class="field">
|
48 |
+
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
49 |
+
<div class="input-box">
|
50 |
+
<input type="tel" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
</li>
|
54 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
55 |
+
<li class="wide">
|
56 |
+
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
57 |
+
<div class="input-box">
|
58 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(0)) ?>" title="<?php echo $this->quoteEscape($this->__('Street Address')) ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
|
59 |
+
</div>
|
60 |
+
</li>
|
61 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
62 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
63 |
+
<li class="wide">
|
64 |
+
<label for="billing:street<?php echo $_i ?>"><?php echo $this->__('Street Address %s', $_i) ?></label>
|
65 |
+
<div class="input-box">
|
66 |
+
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i - 1)) ?>" title="<?php echo $this->quoteEscape($this->__('Street Address %s', $_i)) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
67 |
+
</div>
|
68 |
+
</li>
|
69 |
+
<?php endfor; ?>
|
70 |
+
<li class="fields">
|
71 |
+
<div class="field">
|
72 |
+
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
73 |
+
<div class="input-box">
|
74 |
+
<select id="region_id" name="region_id" title="<?php echo $this->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;">
|
75 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
76 |
+
</select>
|
77 |
+
<script type="text/javascript">
|
78 |
+
//<![CDATA[
|
79 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
|
80 |
+
//]]>
|
81 |
+
</script>
|
82 |
+
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
<div class="field">
|
86 |
+
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
87 |
+
<div class="input-box">
|
88 |
+
<select id="city_id" name="city_id" title="<?php echo $this->__('City') ?>" class="validate-select" style="display:none;">
|
89 |
+
<option value=""><?php echo $this->__('Please select City') ?></option>
|
90 |
+
</select>
|
91 |
+
<script type="text/javascript">
|
92 |
+
//<![CDATA[
|
93 |
+
$('city_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getCityId() ?>");
|
94 |
+
//]]>
|
95 |
+
</script>
|
96 |
+
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->quoteEscape($this->__('City')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
|
97 |
+
</div>
|
98 |
+
</div>
|
99 |
+
</li>
|
100 |
+
<li class="fields">
|
101 |
+
<div class="field">
|
102 |
+
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
103 |
+
<div class="input-box">
|
104 |
+
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->quoteEscape($this->__('Zip/Postal Code')) ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
<div class="field">
|
108 |
+
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
109 |
+
<div class="input-box">
|
110 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
</li>
|
114 |
+
<li class="hidden">
|
115 |
+
<input type="hidden" name="default_billing" value="1" />
|
116 |
+
<input type="hidden" name="default_shipping" value="1" />
|
117 |
+
</li>
|
118 |
+
<?php endif; ?>
|
119 |
+
<li class="fields">
|
120 |
+
<div class="field">
|
121 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
122 |
+
<div class="input-box">
|
123 |
+
<input type="password" name="password" id="password" title="<?php echo $this->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
|
124 |
+
</div>
|
125 |
+
</div>
|
126 |
+
<div class="field">
|
127 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
|
128 |
+
<div class="input-box">
|
129 |
+
<input type="password" name="confirmation" title="<?php echo $this->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
|
130 |
+
</div>
|
131 |
+
</div>
|
132 |
+
</li>
|
133 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
134 |
+
<?php if ($this->isNewsletterEnabled()): ?>
|
135 |
+
<li class="control">
|
136 |
+
<div class="input-box">
|
137 |
+
<input type="checkbox" name="is_subscribed" title="<?php echo $this->quoteEscape($this->__('Sign Up for Newsletter')) ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
|
138 |
+
</div>
|
139 |
+
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
140 |
+
</li>
|
141 |
+
<?php endif ?>
|
142 |
+
<?php echo $this->getChildHtml('persistent.remember.me'); ?>
|
143 |
+
</ul>
|
144 |
+
<?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
|
145 |
+
</div>
|
146 |
+
<div class="buttons-set">
|
147 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
148 |
+
<button type="submit" title="<?php echo $this->quoteEscape($this->__('Register')) ?>" class="button"><span><span><?php echo $this->__('Register') ?></span></span></button>
|
149 |
+
</div>
|
150 |
+
<?php if (Mage::helper('checkout')->isContextCheckout()): ?>
|
151 |
+
<input name="context" type="hidden" value="checkout" />
|
152 |
+
<?php endif; ?>
|
153 |
+
</form>
|
154 |
+
<script type="text/javascript">
|
155 |
+
//<![CDATA[
|
156 |
+
var dataForm = new VarienForm('form-validate', true);
|
157 |
+
<?php //if($this->getShowAddressFields(true)): ?>
|
158 |
+
<?php if(true): ?>
|
159 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
|
160 |
+
|
161 |
+
new CityUpdater('country', 'region_id', 'city', 'city_id', <?php echo Mage::helper('customaddress')->getCityJson() ?>);
|
162 |
+
|
163 |
+
<?php endif; ?>
|
164 |
+
//]]>
|
165 |
+
</script>
|
166 |
+
</div>
|
app/etc/modules/Magebuzz_Improvedaddress.xml
ADDED
@@ -0,0 +1,9 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Magebuzz_Improvedaddress>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Magebuzz_Improvedaddress>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/magebuzz/improvedaddress.js
ADDED
@@ -0,0 +1,88 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
CityUpdater = Class.create();
|
2 |
+
CityUpdater.prototype = {
|
3 |
+
initialize: function(countryEl, regionEl, cityTextEl, citySelectEl, cities) {
|
4 |
+
this.regionEl = $(regionEl);
|
5 |
+
this.cityTextEl = $(cityTextEl);
|
6 |
+
this.citySelectEl = $(citySelectEl);
|
7 |
+
this.cities = cities;
|
8 |
+
this.countryEl = $(countryEl);
|
9 |
+
//if (this.citySelectEl.options.length<=1) {
|
10 |
+
this.update();
|
11 |
+
// }
|
12 |
+
|
13 |
+
this.regionEl.changeUpdater = this.update.bind(this);
|
14 |
+
|
15 |
+
Event.observe(this.regionEl, 'change', this.update.bind(this));
|
16 |
+
Event.observe(this.countryEl, 'change', this.update.bind(this));
|
17 |
+
Event.observe(this.citySelectEl, 'change', this.updateCity.bind(this));
|
18 |
+
},
|
19 |
+
|
20 |
+
update: function() {
|
21 |
+
if (this.cities[this.regionEl.value]) {
|
22 |
+
var i, option, city, def;
|
23 |
+
def = this.citySelectEl.getAttribute('defaultValue');
|
24 |
+
if (this.cityTextEl) {
|
25 |
+
if (!def) {
|
26 |
+
def = this.cityTextEl.value.toLowerCase();
|
27 |
+
}
|
28 |
+
////need to comment this to avoid issue when saving address without touching city field
|
29 |
+
//this.cityTextEl.value = '';
|
30 |
+
}
|
31 |
+
|
32 |
+
this.citySelectEl.options.length = 1;
|
33 |
+
for (cityId in this.cities[this.regionEl.value]) {
|
34 |
+
city = this.cities[this.regionEl.value][cityId];
|
35 |
+
|
36 |
+
option = document.createElement('OPTION');
|
37 |
+
option.value = city.code;
|
38 |
+
option.text = city.name.stripTags();
|
39 |
+
option.title = city.name;
|
40 |
+
|
41 |
+
if (this.citySelectEl.options.add) {
|
42 |
+
this.citySelectEl.options.add(option);
|
43 |
+
} else {
|
44 |
+
this.citySelectEl.appendChild(option);
|
45 |
+
}
|
46 |
+
|
47 |
+
if (cityId==def || (city.name && city.name==def) ||
|
48 |
+
(city.name && city.code.toLowerCase()==def)
|
49 |
+
) {
|
50 |
+
this.citySelectEl.value = city.code;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if (this.cityTextEl) {
|
55 |
+
this.cityTextEl.style.display = 'none';
|
56 |
+
}
|
57 |
+
this.citySelectEl.style.display = '';
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
this.citySelectEl.options.length = 1;
|
61 |
+
if (this.cityTextEl) {
|
62 |
+
this.cityTextEl.style.display = '';
|
63 |
+
}
|
64 |
+
this.citySelectEl.style.display = 'none';
|
65 |
+
Validation.reset(this.citySelectEl);
|
66 |
+
}
|
67 |
+
},
|
68 |
+
|
69 |
+
updateCity: function() {
|
70 |
+
var sIndex = this.citySelectEl.selectedIndex;
|
71 |
+
this.cityTextEl.value = this.citySelectEl.options[sIndex].value;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
function reloadRegion(countryId, regionUrl) {
|
76 |
+
loader = new varienLoader(true);
|
77 |
+
loader.load(regionUrl, {country_id: countryId}, onReloadRegion.bind(this));
|
78 |
+
}
|
79 |
+
|
80 |
+
function onReloadRegion(serverResponse) {
|
81 |
+
if (!serverResponse)
|
82 |
+
return;
|
83 |
+
var data = eval('(' + serverResponse + ')');
|
84 |
+
var regionSelect = $('region_id');
|
85 |
+
if (regionSelect && data.success) {
|
86 |
+
regionSelect.update(data.options)
|
87 |
+
}
|
88 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>magebuzz_region_city_manager</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Region & City Manager Magento extension</summary>
|
10 |
+
<description>Extension allows admin to manage city and regions for any countries.</description>
|
11 |
+
<notes>- Manage Regions & Cities in backend
|
12 |
+
- Show drop down in all address forms</notes>
|
13 |
+
<authors><author><name>Magebuzz</name><user>magebuzz</user><email>magebuzz@gmail.com</email></author></authors>
|
14 |
+
<date>2015-12-18</date>
|
15 |
+
<time>09:39:13</time>
|
16 |
+
<contents><target name="magelocal"><dir name="Magebuzz"><dir name="Improvedaddress"><dir name="Block"><dir name="Adminhtml"><dir name="City"><dir name="Edit"><file name="Form.php" hash="dcda276a93b474b8014849535d1cba4c"/><dir name="Tab"><file name="Form.php" hash="ead1f0fa5246fcfda933ad5a0ebbaebd"/></dir><file name="Tabs.php" hash="042187b9c1ccbcd9411d9c78f409b34d"/></dir><file name="Edit.php" hash="7ba23228a62aa71f6de22b2894c16e8c"/><file name="Grid.php" hash="e6a70f5dc2113c6a16467e6d0a60a569"/></dir><file name="City.php" hash="8d2c1795e88ae02b0d3ebcbc2aaacb7b"/><dir name="Customer"><dir name="Edit"><dir name="Renderer"><file name="City.php" hash="7ec569dfcd90f7eafdba5d04994a3a2a"/></dir><dir name="Tab"><file name="Addresses.php" hash="9b6741f10a44c1e3f3f861fbb0b07e35"/></dir></dir></dir><dir name="Region"><dir name="Edit"><file name="Form.php" hash="7daa45f34860e1db3c65e7fe720a45f6"/><dir name="Tab"><file name="Form.php" hash="ea1989156b92d8d03e603d5bcaae128c"/></dir><file name="Tabs.php" hash="217d3dbf8f90892ebdbdadc6c01ab429"/></dir><file name="Edit.php" hash="df800b3677bac87e25fa847fc00f2575"/><file name="Grid.php" hash="6590e756e51d6384f1e932216310a32d"/><dir name="Renderer"><file name="Name.php" hash="0ccadb40cdfb927e77c4d758785edf5d"/></dir></dir><file name="Region.php" hash="4d26a6cd71212d846e494bd6d59f2e39"/><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Billing"><file name="Address.php" hash="4675b5fba9aefca0e3337e4803fb4a86"/></dir><dir name="Shipping"><file name="Address.php" hash="c1bd32f732bb4ac490d87294a50782e1"/></dir></dir></dir></dir></dir><file name="Improvedaddress.php" hash="0df8ad915f1ccc91bc88f77eb2d316c3"/></dir><dir name="Helper"><file name="Data.php" hash="f1386b985a058fcb85f367c3a2dff843"/></dir><dir name="Model"><file name="City.php" hash="a01443ccf840417eaf7c1b50169d2549"/><dir name="Customer"><dir name="Renderer"><file name="City.php" hash="3cf2a59c3461a078960a16b71760f9d4"/></dir></dir><file name="Improvedaddress.php" hash="6a898fa88a7a6e8aac9bd5d2ab90ed02"/><dir name="Mysql4"><dir name="City"><file name="Collection.php" hash="e3080a9d7ec8973ece4953263c20aab9"/></dir><file name="City.php" hash="57708887d006f2eb8b9811fc6ead75ce"/><dir name="Improvedaddress"><file name="Collection.php" hash="ef941e929454229bb80cbaea81300dc7"/></dir><file name="Improvedaddress.php" hash="1849b8a441bc4fc2e5985990c712e688"/><dir name="Region"><file name="Collection.php" hash="acdf2c915672899322d104ad5feaa7c0"/></dir><file name="Region.php" hash="78b9e9ba3f277bb53f080229c6dc5293"/><dir name="Subdistrict"><file name="Collection.php" hash="11d715c351dd46df6393680d6caa0195"/></dir><file name="Subdistrict.php" hash="8e774b4fac648860b39e7c13a469b08c"/></dir><file name="Observer.php" hash="e3f42a51323ea29d4b6031c1159d0cc1"/><file name="Region.php" hash="ba13d15cd1f1f11eec1740f05bebe41b"/><dir name="Resource"><dir name="Region"><file name="Collection.php" hash="5ce8f482f0ee9b1a9c92af2d5aaba048"/></dir><file name="Region.php" hash="3cdbac9ad1bb1d6bd99a660ac9c251a1"/></dir><file name="Status.php" hash="a4d262c77e3220a7c2e6219d16d2f8c5"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Improvedaddress"><file name="CityController.php" hash="c6296eba3d620b1aa7dbd4bf54338f67"/><file name="DataController.php" hash="66d2e5c412e8aa03f67a72cf6a120f33"/><file name="JsonController.php" hash="f2017b51e5b04f7f6b1c2e1084b2f45b"/><file name="RegionController.php" hash="6f889f3fb73cf4e5e620da4f6dbfd6fa"/></dir></dir><file name="IndexController.php" hash="2f5d1383ea1a56df7f59fe4a9386b252"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7c6e657606f1ff4504da7f6fbb37896e"/><file name="config.xml" hash="6e53656d6840c915420bcddcd6f0c364"/></dir><dir name="sql"><dir name="improvedaddress_setup"><file name="mysql4-install-0.1.0.php" hash="b64813e9082d93501ad452926b128bce"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="a4e493f5d24cd118f072ff76ab1b3c5f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="improvedaddress.xml" hash="7136fed209b61392c02fcd53620d96f4"/></dir><dir name="template"><dir name="improvedaddress"><dir name="checkout"><dir name="onepage"><file name="billing.phtml" hash="7df1f60c63366b9182d0b6eb4af64c38"/><file name="shipping.phtml" hash="4c602cd8e110e210a20ff67c97ef1162"/></dir><file name="onepage.phtml" hash="5c75227683cf256f9081e7d3618f187e"/></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="c1045b6d95438f25ff49c3a699f1b320"/></dir><dir name="form"><file name="register.phtml" hash="9aae7dbd8e34ce0ba91862fbab5bc274"/></dir></dir></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="template"><dir name="improvedaddress"><dir name="checkout"><file name="onepage.phtml" hash="40f8620db5de9d62be12746814d4f189"/></dir><dir name="customer"><dir name="form"><file name="register.phtml" hash="167b298b7bf104d15af41b19cb57ca01"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="improvedaddress.xml" hash="07fc315870a1a88efe3c1ab9fa58da41"/></dir><dir name="template"><dir name="improvedaddress"><dir name="customer"><dir name="tab"><file name="addresses.phtml" hash="cd2b773154041fa899b5f4abd6036fa4"/></dir></dir><dir name="sales"><dir name="order"><dir name="create"><dir name="form"><file name="address.phtml" hash="a39f4d9908495608e142fcfc62d88eee"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="magebuzz"><file name="improvedaddress.js" hash="adbc519348b4643c2ed7da134c2949a5"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="magebuzz"><dir name="improvedaddress"><dir name="js"><file name="opcheckout.js" hash="b93d0a4b3f96ee9af6851aea0b08dfa3"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magebuzz_Improvedaddress.xml" hash="e0ecc597cfbd6d6fe1da461959293097"/></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|
skin/frontend/base/default/magebuzz/improvedaddress/js/opcheckout.js
ADDED
@@ -0,0 +1,988 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|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
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/**
|
2 |
+
* Magento
|
3 |
+
*
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
7 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
8 |
+
* It is also available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/afl-3.0.php
|
10 |
+
* If you did not receive a copy of the license and are unable to
|
11 |
+
* obtain it through the world-wide-web, please send an email
|
12 |
+
* to license@magento.com so we can send you a copy immediately.
|
13 |
+
*
|
14 |
+
* DISCLAIMER
|
15 |
+
*
|
16 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
17 |
+
* versions in the future. If you wish to customize Magento for your
|
18 |
+
* needs please refer to http://www.magento.com for more information.
|
19 |
+
*
|
20 |
+
* @category design
|
21 |
+
* @package base_default
|
22 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
23 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
24 |
+
*/
|
25 |
+
var Checkout = Class.create();
|
26 |
+
Checkout.prototype = {
|
27 |
+
initialize: function(accordion, urls){
|
28 |
+
this.accordion = accordion;
|
29 |
+
this.progressUrl = urls.progress;
|
30 |
+
this.reviewUrl = urls.review;
|
31 |
+
this.saveMethodUrl = urls.saveMethod;
|
32 |
+
this.failureUrl = urls.failure;
|
33 |
+
this.billingForm = false;
|
34 |
+
this.shippingForm= false;
|
35 |
+
this.syncBillingShipping = false;
|
36 |
+
this.method = '';
|
37 |
+
this.payment = '';
|
38 |
+
this.loadWaiting = false;
|
39 |
+
this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'];
|
40 |
+
//We use billing as beginning step since progress bar tracks from billing
|
41 |
+
this.currentStep = 'billing';
|
42 |
+
|
43 |
+
this.accordion.sections.each(function(section) {
|
44 |
+
Event.observe($(section).down('.step-title'), 'click', this._onSectionClick.bindAsEventListener(this));
|
45 |
+
}.bind(this));
|
46 |
+
|
47 |
+
this.accordion.disallowAccessToNextSections = true;
|
48 |
+
},
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Section header click handler
|
52 |
+
*
|
53 |
+
* @param event
|
54 |
+
*/
|
55 |
+
_onSectionClick: function(event) {
|
56 |
+
var section = $(Event.element(event).up().up());
|
57 |
+
if (section.hasClassName('allow')) {
|
58 |
+
Event.stop(event);
|
59 |
+
this.gotoSection(section.readAttribute('id').replace('opc-', ''), false);
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
},
|
63 |
+
|
64 |
+
ajaxFailure: function(){
|
65 |
+
location.href = this.failureUrl;
|
66 |
+
},
|
67 |
+
|
68 |
+
reloadProgressBlock: function(toStep) {
|
69 |
+
this.reloadStep(toStep);
|
70 |
+
if (this.syncBillingShipping) {
|
71 |
+
this.syncBillingShipping = false;
|
72 |
+
this.reloadStep('shipping');
|
73 |
+
}
|
74 |
+
},
|
75 |
+
|
76 |
+
reloadStep: function(prevStep) {
|
77 |
+
var updater = new Ajax.Updater(prevStep + '-progress-opcheckout', this.progressUrl, {
|
78 |
+
method:'get',
|
79 |
+
onFailure:this.ajaxFailure.bind(this),
|
80 |
+
onComplete: function(){
|
81 |
+
this.checkout.resetPreviousSteps();
|
82 |
+
},
|
83 |
+
parameters:prevStep ? { prevStep:prevStep } : null
|
84 |
+
});
|
85 |
+
},
|
86 |
+
|
87 |
+
reloadReviewBlock: function(){
|
88 |
+
var updater = new Ajax.Updater('checkout-review-load', this.reviewUrl, {method: 'get', onFailure: this.ajaxFailure.bind(this)});
|
89 |
+
},
|
90 |
+
|
91 |
+
_disableEnableAll: function(element, isDisabled) {
|
92 |
+
var descendants = element.descendants();
|
93 |
+
for (var k in descendants) {
|
94 |
+
descendants[k].disabled = isDisabled;
|
95 |
+
}
|
96 |
+
element.disabled = isDisabled;
|
97 |
+
},
|
98 |
+
|
99 |
+
setLoadWaiting: function(step, keepDisabled) {
|
100 |
+
if (step) {
|
101 |
+
if (this.loadWaiting) {
|
102 |
+
this.setLoadWaiting(false);
|
103 |
+
}
|
104 |
+
var container = $(step+'-buttons-container');
|
105 |
+
container.addClassName('disabled');
|
106 |
+
container.setStyle({opacity:.5});
|
107 |
+
this._disableEnableAll(container, true);
|
108 |
+
Element.show(step+'-please-wait');
|
109 |
+
} else {
|
110 |
+
if (this.loadWaiting) {
|
111 |
+
var container = $(this.loadWaiting+'-buttons-container');
|
112 |
+
var isDisabled = (keepDisabled ? true : false);
|
113 |
+
if (!isDisabled) {
|
114 |
+
container.removeClassName('disabled');
|
115 |
+
container.setStyle({opacity:1});
|
116 |
+
}
|
117 |
+
this._disableEnableAll(container, isDisabled);
|
118 |
+
Element.hide(this.loadWaiting+'-please-wait');
|
119 |
+
}
|
120 |
+
}
|
121 |
+
this.loadWaiting = step;
|
122 |
+
},
|
123 |
+
|
124 |
+
gotoSection: function (section, reloadProgressBlock) {
|
125 |
+
|
126 |
+
if (reloadProgressBlock) {
|
127 |
+
this.reloadProgressBlock(this.currentStep);
|
128 |
+
}
|
129 |
+
this.currentStep = section;
|
130 |
+
var sectionElement = $('opc-' + section);
|
131 |
+
sectionElement.addClassName('allow');
|
132 |
+
this.accordion.openSection('opc-' + section);
|
133 |
+
if(!reloadProgressBlock) {
|
134 |
+
this.resetPreviousSteps();
|
135 |
+
}
|
136 |
+
},
|
137 |
+
|
138 |
+
resetPreviousSteps: function () {
|
139 |
+
var stepIndex = this.steps.indexOf(this.currentStep);
|
140 |
+
|
141 |
+
//Clear other steps if already populated through javascript
|
142 |
+
for (var i = stepIndex; i < this.steps.length; i++) {
|
143 |
+
var nextStep = this.steps[i];
|
144 |
+
var progressDiv = nextStep + '-progress-opcheckout';
|
145 |
+
if ($(progressDiv)) {
|
146 |
+
//Remove the link
|
147 |
+
$(progressDiv).select('.changelink').each(function (item) {
|
148 |
+
item.remove();
|
149 |
+
});
|
150 |
+
$(progressDiv).select('dt').each(function (item) {
|
151 |
+
item.removeClassName('complete');
|
152 |
+
});
|
153 |
+
//Remove the content
|
154 |
+
$(progressDiv).select('dd.complete').each(function (item) {
|
155 |
+
item.remove();
|
156 |
+
});
|
157 |
+
}
|
158 |
+
}
|
159 |
+
},
|
160 |
+
|
161 |
+
changeSection: function (section) {
|
162 |
+
var changeStep = section.replace('opc-', '');
|
163 |
+
this.gotoSection(changeStep, false);
|
164 |
+
},
|
165 |
+
|
166 |
+
setMethod: function(){
|
167 |
+
if ($('login:guest') && $('login:guest').checked) {
|
168 |
+
this.method = 'guest';
|
169 |
+
var request = new Ajax.Request(
|
170 |
+
this.saveMethodUrl,
|
171 |
+
{method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'guest'}}
|
172 |
+
);
|
173 |
+
Element.hide('register-customer-password');
|
174 |
+
this.gotoSection('billing', true);
|
175 |
+
}
|
176 |
+
else if($('login:register') && ($('login:register').checked || $('login:register').type == 'hidden')) {
|
177 |
+
this.method = 'register';
|
178 |
+
var request = new Ajax.Request(
|
179 |
+
this.saveMethodUrl,
|
180 |
+
{method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'register'}}
|
181 |
+
);
|
182 |
+
Element.show('register-customer-password');
|
183 |
+
this.gotoSection('billing', true);
|
184 |
+
}
|
185 |
+
else{
|
186 |
+
alert(Translator.translate('Please choose to register or to checkout as a guest').stripTags());
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
document.body.fire('login:setMethod', {method : this.method});
|
190 |
+
},
|
191 |
+
|
192 |
+
setBilling: function() {
|
193 |
+
if (($('billing:use_for_shipping_yes')) && ($('billing:use_for_shipping_yes').checked)) {
|
194 |
+
shipping.syncWithBilling();
|
195 |
+
$('opc-shipping').addClassName('allow');
|
196 |
+
this.gotoSection('shipping_method', true);
|
197 |
+
} else if (($('billing:use_for_shipping_no')) && ($('billing:use_for_shipping_no').checked)) {
|
198 |
+
$('shipping:same_as_billing').checked = false;
|
199 |
+
this.gotoSection('shipping', true);
|
200 |
+
} else {
|
201 |
+
$('shipping:same_as_billing').checked = true;
|
202 |
+
this.gotoSection('shipping', true);
|
203 |
+
}
|
204 |
+
|
205 |
+
// this refreshes the checkout progress column
|
206 |
+
|
207 |
+
// if ($('billing:use_for_shipping') && $('billing:use_for_shipping').checked){
|
208 |
+
// shipping.syncWithBilling();
|
209 |
+
// //this.setShipping();
|
210 |
+
// //shipping.save();
|
211 |
+
// $('opc-shipping').addClassName('allow');
|
212 |
+
// this.gotoSection('shipping_method');
|
213 |
+
// } else {
|
214 |
+
// $('shipping:same_as_billing').checked = false;
|
215 |
+
// this.gotoSection('shipping');
|
216 |
+
// }
|
217 |
+
// this.reloadProgressBlock();
|
218 |
+
// //this.accordion.openNextSection(true);
|
219 |
+
},
|
220 |
+
|
221 |
+
setShipping: function() {
|
222 |
+
//this.nextStep();
|
223 |
+
this.gotoSection('shipping_method', true);
|
224 |
+
//this.accordion.openNextSection(true);
|
225 |
+
},
|
226 |
+
|
227 |
+
setShippingMethod: function() {
|
228 |
+
//this.nextStep();
|
229 |
+
this.gotoSection('payment', true);
|
230 |
+
//this.accordion.openNextSection(true);
|
231 |
+
},
|
232 |
+
|
233 |
+
setPayment: function() {
|
234 |
+
//this.nextStep();
|
235 |
+
this.gotoSection('review', true);
|
236 |
+
//this.accordion.openNextSection(true);
|
237 |
+
},
|
238 |
+
|
239 |
+
setReview: function() {
|
240 |
+
this.reloadProgressBlock();
|
241 |
+
//this.nextStep();
|
242 |
+
//this.accordion.openNextSection(true);
|
243 |
+
},
|
244 |
+
|
245 |
+
back: function(){
|
246 |
+
if (this.loadWaiting) return;
|
247 |
+
//Navigate back to the previous available step
|
248 |
+
var stepIndex = this.steps.indexOf(this.currentStep);
|
249 |
+
var section = this.steps[--stepIndex];
|
250 |
+
var sectionElement = $('opc-' + section);
|
251 |
+
|
252 |
+
//Traverse back to find the available section. Ex Virtual product does not have shipping section
|
253 |
+
while (sectionElement === null && stepIndex > 0) {
|
254 |
+
--stepIndex;
|
255 |
+
section = this.steps[stepIndex];
|
256 |
+
sectionElement = $('opc-' + section);
|
257 |
+
}
|
258 |
+
this.changeSection('opc-' + section);
|
259 |
+
},
|
260 |
+
|
261 |
+
setStepResponse: function(response){
|
262 |
+
if (response.update_section) {
|
263 |
+
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
|
264 |
+
}
|
265 |
+
if (response.allow_sections) {
|
266 |
+
response.allow_sections.each(function(e){
|
267 |
+
$('opc-'+e).addClassName('allow');
|
268 |
+
});
|
269 |
+
}
|
270 |
+
|
271 |
+
if(response.duplicateBillingInfo)
|
272 |
+
{
|
273 |
+
this.syncBillingShipping = true;
|
274 |
+
shipping.setSameAsBilling(true);
|
275 |
+
}
|
276 |
+
|
277 |
+
if (response.goto_section) {
|
278 |
+
this.gotoSection(response.goto_section, true);
|
279 |
+
return true;
|
280 |
+
}
|
281 |
+
if (response.redirect) {
|
282 |
+
location.href = response.redirect;
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
// billing
|
290 |
+
var Billing = Class.create();
|
291 |
+
Billing.prototype = {
|
292 |
+
initialize: function(form, addressUrl, saveUrl){
|
293 |
+
this.form = form;
|
294 |
+
if ($(this.form)) {
|
295 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
296 |
+
}
|
297 |
+
this.addressUrl = addressUrl;
|
298 |
+
this.saveUrl = saveUrl;
|
299 |
+
this.onAddressLoad = this.fillForm.bindAsEventListener(this);
|
300 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
301 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
302 |
+
},
|
303 |
+
|
304 |
+
setAddress: function(addressId){
|
305 |
+
if (addressId) {
|
306 |
+
request = new Ajax.Request(
|
307 |
+
this.addressUrl+addressId,
|
308 |
+
{method:'get', onSuccess: this.onAddressLoad, onFailure: checkout.ajaxFailure.bind(checkout)}
|
309 |
+
);
|
310 |
+
}
|
311 |
+
else {
|
312 |
+
this.fillForm(false);
|
313 |
+
}
|
314 |
+
},
|
315 |
+
|
316 |
+
newAddress: function(isNew){
|
317 |
+
if (isNew) {
|
318 |
+
this.resetSelectedAddress();
|
319 |
+
Element.show('billing-new-address-form');
|
320 |
+
} else {
|
321 |
+
Element.hide('billing-new-address-form');
|
322 |
+
}
|
323 |
+
},
|
324 |
+
|
325 |
+
resetSelectedAddress: function(){
|
326 |
+
var selectElement = $('billing-address-select')
|
327 |
+
if (selectElement) {
|
328 |
+
selectElement.value='';
|
329 |
+
}
|
330 |
+
},
|
331 |
+
|
332 |
+
fillForm: function(transport){
|
333 |
+
var elementValues = {};
|
334 |
+
if (transport && transport.responseText){
|
335 |
+
try{
|
336 |
+
elementValues = eval('(' + transport.responseText + ')');
|
337 |
+
}
|
338 |
+
catch (e) {
|
339 |
+
elementValues = {};
|
340 |
+
}
|
341 |
+
}
|
342 |
+
else{
|
343 |
+
this.resetSelectedAddress();
|
344 |
+
}
|
345 |
+
arrElements = Form.getElements(this.form);
|
346 |
+
for (var elemIndex in arrElements) {
|
347 |
+
if (arrElements[elemIndex].id) {
|
348 |
+
var fieldName = arrElements[elemIndex].id.replace(/^billing:/, '');
|
349 |
+
arrElements[elemIndex].value = elementValues[fieldName] ? elementValues[fieldName] : '';
|
350 |
+
if (fieldName == 'country_id' && billingForm){
|
351 |
+
billingForm.elementChildLoad(arrElements[elemIndex]);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
}
|
355 |
+
},
|
356 |
+
|
357 |
+
setUseForShipping: function(flag) {
|
358 |
+
$('shipping:same_as_billing').checked = flag;
|
359 |
+
},
|
360 |
+
|
361 |
+
save: function(){
|
362 |
+
if (checkout.loadWaiting!=false) return;
|
363 |
+
|
364 |
+
var validator = new Validation(this.form);
|
365 |
+
if (validator.validate()) {
|
366 |
+
checkout.setLoadWaiting('billing');
|
367 |
+
|
368 |
+
// if ($('billing:use_for_shipping') && $('billing:use_for_shipping').checked) {
|
369 |
+
// $('billing:use_for_shipping').value=1;
|
370 |
+
// }
|
371 |
+
|
372 |
+
var request = new Ajax.Request(
|
373 |
+
this.saveUrl,
|
374 |
+
{
|
375 |
+
method: 'post',
|
376 |
+
onComplete: this.onComplete,
|
377 |
+
onSuccess: this.onSave,
|
378 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
379 |
+
parameters: Form.serialize(this.form)
|
380 |
+
}
|
381 |
+
);
|
382 |
+
}
|
383 |
+
},
|
384 |
+
|
385 |
+
resetLoadWaiting: function(transport){
|
386 |
+
checkout.setLoadWaiting(false);
|
387 |
+
document.body.fire('billing-request:completed', {transport: transport});
|
388 |
+
},
|
389 |
+
|
390 |
+
/**
|
391 |
+
This method recieves the AJAX response on success.
|
392 |
+
There are 3 options: error, redirect or html with shipping options.
|
393 |
+
*/
|
394 |
+
nextStep: function(transport){
|
395 |
+
if (transport && transport.responseText){
|
396 |
+
try{
|
397 |
+
response = eval('(' + transport.responseText + ')');
|
398 |
+
}
|
399 |
+
catch (e) {
|
400 |
+
response = {};
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
if (response.error){
|
405 |
+
if ((typeof response.message) == 'string') {
|
406 |
+
alert(response.message);
|
407 |
+
} else {
|
408 |
+
if (window.billingRegionUpdater) {
|
409 |
+
billingRegionUpdater.update();
|
410 |
+
}
|
411 |
+
|
412 |
+
alert(response.message.join("\n"));
|
413 |
+
}
|
414 |
+
|
415 |
+
return false;
|
416 |
+
}
|
417 |
+
|
418 |
+
checkout.setStepResponse(response);
|
419 |
+
payment.initWhatIsCvvListeners();
|
420 |
+
// DELETE
|
421 |
+
//alert('error: ' + response.error + ' / redirect: ' + response.redirect + ' / shipping_methods_html: ' + response.shipping_methods_html);
|
422 |
+
// This moves the accordion panels of one page checkout and updates the checkout progress
|
423 |
+
//checkout.setBilling();
|
424 |
+
}
|
425 |
+
}
|
426 |
+
|
427 |
+
// shipping
|
428 |
+
var Shipping = Class.create();
|
429 |
+
Shipping.prototype = {
|
430 |
+
initialize: function(form, addressUrl, saveUrl, methodsUrl){
|
431 |
+
this.form = form;
|
432 |
+
if ($(this.form)) {
|
433 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
434 |
+
}
|
435 |
+
this.addressUrl = addressUrl;
|
436 |
+
this.saveUrl = saveUrl;
|
437 |
+
this.methodsUrl = methodsUrl;
|
438 |
+
this.onAddressLoad = this.fillForm.bindAsEventListener(this);
|
439 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
440 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
441 |
+
},
|
442 |
+
|
443 |
+
setAddress: function(addressId){
|
444 |
+
if (addressId) {
|
445 |
+
request = new Ajax.Request(
|
446 |
+
this.addressUrl+addressId,
|
447 |
+
{method:'get', onSuccess: this.onAddressLoad, onFailure: checkout.ajaxFailure.bind(checkout)}
|
448 |
+
);
|
449 |
+
}
|
450 |
+
else {
|
451 |
+
this.fillForm(false);
|
452 |
+
}
|
453 |
+
},
|
454 |
+
|
455 |
+
newAddress: function(isNew){
|
456 |
+
if (isNew) {
|
457 |
+
this.resetSelectedAddress();
|
458 |
+
Element.show('shipping-new-address-form');
|
459 |
+
} else {
|
460 |
+
Element.hide('shipping-new-address-form');
|
461 |
+
}
|
462 |
+
shipping.setSameAsBilling(false);
|
463 |
+
},
|
464 |
+
|
465 |
+
resetSelectedAddress: function(){
|
466 |
+
var selectElement = $('shipping-address-select')
|
467 |
+
if (selectElement) {
|
468 |
+
selectElement.value='';
|
469 |
+
}
|
470 |
+
},
|
471 |
+
|
472 |
+
fillForm: function(transport){
|
473 |
+
var elementValues = {};
|
474 |
+
if (transport && transport.responseText){
|
475 |
+
try{
|
476 |
+
elementValues = eval('(' + transport.responseText + ')');
|
477 |
+
}
|
478 |
+
catch (e) {
|
479 |
+
elementValues = {};
|
480 |
+
}
|
481 |
+
}
|
482 |
+
else{
|
483 |
+
this.resetSelectedAddress();
|
484 |
+
}
|
485 |
+
arrElements = Form.getElements(this.form);
|
486 |
+
for (var elemIndex in arrElements) {
|
487 |
+
if (arrElements[elemIndex].id) {
|
488 |
+
var fieldName = arrElements[elemIndex].id.replace(/^shipping:/, '');
|
489 |
+
arrElements[elemIndex].value = elementValues[fieldName] ? elementValues[fieldName] : '';
|
490 |
+
if (fieldName == 'country_id' && shippingForm){
|
491 |
+
shippingForm.elementChildLoad(arrElements[elemIndex]);
|
492 |
+
}
|
493 |
+
}
|
494 |
+
}
|
495 |
+
},
|
496 |
+
|
497 |
+
setSameAsBilling: function(flag) {
|
498 |
+
$('shipping:same_as_billing').checked = flag;
|
499 |
+
// #5599. Also it hangs up, if the flag is not false
|
500 |
+
// $('billing:use_for_shipping_yes').checked = flag;
|
501 |
+
if (flag) {
|
502 |
+
this.syncWithBilling();
|
503 |
+
}
|
504 |
+
},
|
505 |
+
|
506 |
+
syncWithBilling: function () {
|
507 |
+
$('billing-address-select') && this.newAddress(!$('billing-address-select').value);
|
508 |
+
$('shipping:same_as_billing').checked = true;
|
509 |
+
if (!$('billing-address-select') || !$('billing-address-select').value) {
|
510 |
+
arrElements = Form.getElements(this.form);
|
511 |
+
for (var elemIndex in arrElements) {
|
512 |
+
if (arrElements[elemIndex].id) {
|
513 |
+
var sourceField = $(arrElements[elemIndex].id.replace(/^shipping:/, 'billing:'));
|
514 |
+
if (sourceField){
|
515 |
+
arrElements[elemIndex].value = sourceField.value;
|
516 |
+
}
|
517 |
+
}
|
518 |
+
}
|
519 |
+
//$('shipping:country_id').value = $('billing:country_id').value;
|
520 |
+
shippingRegionUpdater.update();
|
521 |
+
$('shipping:region_id').value = $('billing:region_id').value;
|
522 |
+
$('shipping:region').value = $('billing:region').value;
|
523 |
+
//shippingForm.elementChildLoad($('shipping:country_id'), this.setRegionValue.bind(this));
|
524 |
+
|
525 |
+
//change for custom address module
|
526 |
+
if (shippingCityUpdater) {
|
527 |
+
shippingCityUpdater.update();
|
528 |
+
$('shipping:city_id').value = $('billing:city_id').value;
|
529 |
+
$('shipping:city').value = $('billing:city').value;
|
530 |
+
}
|
531 |
+
// end of custom address module change
|
532 |
+
} else {
|
533 |
+
$('shipping-address-select').value = $('billing-address-select').value;
|
534 |
+
}
|
535 |
+
},
|
536 |
+
|
537 |
+
setRegionValue: function(){
|
538 |
+
$('shipping:region').value = $('billing:region').value;
|
539 |
+
},
|
540 |
+
|
541 |
+
save: function(){
|
542 |
+
if (checkout.loadWaiting!=false) return;
|
543 |
+
var validator = new Validation(this.form);
|
544 |
+
if (validator.validate()) {
|
545 |
+
checkout.setLoadWaiting('shipping');
|
546 |
+
var request = new Ajax.Request(
|
547 |
+
this.saveUrl,
|
548 |
+
{
|
549 |
+
method:'post',
|
550 |
+
onComplete: this.onComplete,
|
551 |
+
onSuccess: this.onSave,
|
552 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
553 |
+
parameters: Form.serialize(this.form)
|
554 |
+
}
|
555 |
+
);
|
556 |
+
}
|
557 |
+
},
|
558 |
+
|
559 |
+
resetLoadWaiting: function(transport){
|
560 |
+
checkout.setLoadWaiting(false);
|
561 |
+
},
|
562 |
+
|
563 |
+
nextStep: function(transport){
|
564 |
+
if (transport && transport.responseText){
|
565 |
+
try{
|
566 |
+
response = eval('(' + transport.responseText + ')');
|
567 |
+
}
|
568 |
+
catch (e) {
|
569 |
+
response = {};
|
570 |
+
}
|
571 |
+
}
|
572 |
+
if (response.error){
|
573 |
+
if ((typeof response.message) == 'string') {
|
574 |
+
alert(response.message);
|
575 |
+
} else {
|
576 |
+
if (window.shippingRegionUpdater) {
|
577 |
+
shippingRegionUpdater.update();
|
578 |
+
}
|
579 |
+
alert(response.message.join("\n"));
|
580 |
+
}
|
581 |
+
|
582 |
+
return false;
|
583 |
+
}
|
584 |
+
|
585 |
+
checkout.setStepResponse(response);
|
586 |
+
|
587 |
+
/*
|
588 |
+
var updater = new Ajax.Updater(
|
589 |
+
'checkout-shipping-method-load',
|
590 |
+
this.methodsUrl,
|
591 |
+
{method:'get', onSuccess: checkout.setShipping.bind(checkout)}
|
592 |
+
);
|
593 |
+
*/
|
594 |
+
//checkout.setShipping();
|
595 |
+
}
|
596 |
+
}
|
597 |
+
|
598 |
+
// shipping method
|
599 |
+
var ShippingMethod = Class.create();
|
600 |
+
ShippingMethod.prototype = {
|
601 |
+
initialize: function(form, saveUrl){
|
602 |
+
this.form = form;
|
603 |
+
if ($(this.form)) {
|
604 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
605 |
+
}
|
606 |
+
this.saveUrl = saveUrl;
|
607 |
+
this.validator = new Validation(this.form);
|
608 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
609 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
610 |
+
},
|
611 |
+
|
612 |
+
validate: function() {
|
613 |
+
var methods = document.getElementsByName('shipping_method');
|
614 |
+
if (methods.length==0) {
|
615 |
+
alert(Translator.translate('Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.').stripTags());
|
616 |
+
return false;
|
617 |
+
}
|
618 |
+
|
619 |
+
if(!this.validator.validate()) {
|
620 |
+
return false;
|
621 |
+
}
|
622 |
+
|
623 |
+
for (var i=0; i<methods.length; i++) {
|
624 |
+
if (methods[i].checked) {
|
625 |
+
return true;
|
626 |
+
}
|
627 |
+
}
|
628 |
+
alert(Translator.translate('Please specify shipping method.').stripTags());
|
629 |
+
return false;
|
630 |
+
},
|
631 |
+
|
632 |
+
save: function(){
|
633 |
+
|
634 |
+
if (checkout.loadWaiting!=false) return;
|
635 |
+
if (this.validate()) {
|
636 |
+
checkout.setLoadWaiting('shipping-method');
|
637 |
+
var request = new Ajax.Request(
|
638 |
+
this.saveUrl,
|
639 |
+
{
|
640 |
+
method:'post',
|
641 |
+
onComplete: this.onComplete,
|
642 |
+
onSuccess: this.onSave,
|
643 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
644 |
+
parameters: Form.serialize(this.form)
|
645 |
+
}
|
646 |
+
);
|
647 |
+
}
|
648 |
+
},
|
649 |
+
|
650 |
+
resetLoadWaiting: function(transport){
|
651 |
+
checkout.setLoadWaiting(false);
|
652 |
+
},
|
653 |
+
|
654 |
+
nextStep: function(transport){
|
655 |
+
if (transport && transport.responseText){
|
656 |
+
try{
|
657 |
+
response = eval('(' + transport.responseText + ')');
|
658 |
+
}
|
659 |
+
catch (e) {
|
660 |
+
response = {};
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
if (response.error) {
|
665 |
+
alert(response.message);
|
666 |
+
return false;
|
667 |
+
}
|
668 |
+
|
669 |
+
if (response.update_section) {
|
670 |
+
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
|
671 |
+
}
|
672 |
+
|
673 |
+
payment.initWhatIsCvvListeners();
|
674 |
+
|
675 |
+
if (response.goto_section) {
|
676 |
+
checkout.gotoSection(response.goto_section, true);
|
677 |
+
checkout.reloadProgressBlock();
|
678 |
+
return;
|
679 |
+
}
|
680 |
+
|
681 |
+
if (response.payment_methods_html) {
|
682 |
+
$('checkout-payment-method-load').update(response.payment_methods_html);
|
683 |
+
}
|
684 |
+
|
685 |
+
checkout.setShippingMethod();
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
|
690 |
+
// payment
|
691 |
+
var Payment = Class.create();
|
692 |
+
Payment.prototype = {
|
693 |
+
beforeInitFunc:$H({}),
|
694 |
+
afterInitFunc:$H({}),
|
695 |
+
beforeValidateFunc:$H({}),
|
696 |
+
afterValidateFunc:$H({}),
|
697 |
+
initialize: function(form, saveUrl){
|
698 |
+
this.form = form;
|
699 |
+
this.saveUrl = saveUrl;
|
700 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
701 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
702 |
+
},
|
703 |
+
|
704 |
+
addBeforeInitFunction : function(code, func) {
|
705 |
+
this.beforeInitFunc.set(code, func);
|
706 |
+
},
|
707 |
+
|
708 |
+
beforeInit : function() {
|
709 |
+
(this.beforeInitFunc).each(function(init){
|
710 |
+
(init.value)();;
|
711 |
+
});
|
712 |
+
},
|
713 |
+
|
714 |
+
init : function () {
|
715 |
+
this.beforeInit();
|
716 |
+
var elements = Form.getElements(this.form);
|
717 |
+
if ($(this.form)) {
|
718 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
719 |
+
}
|
720 |
+
var method = null;
|
721 |
+
for (var i=0; i<elements.length; i++) {
|
722 |
+
if (elements[i].name=='payment[method]') {
|
723 |
+
if (elements[i].checked) {
|
724 |
+
method = elements[i].value;
|
725 |
+
}
|
726 |
+
} else {
|
727 |
+
elements[i].disabled = true;
|
728 |
+
}
|
729 |
+
elements[i].setAttribute('autocomplete','off');
|
730 |
+
}
|
731 |
+
if (method) this.switchMethod(method);
|
732 |
+
this.afterInit();
|
733 |
+
},
|
734 |
+
|
735 |
+
addAfterInitFunction : function(code, func) {
|
736 |
+
this.afterInitFunc.set(code, func);
|
737 |
+
},
|
738 |
+
|
739 |
+
afterInit : function() {
|
740 |
+
(this.afterInitFunc).each(function(init){
|
741 |
+
(init.value)();
|
742 |
+
});
|
743 |
+
},
|
744 |
+
|
745 |
+
switchMethod: function(method){
|
746 |
+
if (this.currentMethod && $('payment_form_'+this.currentMethod)) {
|
747 |
+
this.changeVisible(this.currentMethod, true);
|
748 |
+
$('payment_form_'+this.currentMethod).fire('payment-method:switched-off', {method_code : this.currentMethod});
|
749 |
+
}
|
750 |
+
if ($('payment_form_'+method)){
|
751 |
+
this.changeVisible(method, false);
|
752 |
+
$('payment_form_'+method).fire('payment-method:switched', {method_code : method});
|
753 |
+
} else {
|
754 |
+
//Event fix for payment methods without form like "Check / Money order"
|
755 |
+
document.body.fire('payment-method:switched', {method_code : method});
|
756 |
+
}
|
757 |
+
if (method == 'free' && quoteBaseGrandTotal > 0.0001
|
758 |
+
&& !(($('use_reward_points') && $('use_reward_points').checked) || ($('use_customer_balance') && $('use_customer_balance').checked))
|
759 |
+
) {
|
760 |
+
if ($('p_method_' + method)) {
|
761 |
+
$('p_method_' + method).checked = false;
|
762 |
+
if ($('dt_method_' + method)) {
|
763 |
+
$('dt_method_' + method).hide();
|
764 |
+
}
|
765 |
+
if ($('dd_method_' + method)) {
|
766 |
+
$('dd_method_' + method).hide();
|
767 |
+
}
|
768 |
+
}
|
769 |
+
method == '';
|
770 |
+
}
|
771 |
+
if (method) {
|
772 |
+
this.lastUsedMethod = method;
|
773 |
+
}
|
774 |
+
this.currentMethod = method;
|
775 |
+
},
|
776 |
+
|
777 |
+
changeVisible: function(method, mode) {
|
778 |
+
var block = 'payment_form_' + method;
|
779 |
+
[block + '_before', block, block + '_after'].each(function(el) {
|
780 |
+
element = $(el);
|
781 |
+
if (element) {
|
782 |
+
element.style.display = (mode) ? 'none' : '';
|
783 |
+
element.select('input', 'select', 'textarea', 'button').each(function(field) {
|
784 |
+
field.disabled = mode;
|
785 |
+
});
|
786 |
+
}
|
787 |
+
});
|
788 |
+
},
|
789 |
+
|
790 |
+
addBeforeValidateFunction : function(code, func) {
|
791 |
+
this.beforeValidateFunc.set(code, func);
|
792 |
+
},
|
793 |
+
|
794 |
+
beforeValidate : function() {
|
795 |
+
var validateResult = true;
|
796 |
+
var hasValidation = false;
|
797 |
+
(this.beforeValidateFunc).each(function(validate){
|
798 |
+
hasValidation = true;
|
799 |
+
if ((validate.value)() == false) {
|
800 |
+
validateResult = false;
|
801 |
+
}
|
802 |
+
}.bind(this));
|
803 |
+
if (!hasValidation) {
|
804 |
+
validateResult = false;
|
805 |
+
}
|
806 |
+
return validateResult;
|
807 |
+
},
|
808 |
+
|
809 |
+
validate: function() {
|
810 |
+
var result = this.beforeValidate();
|
811 |
+
if (result) {
|
812 |
+
return true;
|
813 |
+
}
|
814 |
+
var methods = document.getElementsByName('payment[method]');
|
815 |
+
if (methods.length==0) {
|
816 |
+
alert(Translator.translate('Your order cannot be completed at this time as there is no payment methods available for it.').stripTags());
|
817 |
+
return false;
|
818 |
+
}
|
819 |
+
for (var i=0; i<methods.length; i++) {
|
820 |
+
if (methods[i].checked) {
|
821 |
+
return true;
|
822 |
+
}
|
823 |
+
}
|
824 |
+
result = this.afterValidate();
|
825 |
+
if (result) {
|
826 |
+
return true;
|
827 |
+
}
|
828 |
+
alert(Translator.translate('Please specify payment method.').stripTags());
|
829 |
+
return false;
|
830 |
+
},
|
831 |
+
|
832 |
+
addAfterValidateFunction : function(code, func) {
|
833 |
+
this.afterValidateFunc.set(code, func);
|
834 |
+
},
|
835 |
+
|
836 |
+
afterValidate : function() {
|
837 |
+
var validateResult = true;
|
838 |
+
var hasValidation = false;
|
839 |
+
(this.afterValidateFunc).each(function(validate){
|
840 |
+
hasValidation = true;
|
841 |
+
if ((validate.value)() == false) {
|
842 |
+
validateResult = false;
|
843 |
+
}
|
844 |
+
}.bind(this));
|
845 |
+
if (!hasValidation) {
|
846 |
+
validateResult = false;
|
847 |
+
}
|
848 |
+
return validateResult;
|
849 |
+
},
|
850 |
+
|
851 |
+
save: function(){
|
852 |
+
if (checkout.loadWaiting!=false) return;
|
853 |
+
var validator = new Validation(this.form);
|
854 |
+
if (this.validate() && validator.validate()) {
|
855 |
+
checkout.setLoadWaiting('payment');
|
856 |
+
var request = new Ajax.Request(
|
857 |
+
this.saveUrl,
|
858 |
+
{
|
859 |
+
method:'post',
|
860 |
+
onComplete: this.onComplete,
|
861 |
+
onSuccess: this.onSave,
|
862 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
863 |
+
parameters: Form.serialize(this.form)
|
864 |
+
}
|
865 |
+
);
|
866 |
+
}
|
867 |
+
},
|
868 |
+
|
869 |
+
resetLoadWaiting: function(){
|
870 |
+
checkout.setLoadWaiting(false);
|
871 |
+
},
|
872 |
+
|
873 |
+
nextStep: function(transport){
|
874 |
+
if (transport && transport.responseText){
|
875 |
+
try{
|
876 |
+
response = eval('(' + transport.responseText + ')');
|
877 |
+
}
|
878 |
+
catch (e) {
|
879 |
+
response = {};
|
880 |
+
}
|
881 |
+
}
|
882 |
+
/*
|
883 |
+
* if there is an error in payment, need to show error message
|
884 |
+
*/
|
885 |
+
if (response.error) {
|
886 |
+
if (response.fields) {
|
887 |
+
var fields = response.fields.split(',');
|
888 |
+
for (var i=0;i<fields.length;i++) {
|
889 |
+
var field = null;
|
890 |
+
if (field = $(fields[i])) {
|
891 |
+
Validation.ajaxError(field, response.error);
|
892 |
+
}
|
893 |
+
}
|
894 |
+
return;
|
895 |
+
}
|
896 |
+
if (typeof(response.message) == 'string') {
|
897 |
+
alert(response.message);
|
898 |
+
} else {
|
899 |
+
alert(response.error);
|
900 |
+
}
|
901 |
+
return;
|
902 |
+
}
|
903 |
+
|
904 |
+
checkout.setStepResponse(response);
|
905 |
+
|
906 |
+
//checkout.setPayment();
|
907 |
+
},
|
908 |
+
|
909 |
+
initWhatIsCvvListeners: function(){
|
910 |
+
$$('.cvv-what-is-this').each(function(element){
|
911 |
+
Event.observe(element, 'click', toggleToolTip);
|
912 |
+
});
|
913 |
+
}
|
914 |
+
}
|
915 |
+
|
916 |
+
var Review = Class.create();
|
917 |
+
Review.prototype = {
|
918 |
+
initialize: function(saveUrl, successUrl, agreementsForm){
|
919 |
+
this.saveUrl = saveUrl;
|
920 |
+
this.successUrl = successUrl;
|
921 |
+
this.agreementsForm = agreementsForm;
|
922 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
923 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
924 |
+
},
|
925 |
+
|
926 |
+
save: function(){
|
927 |
+
if (checkout.loadWaiting!=false) return;
|
928 |
+
checkout.setLoadWaiting('review');
|
929 |
+
var params = Form.serialize(payment.form);
|
930 |
+
if (this.agreementsForm) {
|
931 |
+
params += '&'+Form.serialize(this.agreementsForm);
|
932 |
+
}
|
933 |
+
params.save = true;
|
934 |
+
var request = new Ajax.Request(
|
935 |
+
this.saveUrl,
|
936 |
+
{
|
937 |
+
method:'post',
|
938 |
+
parameters:params,
|
939 |
+
onComplete: this.onComplete,
|
940 |
+
onSuccess: this.onSave,
|
941 |
+
onFailure: checkout.ajaxFailure.bind(checkout)
|
942 |
+
}
|
943 |
+
);
|
944 |
+
},
|
945 |
+
|
946 |
+
resetLoadWaiting: function(transport){
|
947 |
+
checkout.setLoadWaiting(false, this.isSuccess);
|
948 |
+
},
|
949 |
+
|
950 |
+
nextStep: function(transport){
|
951 |
+
if (transport && transport.responseText) {
|
952 |
+
try{
|
953 |
+
response = eval('(' + transport.responseText + ')');
|
954 |
+
}
|
955 |
+
catch (e) {
|
956 |
+
response = {};
|
957 |
+
}
|
958 |
+
if (response.redirect) {
|
959 |
+
this.isSuccess = true;
|
960 |
+
location.href = response.redirect;
|
961 |
+
return;
|
962 |
+
}
|
963 |
+
if (response.success) {
|
964 |
+
this.isSuccess = true;
|
965 |
+
window.location=this.successUrl;
|
966 |
+
}
|
967 |
+
else{
|
968 |
+
var msg = response.error_messages;
|
969 |
+
if (typeof(msg)=='object') {
|
970 |
+
msg = msg.join("\n");
|
971 |
+
}
|
972 |
+
if (msg) {
|
973 |
+
alert(msg);
|
974 |
+
}
|
975 |
+
}
|
976 |
+
|
977 |
+
if (response.update_section) {
|
978 |
+
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
|
979 |
+
}
|
980 |
+
|
981 |
+
if (response.goto_section) {
|
982 |
+
checkout.gotoSection(response.goto_section, true);
|
983 |
+
}
|
984 |
+
}
|
985 |
+
},
|
986 |
+
|
987 |
+
isSuccess: false
|
988 |
+
}
|