Version Notes
Clear magento cache after installing this extension and relogin to your magento admin.
Download this release
Release Info
Developer | Rohit Dhiman |
Extension | webskills_shippingrestriction |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip.php +17 -0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit.php +44 -0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Form.php +17 -0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Tab/Form.php +30 -0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Tabs.php +21 -0
- app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Grid.php +62 -0
- app/code/local/Webskills/Shippingrestriction/Block/Index.php +8 -0
- app/code/local/Webskills/Shippingrestriction/Block/Shippingzip.php +27 -0
- app/code/local/Webskills/Shippingrestriction/Helper/Data.php +5 -0
- app/code/local/Webskills/Shippingrestriction/Model/Mysql4/Shippingzip.php +8 -0
- app/code/local/Webskills/Shippingrestriction/Model/Mysql4/Shippingzip/Collection.php +12 -0
- app/code/local/Webskills/Shippingrestriction/Model/Observer.php +29 -0
- app/code/local/Webskills/Shippingrestriction/Model/Observer.php~ +29 -0
- app/code/local/Webskills/Shippingrestriction/Model/Shippingzip.php +12 -0
- app/code/local/Webskills/Shippingrestriction/controllers/Adminhtml/ShippingzipController.php +165 -0
- app/code/local/Webskills/Shippingrestriction/controllers/IndexController.php +43 -0
- app/code/local/Webskills/Shippingrestriction/controllers/IndexController.php~ +43 -0
- app/code/local/Webskills/Shippingrestriction/controllers/ShippingzipController.php +22 -0
- app/code/local/Webskills/Shippingrestriction/etc/config.xml +138 -0
- app/code/local/Webskills/Shippingrestriction/sql/shippingrestriction_setup/mysql4-install-0.1.0.php +14 -0
- app/design/adminhtml/default/default/layout/shippingrestriction.xml +8 -0
- app/design/frontend/base/default/layout/shippingrestriction.xml +20 -0
- app/design/frontend/base/default/template/shippingrestriction/index.phtml +37 -0
- app/design/frontend/base/default/template/shippingrestriction/shippingzip.phtml +33 -0
- app/etc/modules/Webskills_Shippingrestriction.xml +10 -0
- package.xml +21 -0
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
|
9 |
+
$this->_controller = "adminhtml_shippingzip";
|
10 |
+
$this->_blockGroup = "shippingrestriction";
|
11 |
+
$this->_headerText = Mage::helper("shippingrestriction")->__("Shippingzip Manager");
|
12 |
+
$this->_addButtonLabel = Mage::helper("shippingrestriction")->__("Add New Item");
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
parent::__construct();
|
9 |
+
$this->_objectId = "id";
|
10 |
+
$this->_blockGroup = "shippingrestriction";
|
11 |
+
$this->_controller = "adminhtml_shippingzip";
|
12 |
+
$this->_updateButton("save", "label", Mage::helper("shippingrestriction")->__("Save Item"));
|
13 |
+
$this->_updateButton("delete", "label", Mage::helper("shippingrestriction")->__("Delete Item"));
|
14 |
+
|
15 |
+
$this->_addButton("saveandcontinue", array(
|
16 |
+
"label" => Mage::helper("shippingrestriction")->__("Save And Continue Edit"),
|
17 |
+
"onclick" => "saveAndContinueEdit()",
|
18 |
+
"class" => "save",
|
19 |
+
), -100);
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
$this->_formScripts[] = "
|
24 |
+
|
25 |
+
function saveAndContinueEdit(){
|
26 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
27 |
+
}
|
28 |
+
";
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getHeaderText()
|
32 |
+
{
|
33 |
+
if( Mage::registry("shippingzip_data") && Mage::registry("shippingzip_data")->getId() ){
|
34 |
+
|
35 |
+
return Mage::helper("shippingrestriction")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("shippingzip_data")->getId()));
|
36 |
+
|
37 |
+
}
|
38 |
+
else{
|
39 |
+
|
40 |
+
return Mage::helper("shippingrestriction")->__("Add Item");
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Form.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
"id" => "edit_form",
|
8 |
+
"action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
|
9 |
+
"method" => "post",
|
10 |
+
"enctype" =>"multipart/form-data",
|
11 |
+
)
|
12 |
+
);
|
13 |
+
$form->setUseContainer(true);
|
14 |
+
$this->setForm($form);
|
15 |
+
return parent::_prepareForm();
|
16 |
+
}
|
17 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
3 |
+
{
|
4 |
+
protected function _prepareForm()
|
5 |
+
{
|
6 |
+
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset("shippingrestriction_form", array("legend"=>Mage::helper("shippingrestriction")->__("Item information")));
|
10 |
+
|
11 |
+
|
12 |
+
$fieldset->addField("zipcode", "text", array(
|
13 |
+
"label" => Mage::helper("shippingrestriction")->__("Zip Code"),
|
14 |
+
"class" => "required-entry",
|
15 |
+
"required" => true,
|
16 |
+
"name" => "zipcode",
|
17 |
+
));
|
18 |
+
|
19 |
+
|
20 |
+
if (Mage::getSingleton("adminhtml/session")->getShippingzipData())
|
21 |
+
{
|
22 |
+
$form->setValues(Mage::getSingleton("adminhtml/session")->getShippingzipData());
|
23 |
+
Mage::getSingleton("adminhtml/session")->setShippingzipData(null);
|
24 |
+
}
|
25 |
+
elseif(Mage::registry("shippingzip_data")) {
|
26 |
+
$form->setValues(Mage::registry("shippingzip_data")->getData());
|
27 |
+
}
|
28 |
+
return parent::_prepareForm();
|
29 |
+
}
|
30 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Edit/Tabs.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId("shippingzip_tabs");
|
8 |
+
$this->setDestElementId("edit_form");
|
9 |
+
$this->setTitle(Mage::helper("shippingrestriction")->__("Item Information"));
|
10 |
+
}
|
11 |
+
protected function _beforeToHtml()
|
12 |
+
{
|
13 |
+
$this->addTab("form_section", array(
|
14 |
+
"label" => Mage::helper("shippingrestriction")->__("Item Information"),
|
15 |
+
"title" => Mage::helper("shippingrestriction")->__("Item Information"),
|
16 |
+
"content" => $this->getLayout()->createBlock("shippingrestriction/adminhtml_shippingzip_edit_tab_form")->toHtml(),
|
17 |
+
));
|
18 |
+
return parent::_beforeToHtml();
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Adminhtml/Shippingzip/Grid.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webskills_Shippingrestriction_Block_Adminhtml_Shippingzip_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId("shippingzipGrid");
|
10 |
+
$this->setDefaultSort("id");
|
11 |
+
$this->setDefaultDir("DESC");
|
12 |
+
$this->setSaveParametersInSession(true);
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = Mage::getModel("shippingrestriction/shippingzip")->getCollection();
|
18 |
+
$this->setCollection($collection);
|
19 |
+
return parent::_prepareCollection();
|
20 |
+
}
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn("id", array(
|
24 |
+
"header" => Mage::helper("shippingrestriction")->__("ID"),
|
25 |
+
"align" =>"right",
|
26 |
+
"width" => "50px",
|
27 |
+
"type" => "number",
|
28 |
+
"index" => "id",
|
29 |
+
));
|
30 |
+
|
31 |
+
$this->addColumn("zipcode", array(
|
32 |
+
"header" => Mage::helper("shippingrestriction")->__("Zip Code"),
|
33 |
+
"index" => "zipcode",
|
34 |
+
));
|
35 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
|
36 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
|
37 |
+
|
38 |
+
return parent::_prepareColumns();
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getRowUrl($row)
|
42 |
+
{
|
43 |
+
return $this->getUrl("*/*/edit", array("id" => $row->getId()));
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
protected function _prepareMassaction()
|
49 |
+
{
|
50 |
+
$this->setMassactionIdField('id');
|
51 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
52 |
+
$this->getMassactionBlock()->setUseSelectAll(true);
|
53 |
+
$this->getMassactionBlock()->addItem('remove_shippingzip', array(
|
54 |
+
'label'=> Mage::helper('shippingrestriction')->__('Remove Shippingzip'),
|
55 |
+
'url' => $this->getUrl('*/adminhtml_shippingzip/massRemove'),
|
56 |
+
'confirm' => Mage::helper('shippingrestriction')->__('Are you sure?')
|
57 |
+
));
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Index.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Block_Index extends Mage_Core_Block_Template{
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Block/Shippingzip.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Block_Shippingzip extends Mage_Core_Block_Template{
|
3 |
+
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$datasets=Mage::getModel('shippingrestriction/shippingzip')->getCollection();
|
8 |
+
$this->setDatasets($datasets);
|
9 |
+
}
|
10 |
+
|
11 |
+
protected function _prepareLayout()
|
12 |
+
{
|
13 |
+
parent::_prepareLayout();
|
14 |
+
$pager = $this->getLayout()->createBlock('page/html_pager')->setCollection($this->getDatasets());
|
15 |
+
$this->setChild('pager', $pager);
|
16 |
+
$this->getDatasets()->load();
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getPagerHtml()
|
21 |
+
{
|
22 |
+
return $this->getChildHtml('pager');
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/local/Webskills/Shippingrestriction/Model/Mysql4/Shippingzip.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Model_Mysql4_Shippingzip extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init("shippingrestriction/shippingzip", "id");
|
7 |
+
}
|
8 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Model/Mysql4/Shippingzip/Collection.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Model_Mysql4_Shippingzip_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
public function _construct(){
|
6 |
+
$this->_init("shippingrestriction/shippingzip");
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
}
|
12 |
+
|
app/code/local/Webskills/Shippingrestriction/Model/Observer.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Model_Observer
|
3 |
+
{
|
4 |
+
|
5 |
+
public function Shippingzip(Varien_Event_Observer $observer)
|
6 |
+
{
|
7 |
+
$collection = Mage::getModel('shippingrestriction/shippingzip')->getCollection();
|
8 |
+
|
9 |
+
$data = array();
|
10 |
+
foreach ($collection as $value)
|
11 |
+
{
|
12 |
+
$data[] = $value->zipcode;
|
13 |
+
}
|
14 |
+
$address = Mage::getSingleton('checkout/session')->getQuote()
|
15 |
+
->getShippingAddress();
|
16 |
+
|
17 |
+
if (in_array($address->getData('postcode'),$data))
|
18 |
+
{
|
19 |
+
throw new Mage_Core_Exception(
|
20 |
+
Mage::helper('catalog')->__('Shipping is not available for your location.')
|
21 |
+
);die;
|
22 |
+
}
|
23 |
+
else
|
24 |
+
{
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Model/Observer.php~
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_Model_Observer
|
3 |
+
{
|
4 |
+
|
5 |
+
public function Shippingzip(Varien_Event_Observer $observer)
|
6 |
+
{
|
7 |
+
$collection = Mage::getModel('shippingrestriction/shippingzip')->getCollection();
|
8 |
+
|
9 |
+
$data = array();
|
10 |
+
foreach ($collection as $value)
|
11 |
+
{
|
12 |
+
$data[] = $value->zipcode;
|
13 |
+
}
|
14 |
+
$address = Mage::getSingleton('checkout/session')->getQuote()
|
15 |
+
->getShippingAddress();
|
16 |
+
|
17 |
+
if (in_array($address->getData('postcode'),$data))
|
18 |
+
{
|
19 |
+
throw new Mage_Core_Exception(
|
20 |
+
Mage::helper('catalog')->__('Shipping is not available for your location.')
|
21 |
+
);die;
|
22 |
+
}
|
23 |
+
else
|
24 |
+
{
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/local/Webskills/Shippingrestriction/Model/Shippingzip.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webskills_Shippingrestriction_Model_Shippingzip extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
protected function _construct(){
|
6 |
+
|
7 |
+
$this->_init("shippingrestriction/shippingzip");
|
8 |
+
|
9 |
+
}
|
10 |
+
|
11 |
+
}
|
12 |
+
|
app/code/local/Webskills/Shippingrestriction/controllers/Adminhtml/ShippingzipController.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webskills_Shippingrestriction_Adminhtml_ShippingzipController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
protected function _initAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout()->_setActiveMenu("shippingrestriction/shippingzip")->_addBreadcrumb(Mage::helper("adminhtml")->__("Shippingzip Manager"),Mage::helper("adminhtml")->__("Shippingzip Manager"));
|
8 |
+
return $this;
|
9 |
+
}
|
10 |
+
public function indexAction()
|
11 |
+
{
|
12 |
+
$this->_title($this->__("Shippingrestriction"));
|
13 |
+
$this->_title($this->__("Manager Shippingzip"));
|
14 |
+
|
15 |
+
$this->_initAction();
|
16 |
+
$this->renderLayout();
|
17 |
+
}
|
18 |
+
public function editAction()
|
19 |
+
{
|
20 |
+
$this->_title($this->__("Shippingrestriction"));
|
21 |
+
$this->_title($this->__("Shippingzip"));
|
22 |
+
$this->_title($this->__("Edit Item"));
|
23 |
+
|
24 |
+
$id = $this->getRequest()->getParam("id");
|
25 |
+
$model = Mage::getModel("shippingrestriction/shippingzip")->load($id);
|
26 |
+
if ($model->getId()) {
|
27 |
+
Mage::register("shippingzip_data", $model);
|
28 |
+
$this->loadLayout();
|
29 |
+
$this->_setActiveMenu("shippingrestriction/shippingzip");
|
30 |
+
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Shippingzip Manager"), Mage::helper("adminhtml")->__("Shippingzip Manager"));
|
31 |
+
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Shippingzip Description"), Mage::helper("adminhtml")->__("Shippingzip Description"));
|
32 |
+
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
|
33 |
+
$this->_addContent($this->getLayout()->createBlock("shippingrestriction/adminhtml_shippingzip_edit"))->_addLeft($this->getLayout()->createBlock("shippingrestriction/adminhtml_shippingzip_edit_tabs"));
|
34 |
+
$this->renderLayout();
|
35 |
+
}
|
36 |
+
else {
|
37 |
+
Mage::getSingleton("adminhtml/session")->addError(Mage::helper("shippingrestriction")->__("Item does not exist."));
|
38 |
+
$this->_redirect("*/*/");
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
public function newAction()
|
43 |
+
{
|
44 |
+
|
45 |
+
$this->_title($this->__("Shippingrestriction"));
|
46 |
+
$this->_title($this->__("Shippingzip"));
|
47 |
+
$this->_title($this->__("New Item"));
|
48 |
+
|
49 |
+
$id = $this->getRequest()->getParam("id");
|
50 |
+
$model = Mage::getModel("shippingrestriction/shippingzip")->load($id);
|
51 |
+
|
52 |
+
$data = Mage::getSingleton("adminhtml/session")->getFormData(true);
|
53 |
+
if (!empty($data)) {
|
54 |
+
$model->setData($data);
|
55 |
+
}
|
56 |
+
|
57 |
+
Mage::register("shippingzip_data", $model);
|
58 |
+
|
59 |
+
$this->loadLayout();
|
60 |
+
$this->_setActiveMenu("shippingrestriction/shippingzip");
|
61 |
+
|
62 |
+
$this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
|
63 |
+
|
64 |
+
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Shippingzip Manager"), Mage::helper("adminhtml")->__("Shippingzip Manager"));
|
65 |
+
$this->_addBreadcrumb(Mage::helper("adminhtml")->__("Shippingzip Description"), Mage::helper("adminhtml")->__("Shippingzip Description"));
|
66 |
+
|
67 |
+
|
68 |
+
$this->_addContent($this->getLayout()->createBlock("shippingrestriction/adminhtml_shippingzip_edit"))->_addLeft($this->getLayout()->createBlock("shippingrestriction/adminhtml_shippingzip_edit_tabs"));
|
69 |
+
|
70 |
+
$this->renderLayout();
|
71 |
+
|
72 |
+
}
|
73 |
+
public function saveAction()
|
74 |
+
{
|
75 |
+
|
76 |
+
$post_data=$this->getRequest()->getPost();
|
77 |
+
|
78 |
+
|
79 |
+
if ($post_data) {
|
80 |
+
|
81 |
+
try {
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
$model = Mage::getModel("shippingrestriction/shippingzip")
|
86 |
+
->addData($post_data)
|
87 |
+
->setId($this->getRequest()->getParam("id"))
|
88 |
+
->save();
|
89 |
+
|
90 |
+
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Shippingzip was successfully saved"));
|
91 |
+
Mage::getSingleton("adminhtml/session")->setShippingzipData(false);
|
92 |
+
|
93 |
+
if ($this->getRequest()->getParam("back")) {
|
94 |
+
$this->_redirect("*/*/edit", array("id" => $model->getId()));
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
$this->_redirect("*/*/");
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
catch (Exception $e) {
|
101 |
+
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
|
102 |
+
Mage::getSingleton("adminhtml/session")->setShippingzipData($this->getRequest()->getPost());
|
103 |
+
$this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
108 |
+
$this->_redirect("*/*/");
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
public function deleteAction()
|
114 |
+
{
|
115 |
+
if( $this->getRequest()->getParam("id") > 0 ) {
|
116 |
+
try {
|
117 |
+
$model = Mage::getModel("shippingrestriction/shippingzip");
|
118 |
+
$model->setId($this->getRequest()->getParam("id"))->delete();
|
119 |
+
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
|
120 |
+
$this->_redirect("*/*/");
|
121 |
+
}
|
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 |
+
|
131 |
+
public function massRemoveAction()
|
132 |
+
{
|
133 |
+
try {
|
134 |
+
$ids = $this->getRequest()->getPost('ids', array());
|
135 |
+
foreach ($ids as $id) {
|
136 |
+
$model = Mage::getModel("shippingrestriction/shippingzip");
|
137 |
+
$model->setId($id)->delete();
|
138 |
+
}
|
139 |
+
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
|
140 |
+
}
|
141 |
+
catch (Exception $e) {
|
142 |
+
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
|
143 |
+
}
|
144 |
+
$this->_redirect('*/*/');
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Export order grid to CSV format
|
149 |
+
*/
|
150 |
+
public function exportCsvAction()
|
151 |
+
{
|
152 |
+
$fileName = 'shippingzip.csv';
|
153 |
+
$grid = $this->getLayout()->createBlock('shippingrestriction/adminhtml_shippingzip_grid');
|
154 |
+
$this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* Export order grid to Excel XML format
|
158 |
+
*/
|
159 |
+
public function exportExcelAction()
|
160 |
+
{
|
161 |
+
$fileName = 'shippingzip.xml';
|
162 |
+
$grid = $this->getLayout()->createBlock('shippingrestriction/adminhtml_shippingzip_grid');
|
163 |
+
$this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
|
164 |
+
}
|
165 |
+
}
|
app/code/local/Webskills/Shippingrestriction/controllers/IndexController.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_IndexController extends Mage_Core_Controller_Front_Action{
|
3 |
+
public function IndexAction() {
|
4 |
+
|
5 |
+
$this->loadLayout();
|
6 |
+
$this->getLayout()->getBlock("head")->setTitle($this->__("Shippingrestriction"));
|
7 |
+
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
|
8 |
+
$breadcrumbs->addCrumb("home", array(
|
9 |
+
"label" => $this->__("Home Page"),
|
10 |
+
"title" => $this->__("Home Page"),
|
11 |
+
"link" => Mage::getBaseUrl()
|
12 |
+
));
|
13 |
+
|
14 |
+
$breadcrumbs->addCrumb("shippingrestriction", array(
|
15 |
+
"label" => $this->__("Shippingrestriction"),
|
16 |
+
"title" => $this->__("Shippingrestriction")
|
17 |
+
));
|
18 |
+
|
19 |
+
$this->renderLayout();
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
public function FrontAction()
|
24 |
+
{
|
25 |
+
$collection = Mage::getModel('shippingrestriction/shippingzip')->getCollection();
|
26 |
+
$data = array();
|
27 |
+
foreach ($collection as $value)
|
28 |
+
{
|
29 |
+
$data[] = $value->zipcode;
|
30 |
+
}
|
31 |
+
$address = $_REQUEST['zipcode'];
|
32 |
+
|
33 |
+
if (in_array($address,$data))
|
34 |
+
{
|
35 |
+
echo '<span style="color:#E84100">Oops!Shipping is not available for your location</span>';
|
36 |
+
}
|
37 |
+
else
|
38 |
+
{
|
39 |
+
echo '<span style="color:#5A9800">Congratulations!Shipping is Available for your location</span>';
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Webskills/Shippingrestriction/controllers/IndexController.php~
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_IndexController extends Mage_Core_Controller_Front_Action{
|
3 |
+
public function IndexAction() {
|
4 |
+
|
5 |
+
$this->loadLayout();
|
6 |
+
$this->getLayout()->getBlock("head")->setTitle($this->__("Shippingrestriction"));
|
7 |
+
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
|
8 |
+
$breadcrumbs->addCrumb("home", array(
|
9 |
+
"label" => $this->__("Home Page"),
|
10 |
+
"title" => $this->__("Home Page"),
|
11 |
+
"link" => Mage::getBaseUrl()
|
12 |
+
));
|
13 |
+
|
14 |
+
$breadcrumbs->addCrumb("shippingrestriction", array(
|
15 |
+
"label" => $this->__("Shippingrestriction"),
|
16 |
+
"title" => $this->__("Shippingrestriction")
|
17 |
+
));
|
18 |
+
|
19 |
+
$this->renderLayout();
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
public function FrontAction()
|
24 |
+
{
|
25 |
+
$collection = Mage::getModel('shippingrestriction/shippingzip')->getCollection();
|
26 |
+
$data = array();
|
27 |
+
foreach ($collection as $value)
|
28 |
+
{
|
29 |
+
$data[] = $value->zipcode;
|
30 |
+
}
|
31 |
+
$address = $_REQUEST['zipcode'];
|
32 |
+
|
33 |
+
if (in_array($address,$data))
|
34 |
+
{
|
35 |
+
echo '<span style="color:#E84100">Oops!Shipping is not available for your location</span>';
|
36 |
+
}
|
37 |
+
else
|
38 |
+
{
|
39 |
+
echo '<span style="color:#5A9800">Congratulations!Shipping Available for your location</span>';
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
app/code/local/Webskills/Shippingrestriction/controllers/ShippingzipController.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Webskills_Shippingrestriction_ShippingzipController extends Mage_Core_Controller_Front_Action{
|
3 |
+
public function IndexAction() {
|
4 |
+
|
5 |
+
$this->loadLayout();
|
6 |
+
$this->getLayout()->getBlock("head")->setTitle($this->__("Shippingzip"));
|
7 |
+
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
|
8 |
+
$breadcrumbs->addCrumb("home", array(
|
9 |
+
"label" => $this->__("Home Page"),
|
10 |
+
"title" => $this->__("Home Page"),
|
11 |
+
"link" => Mage::getBaseUrl()
|
12 |
+
));
|
13 |
+
|
14 |
+
$breadcrumbs->addCrumb("shippingrestriction", array(
|
15 |
+
"label" => $this->__("Shippingzip"),
|
16 |
+
"title" => $this->__("Shippingzip")
|
17 |
+
));
|
18 |
+
|
19 |
+
$this->renderLayout();
|
20 |
+
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Webskills/Shippingrestriction/etc/config.xml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Webskills_Shippingrestriction>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Webskills_Shippingrestriction>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<shippingrestriction>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Webskills_Shippingrestriction</module>
|
14 |
+
<frontName>shippingrestriction</frontName>
|
15 |
+
</args>
|
16 |
+
</shippingrestriction>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<shippingrestriction>
|
21 |
+
<file>shippingrestriction.xml</file>
|
22 |
+
</shippingrestriction>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<global>
|
27 |
+
<helpers>
|
28 |
+
<shippingrestriction>
|
29 |
+
<class>Webskills_Shippingrestriction_Helper</class>
|
30 |
+
</shippingrestriction>
|
31 |
+
</helpers>
|
32 |
+
<blocks>
|
33 |
+
<shippingrestriction>
|
34 |
+
<class>Webskills_Shippingrestriction_Block</class>
|
35 |
+
</shippingrestriction>
|
36 |
+
</blocks>
|
37 |
+
<models>
|
38 |
+
<shippingrestriction>
|
39 |
+
<class>Webskills_Shippingrestriction_Model</class>
|
40 |
+
<resourceModel>shippingrestriction_mysql4</resourceModel>
|
41 |
+
</shippingrestriction>
|
42 |
+
<shippingrestriction_mysql4>
|
43 |
+
<class>Webskills_Shippingrestriction_Model_Mysql4</class>
|
44 |
+
<entities>
|
45 |
+
<shippingzip>
|
46 |
+
<table>shipping_zipcodes</table>
|
47 |
+
</shippingzip>
|
48 |
+
</entities>
|
49 |
+
</shippingrestriction_mysql4>
|
50 |
+
</models>
|
51 |
+
<resources>
|
52 |
+
<shippingrestriction_setup>
|
53 |
+
<setup>
|
54 |
+
<module>Webskills_Shippingrestriction</module>
|
55 |
+
</setup>
|
56 |
+
<connection>
|
57 |
+
<use>core_setup</use>
|
58 |
+
</connection>
|
59 |
+
</shippingrestriction_setup>
|
60 |
+
<shippingrestriction_write>
|
61 |
+
<connection>
|
62 |
+
<use>core_write</use>
|
63 |
+
</connection>
|
64 |
+
</shippingrestriction_write>
|
65 |
+
<shippingrestriction_read>
|
66 |
+
<connection>
|
67 |
+
<use>core_read</use>
|
68 |
+
</connection>
|
69 |
+
</shippingrestriction_read>
|
70 |
+
</resources>
|
71 |
+
<events>
|
72 |
+
<sales_order_save_before> <!-- identifier of the event we want to catch -->
|
73 |
+
<observers>
|
74 |
+
<sales_order_save_before_handler> <!-- identifier of the event handler -->
|
75 |
+
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
|
76 |
+
<class>shippingrestriction/observer</class> <!-- observers class alias -->
|
77 |
+
<method>Shippingzip</method> <!-- observer's method to be called -->
|
78 |
+
<args></args> <!-- additional arguments passed to observer -->
|
79 |
+
</sales_order_save_before_handler>
|
80 |
+
</observers>
|
81 |
+
</sales_order_save_before>
|
82 |
+
</events>
|
83 |
+
</global>
|
84 |
+
<admin>
|
85 |
+
<routers>
|
86 |
+
<shippingrestriction>
|
87 |
+
<use>admin</use>
|
88 |
+
<args>
|
89 |
+
<module>Webskills_Shippingrestriction</module>
|
90 |
+
<frontName>shippingrestriction</frontName>
|
91 |
+
</args>
|
92 |
+
</shippingrestriction>
|
93 |
+
</routers>
|
94 |
+
</admin>
|
95 |
+
<adminhtml>
|
96 |
+
<menu>
|
97 |
+
<shippingrestriction module="shippingrestriction">
|
98 |
+
<title>WS Shipping Restriction</title>
|
99 |
+
<sort_order>100</sort_order>
|
100 |
+
<children>
|
101 |
+
<shippingzip module="shippingrestriction">
|
102 |
+
<title>Manage Zip Codes</title>
|
103 |
+
<sort_order>0</sort_order>
|
104 |
+
<action>shippingrestriction/adminhtml_shippingzip</action>
|
105 |
+
</shippingzip>
|
106 |
+
</children>
|
107 |
+
</shippingrestriction>
|
108 |
+
</menu>
|
109 |
+
<acl>
|
110 |
+
<resources>
|
111 |
+
<all>
|
112 |
+
<title>Allow Everything</title>
|
113 |
+
</all>
|
114 |
+
<admin>
|
115 |
+
<children>
|
116 |
+
<shippingrestriction translate="title" module="shippingrestriction">
|
117 |
+
<title>Shippingrestriction</title>
|
118 |
+
<sort_order>1000</sort_order>
|
119 |
+
<children>
|
120 |
+
<shippingzip translate="title">
|
121 |
+
<title>Manage Shippingzip</title>
|
122 |
+
<sort_order>0</sort_order>
|
123 |
+
</shippingzip>
|
124 |
+
</children>
|
125 |
+
</shippingrestriction>
|
126 |
+
</children>
|
127 |
+
</admin>
|
128 |
+
</resources>
|
129 |
+
</acl>
|
130 |
+
<layout>
|
131 |
+
<updates>
|
132 |
+
<shippingrestriction>
|
133 |
+
<file>shippingrestriction.xml</file>
|
134 |
+
</shippingrestriction>
|
135 |
+
</updates>
|
136 |
+
</layout>
|
137 |
+
</adminhtml>
|
138 |
+
</config>
|
app/code/local/Webskills/Shippingrestriction/sql/shippingrestriction_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$installer->startSetup();
|
4 |
+
$installer->run("
|
5 |
+
|
6 |
+
CREATE TABLE {$this->getTable('shipping_zipcodes')} (
|
7 |
+
`id` int(11) NOT NULL auto_increment,
|
8 |
+
`zipcode` varchar(60) NOT NULL,
|
9 |
+
PRIMARY KEY (`id`)
|
10 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
11 |
+
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/shippingrestriction.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<shippingrestriction_adminhtml_shippingzip_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="shippingrestriction/adminhtml_shippingzip" name="shippingzip" />
|
6 |
+
</reference>
|
7 |
+
</shippingrestriction_adminhtml_shippingzip_index>
|
8 |
+
</layout>
|
app/design/frontend/base/default/layout/shippingrestriction.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<shippingrestriction_index_index>
|
4 |
+
<reference name="root">
|
5 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="content">
|
8 |
+
<block type="shippingrestriction/index" name="shippingrestriction_index" template="shippingrestriction/index.phtml"/>
|
9 |
+
</reference>
|
10 |
+
</shippingrestriction_index_index>
|
11 |
+
<shippingrestriction_shippingzip_index>
|
12 |
+
<reference name="root">
|
13 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
14 |
+
</reference>
|
15 |
+
<reference name="content">
|
16 |
+
<block type="shippingrestriction/shippingzip" name="shippingrestriction_shippingzip" template="shippingrestriction/shippingzip.phtml"/>
|
17 |
+
</reference>
|
18 |
+
</shippingrestriction_shippingzip_index>
|
19 |
+
</layout>
|
20 |
+
|
app/design/frontend/base/default/template/shippingrestriction/index.phtml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
2 |
+
<h1> Search Shipping Locations </h1>
|
3 |
+
<script>
|
4 |
+
function Checkshipping()
|
5 |
+
{
|
6 |
+
var zipcode = document.getElementById('zipcode').value;
|
7 |
+
jQuery( "#result" ).empty();
|
8 |
+
|
9 |
+
if (zipcode == '')
|
10 |
+
{
|
11 |
+
jQuery("#zipcode").css("border","2px dotted #E84100");return false;
|
12 |
+
}
|
13 |
+
jQuery.ajax({
|
14 |
+
type:"POST",
|
15 |
+
xhrFields: {
|
16 |
+
withCredentials: false
|
17 |
+
},
|
18 |
+
url:"<?php echo Mage::getBaseUrl();?>shippingrestriction/index/front",
|
19 |
+
data:{'zipcode':zipcode},
|
20 |
+
success: function (data, status) {
|
21 |
+
jQuery("#zipcode").css("border","none");
|
22 |
+
jQuery( "#result" ).empty(data);
|
23 |
+
jQuery( "#result" ).append(data);
|
24 |
+
|
25 |
+
},
|
26 |
+
error: function (xhr, desc, err) {
|
27 |
+
|
28 |
+
alert("Error Processing your request!Please try again later!");
|
29 |
+
alert(xhr.toSource());
|
30 |
+
alert("Desc: " + desc + "\nErr:" + err);
|
31 |
+
}
|
32 |
+
});
|
33 |
+
}
|
34 |
+
</script>
|
35 |
+
<input type="text" id="zipcode">
|
36 |
+
<button onclick="Checkshipping()" title="Continue" class="button" type="button"><span><span>Go</span></span></button>
|
37 |
+
<div id ="result"></div>
|
app/design/frontend/base/default/template/shippingrestriction/shippingzip.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
3 |
+
<?php $_datasets = $this->getDatasets(); ?>
|
4 |
+
<div class="page-head">
|
5 |
+
<h3><?php echo $this->__('Shippingzip') ?></h3>
|
6 |
+
</div>
|
7 |
+
<?php echo $this->getPagerHtml(); ?>
|
8 |
+
<?php if($_datasets->getSize()): ?>
|
9 |
+
<table cellspacing="0" class="data-table" id="data-table">
|
10 |
+
<thead>
|
11 |
+
<tr>
|
12 |
+
<th><?php echo $this->__('Id') ?></th>
|
13 |
+
|
14 |
+
<th><?php echo $this->__('zipcode') ?></th>
|
15 |
+
<th> </th>
|
16 |
+
</tr>
|
17 |
+
</thead>
|
18 |
+
<tbody>
|
19 |
+
<?php foreach ($_datasets as $_dataset): ?>
|
20 |
+
<tr>
|
21 |
+
<td valign="middle" style="vertical-align:middle;"><?php echo $_dataset->getId() ?></td>
|
22 |
+
|
23 |
+
<td valign="middle" style="vertical-align:middle;"><?php echo $_dataset->getData('zipcode') ?></td>
|
24 |
+
<td valign="middle" style="vertical-align:middle;"><a href="#" ><?php echo($this->__('View')) ?></a></td>
|
25 |
+
</tr>
|
26 |
+
<?php endforeach; ?>
|
27 |
+
</tbody>
|
28 |
+
</table>
|
29 |
+
<script type="text/javascript">decorateTable('data-table')</script>
|
30 |
+
<?php echo $this->getPagerHtml(); ?>
|
31 |
+
<?php else: ?>
|
32 |
+
<p><?php echo $this->__('You have submited no data.'); ?></p>
|
33 |
+
<?php endif ?>
|
app/etc/modules/Webskills_Shippingrestriction.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Webskills_Shippingrestriction>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</Webskills_Shippingrestriction>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>webskills_shippingrestriction</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Restrict your shipping by adding zip codes.</summary>
|
10 |
+
<description>Shipping Restriction is a simple and lite magento extension.Using this extension,you can restrict your shipping deleivery by adding zipcodes.
|
11 |
+
You can add,remove or edit zipcodes from backend.
|
12 |
+
Also,there is an additional ajax based block you can place at any page using following code:
|
13 |
+
{{block type="core/template" template="shippingrestriction/index.phtml"}}</description>
|
14 |
+
<notes>Clear magento cache after installing this extension and relogin to your magento admin.</notes>
|
15 |
+
<authors><author><name>Rohit Dhiman</name><user>rohitjesus</user><email>rohitdoll@gmail.com</email></author></authors>
|
16 |
+
<date>2014-06-12</date>
|
17 |
+
<time>07:32:22</time>
|
18 |
+
<contents><target name="magelocal"><dir name="Webskills"><dir name="Shippingrestriction"><dir name="Block"><dir name="Adminhtml"><dir name="Shippingzip"><dir name="Edit"><file name="Form.php" hash="5d7df940af0140fb61afb91428f62f59"/><dir name="Tab"><file name="Form.php" hash="532ca5831630c7b7ad9832f8faa8cfb6"/></dir><file name="Tabs.php" hash="cd5fcf91406ac4ab4f2c77eea869f9d0"/></dir><file name="Edit.php" hash="39ea1017251a3e56340d4ac7cf91acda"/><file name="Grid.php" hash="27129599f3c5cc42308787d3bda95f2c"/></dir><file name="Shippingzip.php" hash="b5f0b932027b876f315e17ae6a9d8752"/></dir><file name="Index.php" hash="a2ec07eb5805838f1c5c615b21c05004"/><file name="Shippingzip.php" hash="5ce623899287dca1434d78dfab67fe78"/></dir><dir name="Helper"><file name="Data.php" hash="ecd9b30b91affedbcc8d3fc4ca76ed2e"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Shippingzip"><file name="Collection.php" hash="2ac4e031797d5fb603f68e9a1df8938d"/></dir><file name="Shippingzip.php" hash="159c5edef6fe90bf1918e7ef5539d313"/></dir><file name="Observer.php" hash="88c95f6b876e294464b7fa39541a61bd"/><file name="Observer.php~" hash="88c95f6b876e294464b7fa39541a61bd"/><file name="Shippingzip.php" hash="674116aa5d659b2ae0a45a008a0b4b97"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ShippingzipController.php" hash="8c4846b6986f9d0a6b85bb16acd89b14"/></dir><file name="IndexController.php" hash="dd5389173c8c6370c3405ac15a069fdb"/><file name="IndexController.php~" hash="b7186ea045566b454677880a2a305b5e"/><file name="ShippingzipController.php" hash="25525a79b617bbb3f8e0f5c742d6f71f"/></dir><dir name="etc"><file name="config.xml" hash="8567987eb7fbf7d86804600aba5730dc"/></dir><dir name="sql"><dir name="shippingrestriction_setup"><file name="mysql4-install-0.1.0.php" hash="7c5750e9afdedbe37511c2632f2c7896"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webskills_Shippingrestriction.xml" hash="ecdb562dc07d9d7c20cce6221a39868b"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="shippingrestriction.xml" hash="72896f42250ffb5c4b2e18c46393b4b5"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shippingrestriction.xml" hash="d2ea2a540af46f17349d7c724dd79506"/></dir><dir name="template"><dir name="shippingrestriction"><file name="index.phtml" hash="7330a2a5fb4c5db1e3bfe0caa3ab3ad4"/><file name="shippingzip.phtml" hash="c1fce0c026e10a2d1e9a6f497a860e79"/></dir></dir></dir></dir></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|