Version Notes
This is first stable version
Download this release
Release Info
Developer | Iverve |
Extension | Ifuturz_Notforsale |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Ifuturz/Notforsale/Block/Notforsale.php +42 -0
- app/code/local/Ifuturz/Notforsale/Helper/Catalog/Product/Configuration.php +78 -0
- app/code/local/Ifuturz/Notforsale/Helper/Data.php +8 -0
- app/code/local/Ifuturz/Notforsale/Helper/Product/Configuration.php +27 -0
- app/code/local/Ifuturz/Notforsale/Model/Observer.php +46 -0
- app/code/local/Ifuturz/Notforsale/controllers/CartController.php +46 -0
- app/code/local/Ifuturz/Notforsale/controllers/IndexController.php +73 -0
- app/code/local/Ifuturz/Notforsale/controllers/OnepageController.php +118 -0
- app/code/local/Ifuturz/Notforsale/etc/config.xml +90 -0
- app/code/local/Ifuturz/Notforsale/sql/notforsale_setup/mysql4-install-0.1.0.php +68 -0
- app/design/frontend/base/default/layout/notforsale.xml +15 -0
- app/etc/modules/Ifuturz_Notforsale.xml +11 -0
- package.xml +33 -0
app/code/local/Ifuturz/Notforsale/Block/Notforsale.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_Notforsale_Block_Notforsale extends Mage_Core_Block_Template
|
6 |
+
{
|
7 |
+
public function checkShiprestriction()
|
8 |
+
{
|
9 |
+
$session= Mage::getSingleton('checkout/session');
|
10 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
11 |
+
foreach($session->getQuote()->getAllItems() as $item)
|
12 |
+
{
|
13 |
+
$productType = $item->getProduct()->getTypeId();
|
14 |
+
if($productType == 'configurable' || $productType == 'bundle')
|
15 |
+
{
|
16 |
+
continue;
|
17 |
+
}
|
18 |
+
$productid = $item->getProductId();
|
19 |
+
$productload = Mage::getModel('catalog/product')->load($productid);
|
20 |
+
$optionvalues = $productload->getAttributeText('not_for_sale_to');
|
21 |
+
if(count($optionvalues) > 1)
|
22 |
+
{
|
23 |
+
if($productload->getNot_for_sale_to()!='')
|
24 |
+
{
|
25 |
+
for($i=0;$i<count($optionvalues);$i++)
|
26 |
+
{
|
27 |
+
$statedata = $connection->query("select * from directory_country_region WHERE code='".$optionvalues[$i]."'");
|
28 |
+
$statename = $statedata->fetch();
|
29 |
+
$regionids[] = $statename['region_id'];
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
else if($optionvalues != '')
|
34 |
+
{
|
35 |
+
$statedata = $connection->query("select * from directory_country_region WHERE code='".$optionvalues."'");
|
36 |
+
$statename = $statedata->fetch();
|
37 |
+
$regionids[] = $statename['region_id'];
|
38 |
+
}
|
39 |
+
}
|
40 |
+
return $regionids;
|
41 |
+
}
|
42 |
+
}
|
app/code/local/Ifuturz/Notforsale/Helper/Catalog/Product/Configuration.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_Notforsale_Helper_Catalog_Product_Configuration extends Mage_Bundle_Helper_Catalog_Product_Configuration
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Get bundled selections (slections-products collection)
|
9 |
+
*
|
10 |
+
* Returns array of options objects.
|
11 |
+
* Each option object will contain array of selections objects
|
12 |
+
*
|
13 |
+
* @return array
|
14 |
+
*/
|
15 |
+
public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
|
16 |
+
{
|
17 |
+
$options = array();
|
18 |
+
$product = $item->getProduct();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var Mage_Bundle_Model_Product_Type
|
22 |
+
*/
|
23 |
+
$typeInstance = $product->getTypeInstance(true);
|
24 |
+
|
25 |
+
// get bundle options
|
26 |
+
$optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
|
27 |
+
$bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
|
28 |
+
if ($bundleOptionsIds) {
|
29 |
+
/**
|
30 |
+
* @var Mage_Bundle_Model_Mysql4_Option_Collection
|
31 |
+
*/
|
32 |
+
$optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
|
33 |
+
|
34 |
+
// get and add bundle selections collection
|
35 |
+
$selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
|
36 |
+
|
37 |
+
$bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
|
38 |
+
|
39 |
+
if (!empty($bundleSelectionIds)) {
|
40 |
+
$selectionsCollection = $typeInstance->getSelectionsByIds(
|
41 |
+
unserialize($selectionsQuoteItemOption->getValue()),
|
42 |
+
$product
|
43 |
+
);
|
44 |
+
|
45 |
+
$bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
|
46 |
+
foreach ($bundleOptions as $bundleOption) {
|
47 |
+
|
48 |
+
if ($bundleOption->getSelections()) {
|
49 |
+
$sel = $bundleOption->getSelections(); /*added by ifuturz*/
|
50 |
+
$option = array(
|
51 |
+
'label' => $bundleOption->getTitle(),
|
52 |
+
'value' => array(),
|
53 |
+
'pid' => $sel[0]->entity_id,/*added by ifuturz*/
|
54 |
+
);
|
55 |
+
|
56 |
+
$bundleSelections = $bundleOption->getSelections();
|
57 |
+
|
58 |
+
foreach ($bundleSelections as $bundleSelection) {
|
59 |
+
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
|
60 |
+
if ($qty) {
|
61 |
+
$option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
|
62 |
+
. ' ' . Mage::helper('core')->currency(
|
63 |
+
$this->getSelectionFinalPrice($item, $bundleSelection)
|
64 |
+
);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
if ($option['value']) {
|
69 |
+
$options[] = $option;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
return $options;
|
77 |
+
}
|
78 |
+
}
|
app/code/local/Ifuturz/Notforsale/Helper/Data.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_Notforsale_Helper_Data extends Mage_Core_Helper_Abstract
|
6 |
+
{
|
7 |
+
}
|
8 |
+
|
app/code/local/Ifuturz/Notforsale/Helper/Product/Configuration.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_Notforsale_Helper_Product_Configuration extends Mage_Catalog_Helper_Product_Configuration
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Retrieves configuration options for configurable product
|
9 |
+
*
|
10 |
+
* @param Mage_Catalog_Model_Product_Configuration_Item_Interface $item
|
11 |
+
* @return array
|
12 |
+
*/
|
13 |
+
public function getConfigurableOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
|
14 |
+
{
|
15 |
+
$product = $item->getProduct();
|
16 |
+
$typeId = $product->getTypeId();
|
17 |
+
if ($typeId != Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
|
18 |
+
Mage::throwException($this->__('Wrong product type to extract configurable options.'));
|
19 |
+
}
|
20 |
+
$attributes = $product->getTypeInstance(true)
|
21 |
+
->getSelectedAttributesInfo($product);
|
22 |
+
|
23 |
+
$attributes[0]['pid'] = $item->getOptionByCode('simple_product')->getProduct()->getId(); /* code added by ifuturz */
|
24 |
+
|
25 |
+
return array_merge($attributes, $this->getCustomOptions($item));
|
26 |
+
}
|
27 |
+
}
|
app/code/local/Ifuturz/Notforsale/Model/Observer.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_Notforsale_Model_Observer
|
6 |
+
{
|
7 |
+
public function checkInstallation($observer)
|
8 |
+
{
|
9 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
10 |
+
$sql ="SELECT * FROM `notforsale_lck` WHERE flag='LCK' AND value='1'";
|
11 |
+
$data = $read->fetchAll($sql);
|
12 |
+
if(count($data)==1)
|
13 |
+
{
|
14 |
+
|
15 |
+
$admindata = $read->fetchAll("SELECT email FROM admin_user WHERE username='admin'");
|
16 |
+
|
17 |
+
$storename = Mage::getStoreConfig('general/store_information/name');
|
18 |
+
$storephone = Mage::getStoreConfig('general/store_information/phone');
|
19 |
+
$store_address = Mage::getStoreConfig('general/store_information/address');
|
20 |
+
$secureurl = Mage::getStoreConfig('web/unsecure/base_url');
|
21 |
+
$unsecureurl = Mage::getStoreConfig('web/secure/base_url');
|
22 |
+
$sendername = Mage::getStoreConfig('trans_email/ident_general/name');
|
23 |
+
$general_email = Mage::getStoreConfig('trans_email/ident_general/email');
|
24 |
+
$admin_email = $admindata[0]['email'];
|
25 |
+
|
26 |
+
$body = "Extension <b>'Notforsale'</b> is installed to the following detail: <br/><br/> STORE NAME: ".$storename."<br/>STORE PHONE: ".$storephone."<br/>STORE ADDRESS: ".$store_address."<br/>SECURE URL: ".$secureurl."<br/>UNSECURE URL: ".$unsecureurl."<br/>ADMIN EMAIL ADDRESS: ".$admin_email."<br/>GENERAL EMAIL ADDRESS: ".$general_email."";
|
27 |
+
|
28 |
+
$mail = Mage::getModel('core/email');
|
29 |
+
$mail->setToName('Extension Geek');
|
30 |
+
$mail->setToEmail('extension.geek@ifuturz.com');
|
31 |
+
$mail->setBody($body);
|
32 |
+
$mail->setSubject('Notforsale Extension is installed!!!');
|
33 |
+
$mail->setFromEmail($general_email);
|
34 |
+
$mail->setFromName($sendername);
|
35 |
+
$mail->setType('html');
|
36 |
+
try{
|
37 |
+
$mail->send();
|
38 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
39 |
+
$write->query("update notforsale_lck set value='0' where flag='LCK'");
|
40 |
+
}
|
41 |
+
catch(Exception $e)
|
42 |
+
{
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
app/code/local/Ifuturz/Notforsale/controllers/CartController.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
require_once 'Mage/Checkout/controllers/CartController.php';
|
6 |
+
class Ifuturz_Notforsale_CartController extends Mage_Checkout_CartController
|
7 |
+
{
|
8 |
+
public function estimatePostAction()
|
9 |
+
{
|
10 |
+
|
11 |
+
$country = (string) $this->getRequest()->getParam('country_id');
|
12 |
+
$postcode = (string) $this->getRequest()->getParam('estimate_postcode');
|
13 |
+
$city = (string) $this->getRequest()->getParam('estimate_city');
|
14 |
+
$regionId = (string) $this->getRequest()->getParam('region_id');
|
15 |
+
$region = (string) $this->getRequest()->getParam('region');
|
16 |
+
|
17 |
+
/*start code by ifuturz*/
|
18 |
+
$regionModel = Mage::getModel('directory/region')->load($regionId);
|
19 |
+
$region_code = $regionModel->getCode();
|
20 |
+
$_blockData = $this->getLayout()->createBlock('notforsale/notforsale');
|
21 |
+
|
22 |
+
if(in_array($regionId,$_blockData->checkShiprestriction()))
|
23 |
+
{
|
24 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
25 |
+
$statename = $connection->fetchRow("select * from directory_country_region WHERE region_id=".$regionId." AND country_id = 'US' limit 1");
|
26 |
+
|
27 |
+
if(count($statename) > 0)
|
28 |
+
{
|
29 |
+
$this->_getSession()->addError($this->__('You have an product in your shopping cart that can not be shipped to the '.$statename["default_name"].' due to '.$statename["code"].' state regulation. Please remove the items from your cart.'));
|
30 |
+
$this->_goBack();
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
/*end code by ifuturz*/
|
35 |
+
$this->_getQuote()->getShippingAddress()
|
36 |
+
->setCountryId($country)
|
37 |
+
->setCity($city)
|
38 |
+
->setPostcode($postcode)
|
39 |
+
->setRegionId($regionId)
|
40 |
+
->setRegion($region)
|
41 |
+
->setCollectShippingRates(true);
|
42 |
+
$this->_getQuote()->save();
|
43 |
+
$this->_goBack();
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
app/code/local/Ifuturz/Notforsale/controllers/IndexController.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
class Ifuturz_PriceProtection_IndexController extends Mage_Core_Controller_Front_Action{
|
6 |
+
public function IndexAction() {
|
7 |
+
|
8 |
+
$this->loadLayout();
|
9 |
+
$this->getLayout()->getBlock("head")->setTitle($this->__("Price Protection"));
|
10 |
+
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
|
11 |
+
$breadcrumbs->addCrumb("home", array(
|
12 |
+
"label" => $this->__("Home Page"),
|
13 |
+
"title" => $this->__("Home Page"),
|
14 |
+
"link" => Mage::getBaseUrl()
|
15 |
+
));
|
16 |
+
|
17 |
+
$breadcrumbs->addCrumb("price protection", array(
|
18 |
+
"label" => $this->__("Price Protection"),
|
19 |
+
"title" => $this->__("Price Protection")
|
20 |
+
));
|
21 |
+
|
22 |
+
$this->renderLayout();
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
public function saveAction() {
|
27 |
+
|
28 |
+
|
29 |
+
$data = $this->getRequest()->getPost();
|
30 |
+
|
31 |
+
$model = Mage::getModel('priceprotection/priceprotection');
|
32 |
+
|
33 |
+
$model->setName($data['name']);
|
34 |
+
|
35 |
+
$model->setEmail($data['email']);
|
36 |
+
$model->setAddressline1($data['addressline1']);
|
37 |
+
|
38 |
+
$model->setAddressline2($data['addressline2']);
|
39 |
+
|
40 |
+
$model->setCity($data['city']);
|
41 |
+
|
42 |
+
$model->setState($data['state']);
|
43 |
+
|
44 |
+
$model->setZipcode($data['zipcode']);
|
45 |
+
|
46 |
+
$model->setOrderNumber($data['order_number']);
|
47 |
+
$model->setItemNumber($data['item_number']);
|
48 |
+
$model->setItemDescription($data['item_description']);
|
49 |
+
$model->setOriginalPurchaseDate($data['original_purchase_date']);
|
50 |
+
$model->setOriginalPurchasePrice($data['original_purchase_price']);
|
51 |
+
$model->setPurchasePrice($data['purchase_price']);
|
52 |
+
$model->setPurchaseZipcode($data['purchase_zipcode']);
|
53 |
+
|
54 |
+
$model->setSame($data['same']);
|
55 |
+
|
56 |
+
$model->setAvailable($data['available']);
|
57 |
+
|
58 |
+
$model->setOriginal($data['original']);
|
59 |
+
|
60 |
+
$model->setCreatedTime(now());
|
61 |
+
|
62 |
+
$model->setUpdateTime(now());
|
63 |
+
|
64 |
+
$model->save();
|
65 |
+
|
66 |
+
// echo "<pre>";print_r($model->getData());die;
|
67 |
+
|
68 |
+
Mage::getSingleton('core/session')->addSuccess(Mage::helper('priceprotection')->__('Your form has been send successfully.'));
|
69 |
+
|
70 |
+
$this->_redirect('priceprotection');
|
71 |
+
|
72 |
+
}
|
73 |
+
}
|
app/code/local/Ifuturz/Notforsale/controllers/OnepageController.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
6 |
+
class Ifuturz_Notforsale_OnepageController extends Mage_Checkout_OnepageController
|
7 |
+
{
|
8 |
+
public function saveOrderAction()
|
9 |
+
{
|
10 |
+
if ($this->_expireAjax()) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
/* start code by ifuturz */
|
14 |
+
$result = array();
|
15 |
+
$_blockData = $this->getLayout()->createBlock('notforsale/notforsale');
|
16 |
+
$regionId = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getRegionId();
|
17 |
+
|
18 |
+
if(in_array($regionId,$_blockData->checkShiprestriction()))
|
19 |
+
{
|
20 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
21 |
+
$statename = $connection->fetchRow("select * from directory_country_region WHERE region_id=".$regionId." AND country_id = 'US' limit 1");
|
22 |
+
//Mage::getSingleton('core/session')->setCheckouterror('You have an product in your shopping cart that can not be shipped to the '.$statename["default_name"].' due to '.$statename["code"].' state regulation. Please remove the items from your card.');
|
23 |
+
|
24 |
+
$result['error'] = true;
|
25 |
+
$result['error_messages'] = $this->__('You have an product in your shopping cart that can not be shipped to the '.$statename["default_name"].' due to '.$statename["code"].' state regulation. Please remove the items from your cart.');
|
26 |
+
|
27 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
28 |
+
|
29 |
+
return;
|
30 |
+
|
31 |
+
//$this->_redirect(Mage::getUrl('checkout/cart'));
|
32 |
+
//return;
|
33 |
+
}
|
34 |
+
//die('dfsf');
|
35 |
+
/* end code by ifuturz */
|
36 |
+
$result = array();
|
37 |
+
try {
|
38 |
+
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
|
39 |
+
if ($requiredAgreements) {
|
40 |
+
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
|
41 |
+
$diff = array_diff($requiredAgreements, $postedAgreements);
|
42 |
+
if ($diff) {
|
43 |
+
$result['success'] = false;
|
44 |
+
$result['error'] = true;
|
45 |
+
$result['error_messages'] = $this->__('Please agree to all the terms and conditions before placing the order.');
|
46 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$data = $this->getRequest()->getPost('payment', array());
|
52 |
+
if ($data) {
|
53 |
+
$data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT
|
54 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
|
55 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
|
56 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
|
57 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
|
58 |
+
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
59 |
+
}
|
60 |
+
|
61 |
+
$this->getOnepage()->saveOrder();
|
62 |
+
|
63 |
+
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
|
64 |
+
$result['success'] = true;
|
65 |
+
$result['error'] = false;
|
66 |
+
} catch (Mage_Payment_Model_Info_Exception $e) {
|
67 |
+
$message = $e->getMessage();
|
68 |
+
if (!empty($message)) {
|
69 |
+
$result['error_messages'] = $message;
|
70 |
+
}
|
71 |
+
$result['goto_section'] = 'payment';
|
72 |
+
$result['update_section'] = array(
|
73 |
+
'name' => 'payment-method',
|
74 |
+
'html' => $this->_getPaymentMethodsHtml()
|
75 |
+
);
|
76 |
+
} catch (Mage_Core_Exception $e) {
|
77 |
+
Mage::logException($e);
|
78 |
+
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
79 |
+
$result['success'] = false;
|
80 |
+
$result['error'] = true;
|
81 |
+
$result['error_messages'] = $e->getMessage();
|
82 |
+
|
83 |
+
$gotoSection = $this->getOnepage()->getCheckout()->getGotoSection();
|
84 |
+
if ($gotoSection) {
|
85 |
+
$result['goto_section'] = $gotoSection;
|
86 |
+
$this->getOnepage()->getCheckout()->setGotoSection(null);
|
87 |
+
}
|
88 |
+
$updateSection = $this->getOnepage()->getCheckout()->getUpdateSection();
|
89 |
+
if ($updateSection) {
|
90 |
+
if (isset($this->_sectionUpdateFunctions[$updateSection])) {
|
91 |
+
$updateSectionFunction = $this->_sectionUpdateFunctions[$updateSection];
|
92 |
+
$result['update_section'] = array(
|
93 |
+
'name' => $updateSection,
|
94 |
+
'html' => $this->$updateSectionFunction()
|
95 |
+
);
|
96 |
+
}
|
97 |
+
$this->getOnepage()->getCheckout()->setUpdateSection(null);
|
98 |
+
}
|
99 |
+
} catch (Exception $e) {
|
100 |
+
Mage::logException($e);
|
101 |
+
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
102 |
+
$result['success'] = false;
|
103 |
+
$result['error'] = true;
|
104 |
+
$result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
|
105 |
+
}
|
106 |
+
$this->getOnepage()->getQuote()->save();
|
107 |
+
/**
|
108 |
+
* when there is redirect to third party, we don't want to save order yet.
|
109 |
+
* we will save the order in return action.
|
110 |
+
*/
|
111 |
+
if (isset($redirectUrl)) {
|
112 |
+
$result['redirect'] = $redirectUrl;
|
113 |
+
}
|
114 |
+
|
115 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
app/code/local/Ifuturz/Notforsale/etc/config.xml
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Ifuturz_Notforsale>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Ifuturz_Notforsale>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<notforsale>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Ifuturz_Notforsale</module>
|
14 |
+
<frontName>notforsale</frontName>
|
15 |
+
</args>
|
16 |
+
</notforsale>
|
17 |
+
<checkout>
|
18 |
+
<args>
|
19 |
+
<modules>
|
20 |
+
<ifuturz_notforsale before="Mage_Checkout">Ifuturz_Notforsale</ifuturz_notforsale>
|
21 |
+
</modules>
|
22 |
+
</args>
|
23 |
+
</checkout>
|
24 |
+
</routers>
|
25 |
+
<layout>
|
26 |
+
<updates>
|
27 |
+
<notforsale>
|
28 |
+
<file>notforsale.xml</file>
|
29 |
+
</notforsale>
|
30 |
+
</updates>
|
31 |
+
</layout>
|
32 |
+
</frontend>
|
33 |
+
<global>
|
34 |
+
<helpers>
|
35 |
+
<notforsale>
|
36 |
+
<class>Ifuturz_Notforsale_Helper</class>
|
37 |
+
</notforsale>
|
38 |
+
<bundle>
|
39 |
+
<rewrite>
|
40 |
+
<catalog_product_configuration>Ifuturz_Notforsale_Helper_Catalog_Product_Configuration</catalog_product_configuration>
|
41 |
+
</rewrite>
|
42 |
+
</bundle>
|
43 |
+
<catalog>
|
44 |
+
<rewrite>
|
45 |
+
<product_configuration>Ifuturz_Notforsale_Helper_Product_Configuration</product_configuration>
|
46 |
+
</rewrite>
|
47 |
+
</catalog>
|
48 |
+
</helpers>
|
49 |
+
<blocks>
|
50 |
+
<notforsale>
|
51 |
+
<class>Ifuturz_Notforsale_Block</class>
|
52 |
+
</notforsale>
|
53 |
+
</blocks>
|
54 |
+
<resources>
|
55 |
+
<notforsale_setup>
|
56 |
+
<setup>
|
57 |
+
<module>Ifuturz_Notforsale</module>
|
58 |
+
</setup>
|
59 |
+
<connection>
|
60 |
+
<use>core_setup</use>
|
61 |
+
</connection>
|
62 |
+
</notforsale_setup>
|
63 |
+
<notforsale_write>
|
64 |
+
<connection>
|
65 |
+
<use>core_write</use>
|
66 |
+
</connection>
|
67 |
+
</notforsale_write>
|
68 |
+
<notforsale_read>
|
69 |
+
<connection>
|
70 |
+
<use>core_read</use>
|
71 |
+
</connection>
|
72 |
+
</notforsale_read>
|
73 |
+
</resources>
|
74 |
+
<models>
|
75 |
+
<notforsale>
|
76 |
+
<class>Ifuturz_Notforsale_Model</class>
|
77 |
+
</notforsale>
|
78 |
+
</models>
|
79 |
+
<events>
|
80 |
+
<controller_action_predispatch>
|
81 |
+
<observers>
|
82 |
+
<notforsale_install>
|
83 |
+
<class>Ifuturz_Notforsale_Model_Observer</class>
|
84 |
+
<method>checkInstallation</method>
|
85 |
+
</notforsale_install>
|
86 |
+
</observers>
|
87 |
+
</controller_action_predispatch>
|
88 |
+
</events>
|
89 |
+
</global>
|
90 |
+
</config>
|
app/code/local/Ifuturz/Notforsale/sql/notforsale_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Ifuturz_Notforsale
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$attributeInstaller = new Mage_Catalog_Model_Resource_Setup();
|
9 |
+
|
10 |
+
$attributeInstaller->addAttribute('catalog_product', 'not_for_sale_to', array(
|
11 |
+
'type' => 'varchar',
|
12 |
+
'backend' => '',
|
13 |
+
'frontend' => '',
|
14 |
+
'label' => 'Not For Sale To',
|
15 |
+
'input' => 'multiselect',
|
16 |
+
'class' => '',
|
17 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
18 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => false,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => true,
|
27 |
+
'unique' => false,
|
28 |
+
'group' => 'General',
|
29 |
+
'apply_to' => 'simple'
|
30 |
+
));
|
31 |
+
|
32 |
+
$attributeId = $attributeInstaller->getAttributeId('catalog_product', 'not_for_sale_to');
|
33 |
+
|
34 |
+
$aOption = array();
|
35 |
+
$aOption['attribute_id'] = $attributeId;
|
36 |
+
$regionCollection = Mage::getModel('directory/region_api')->items('US');
|
37 |
+
|
38 |
+
$i=0;
|
39 |
+
foreach($regionCollection as $regionData)
|
40 |
+
{
|
41 |
+
$aOption['value']['option'.$i][0] = $regionData['code'];
|
42 |
+
$i++;
|
43 |
+
}
|
44 |
+
$attributeInstaller->addAttributeOption($aOption);
|
45 |
+
|
46 |
+
|
47 |
+
foreach ($attributeInstaller->getAllAttributeSetIds('catalog_product') as $attributeSetId)
|
48 |
+
{
|
49 |
+
try {
|
50 |
+
$attributeGroupId = $attributeInstaller->getAttributeGroupId('catalog_product', $attributeSetId, 'General');
|
51 |
+
} catch (Exception $e) {
|
52 |
+
$attributeGroupId = $attributeInstaller->getDefaultAttributeGroupId('catalog_product', $attributeSetId);
|
53 |
+
}
|
54 |
+
$attributeInstaller->addAttributeToSet('catalog_product', $attributeSetId, $attributeGroupId, $attributeId);
|
55 |
+
}
|
56 |
+
|
57 |
+
$installer->run("
|
58 |
+
|
59 |
+
-- DROP TABLE IF EXISTS {$this->getTable('notforsale_lck')};
|
60 |
+
CREATE TABLE {$this->getTable('notforsale_lck')} (
|
61 |
+
`flag` varchar(4),
|
62 |
+
`value` ENUM('0','1') DEFAULT '0' NOT NULL
|
63 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
64 |
+
|
65 |
+
INSERT INTO `{$installer->getTable('notforsale_lck')}` VALUES ('LCK','1');
|
66 |
+
");
|
67 |
+
|
68 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/notforsale.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<checkout_cart_index>
|
4 |
+
<reference name="checkout.cart">
|
5 |
+
<action method="addItemRender">
|
6 |
+
<type>simple</type><block>checkout/cart_item_renderer</block><template>notforsale/item/default.phtml</template>
|
7 |
+
</action>
|
8 |
+
<action method="addItemRender">
|
9 |
+
<type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>notforsale/item/default.phtml</template>
|
10 |
+
</action>
|
11 |
+
<action method="addItemRender">
|
12 |
+
<type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>notforsale/item/default.phtml</template></action>
|
13 |
+
</reference>
|
14 |
+
</checkout_cart_index>
|
15 |
+
</layout>
|
app/etc/modules/Ifuturz_Notforsale.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--/**
|
2 |
+
* @package Ifuturz_Notforsale
|
3 |
+
*/-->
|
4 |
+
<config>
|
5 |
+
<modules>
|
6 |
+
<Ifuturz_Notforsale>
|
7 |
+
<active>true</active>
|
8 |
+
<codePool>local</codePool>
|
9 |
+
</Ifuturz_Notforsale>
|
10 |
+
</modules>
|
11 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ifuturz_Notforsale</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Some clients need to restrict their specific products for sale to specific states. This extension will let you restrict your products for sale to US states.</summary>
|
10 |
+
<description>More Flexible Approach to Restrict the Product for Sale in US states
|
11 |
+

|
12 |
+
- Some clients need to restrict their specific products for sale to specific states. This extension will let you restrict your products for sale to US states.
|
13 |
+

|
14 |
+
- The admin will have to select the restricted state(s) for the products he wants to filter from the admin panel.
|
15 |
+

|
16 |
+
- As per the attribute set by the admin, the product will not be sold to the specified state(s).
|
17 |
+

|
18 |
+
For Example: The admin has restricted his “XYZ” product for the states CA(California) and FL(Florida) from the admin panel.
|
19 |
+

|
20 |
+
Now, on front end when the user buys the product “ABC”, and he selects the state CA or FL for shipping, then he/she will be notified via message that this product cannot be shipped to CA state (that is, the state the user selected for the shipping).
|
21 |
+

|
22 |
+
- When the user traverses to the cart page, there will be label like “Not for sale to state: XXX” under the added cart product
|
23 |
+

|
24 |
+
- Even on the check out page, it is also checked that the shipping state is restricted for the specific products. Still, if the user clicks on “Place Order” button, the popup will appear with the message notifying that the product cannot be shipped to “ABC” state. 
|
25 |
+
</description>
|
26 |
+
<notes>This is first stable version</notes>
|
27 |
+
<authors><author><name>Iverve</name><user>iverve</user><email>extension.geek@ifuturz.com</email></author></authors>
|
28 |
+
<date>2015-01-28</date>
|
29 |
+
<time>08:48:37</time>
|
30 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Ifuturz_Notforsale.xml" hash="35344cfeced9cfc344ebcebbe0fae1bf"/></dir></target><target name="magelocal"><dir name="Ifuturz"><dir name="Notforsale"><dir name="Block"><file name="Notforsale.php" hash="48afe8adfbdbdd8cc0d231221c912eda"/></dir><dir name="Helper"><dir name="Catalog"><dir name="Product"><file name="Configuration.php" hash="47706019ff75b8605a6713b4649ce252"/></dir></dir><file name="Data.php" hash="c59ca56fdd9777b9bd9a104e1ad9d3f0"/><dir name="Product"><file name="Configuration.php" hash="dc54fea3cd51a9b88a9a11e382f36582"/></dir></dir><dir name="Model"><file name="Observer.php" hash="18593e5d96ef7dbf6fe033f067dc90c3"/></dir><dir name="controllers"><file name="CartController.php" hash="ad502343e67f787ad31706587df12074"/><file name="IndexController.php" hash="3c529a539ce12dd34792f5874d06fb94"/><file name="OnepageController.php" hash="ef2f8e4ffa2bd42564f6febdbb397332"/></dir><dir name="etc"><file name="config.xml" hash="eb8dfb90191a8580774edcfa4acb8ebb"/></dir><dir name="sql"><dir name="notforsale_setup"><file name="mysql4-install-0.1.0.php" hash="6d59a731a75001a4154a721d944da306"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="notforsale.xml" hash="e43fb16d76de674d5e47a4c61515c516"/></dir></dir></dir></dir></target></contents>
|
31 |
+
<compatible/>
|
32 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
33 |
+
</package>
|