Version Notes
There are no uploaded releases
Download this release
Release Info
Developer | Satish Mantri |
Extension | Oscprofessionals_Flatship |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Oscprofessionals/Flatship/Helper/Data.php +78 -0
- app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Country.php +28 -0
- app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Option.php +40 -0
- app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Priority.php +39 -0
- app/code/community/Oscprofessionals/Flatship/Model/Carrier/Oscpflatshiprate.php +292 -0
- app/code/community/Oscprofessionals/Flatship/etc/config.xml +74 -0
- app/code/community/Oscprofessionals/Flatship/etc/system.xml +148 -0
- app/code/community/Oscprofessionals/Flatship/sql/oscpflatshiprate_setup/install-1.0.0.php +63 -0
- app/etc/modules/Oscprofessionals_Flatship.xml +12 -0
- package.xml +25 -0
app/code/community/Oscprofessionals/Flatship/Helper/Data.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
6 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*
|
9 |
+
* @category Oscprofessionals
|
10 |
+
* @package Oscprofessionals_Flatship
|
11 |
+
*/
|
12 |
+
|
13 |
+
class Oscprofessionals_Flatship_Helper_Data extends Mage_Core_Helper_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
const XML_PATH_ENABLE = 'carriers/oscpflatshiprate/active';
|
17 |
+
CONST XML_PATH_MODE = 'carriers/oscpflatshiprate/shipping_mode';
|
18 |
+
const XML_PATH_CUSTOMER_GROUP_ENABLE = 'carriers/oscpflatshiprate/customer_group';
|
19 |
+
const XML_PATH_CUSTOMER_GROUP_ID = 'carriers/oscpflatshiprate/customer_group_id';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Check module is enable or not
|
23 |
+
* @param (null) storeId
|
24 |
+
* @return boolean
|
25 |
+
*/
|
26 |
+
public function isEnable($storeId = null)
|
27 |
+
{
|
28 |
+
if (is_null($storeId))
|
29 |
+
{
|
30 |
+
$storeId = Mage::app()->getStore()->getId();
|
31 |
+
}
|
32 |
+
return Mage::getStoreConfig(self::XML_PATH_ENABLE, $storeId);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check shipping method mode type either Category or Product
|
37 |
+
* @param (null) storeId
|
38 |
+
* @return $modeType (string)
|
39 |
+
*/
|
40 |
+
Public function getMode($storeId = null)
|
41 |
+
{
|
42 |
+
if (is_null($storeId))
|
43 |
+
{
|
44 |
+
$storeId = Mage::app()->getStore()->getId();
|
45 |
+
}
|
46 |
+
return Mage::getStoreConfig(self::XML_PATH_MODE, $storeId);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Check customer group is enable or not
|
51 |
+
* @param (null) storeId
|
52 |
+
* @return boolean
|
53 |
+
*/
|
54 |
+
public function isAllowedCustomerGroup($storeId = null)
|
55 |
+
{
|
56 |
+
if (is_null($storeId))
|
57 |
+
{
|
58 |
+
$storeId = Mage::app()->getStore()->getId();
|
59 |
+
}
|
60 |
+
return Mage::getStoreConfig(self::XML_PATH_CUSTOMER_GROUP_ENABLE, $storeId);
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* get customer group Id
|
66 |
+
* @param (null) storeId
|
67 |
+
* @return boolean
|
68 |
+
*/
|
69 |
+
public function getCustomerGroupId($storeId = null)
|
70 |
+
{
|
71 |
+
if (is_null($storeId))
|
72 |
+
{
|
73 |
+
$storeId = Mage::app()->getStore()->getId();
|
74 |
+
}
|
75 |
+
return Mage::getStoreConfig(self::XML_PATH_CUSTOMER_GROUP_ID, $storeId);
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Country.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
5 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @category Oscprofessionals
|
9 |
+
* @package Oscprofessionals_Flatship
|
10 |
+
*/
|
11 |
+
class Oscprofessionals_Flatship_Model_Adminhtml_System_Config_Source_Country
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $_options;
|
15 |
+
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
if (!$this->_options) {
|
19 |
+
$this->_options = Mage::getResourceModel('customer/group_collection')
|
20 |
+
//->setRealGroupsFilter()
|
21 |
+
->loadData()->toOptionArray();
|
22 |
+
array_unshift($this->_options, array('value'=> '', 'label'=> '-- Please Select --'));
|
23 |
+
}
|
24 |
+
return $this->_options;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
|
app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Option.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
5 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @category Oscprofessionals
|
9 |
+
* @package Oscprofessionals_Flatship
|
10 |
+
*/
|
11 |
+
class Oscprofessionals_Flatship_Model_Adminhtml_System_Config_Source_Option
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Options getter
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
return array(
|
22 |
+
array('value' => 'product', 'label'=>Mage::helper('adminhtml')->__('Product')),
|
23 |
+
array('value' => 'category', 'label'=>Mage::helper('adminhtml')->__('Category')),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get options in "key-value" format
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function toArray()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
0 => Mage::helper('adminhtml')->__('Product'),
|
36 |
+
1 => Mage::helper('adminhtml')->__('Category'),
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/community/Oscprofessionals/Flatship/Model/Adminhtml/System/Config/Source/Priority.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
5 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @category Oscprofessionals
|
9 |
+
* @package Oscprofessionals_Flatship
|
10 |
+
*/
|
11 |
+
class Oscprofessionals_Flatship_Model_Adminhtml_System_Config_Source_Priority
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Options getter
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
return array(
|
22 |
+
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('High')),
|
23 |
+
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Low')),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get options in "key-value" format
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function toArray()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
0 => Mage::helper('adminhtml')->__('High'),
|
36 |
+
1 => Mage::helper('adminhtml')->__('Low'),
|
37 |
+
);
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Oscprofessionals/Flatship/Model/Carrier/Oscpflatshiprate.php
ADDED
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Collect the rates based on Category and Product
|
5 |
+
*
|
6 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
7 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
+
*
|
10 |
+
* @category Oscprofessionals
|
11 |
+
* @package Oscprofessionals_Flatship
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Oscprofessionals_Flatship_Model_Carrier_Oscpflatshiprate
|
15 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
16 |
+
implements Mage_Shipping_Model_Carrier_Interface {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Carrier's code
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $_code = 'oscpflatshiprate';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Whether this carrier has fixed rates calculation
|
27 |
+
*
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
protected $_isFixed = true;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Default condition name
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
protected $_default_condition_name = 'products';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Collect and get rates
|
41 |
+
*
|
42 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
43 |
+
* @return Rate Result|Method|Price
|
44 |
+
*/
|
45 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
46 |
+
{
|
47 |
+
|
48 |
+
// return if module disable
|
49 |
+
if(!Mage::helper('oscpflatshiprate')->isEnable()){
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
//Add shipping Title
|
53 |
+
$shippingTitle = $this->getConfigData('title');
|
54 |
+
|
55 |
+
//Add shipping Name
|
56 |
+
$methodTitle = $this->getConfigData('name');
|
57 |
+
|
58 |
+
//Add shipping Default Price
|
59 |
+
$shippingRate = $this->getConfigData('price');
|
60 |
+
|
61 |
+
//shipping Mode type category/product
|
62 |
+
$shippingMode = Mage::helper('oscpflatshiprate')->getMode();
|
63 |
+
|
64 |
+
// if not shipping mode the set default
|
65 |
+
$shippingMode = $shippingMode ? $shippingMode : $this->_default_condition_name;
|
66 |
+
|
67 |
+
// get customer group Enable
|
68 |
+
$customerGroupEnable = Mage::helper('oscpflatshiprate')->isAllowedCustomerGroup();
|
69 |
+
|
70 |
+
//collect selected customer group id
|
71 |
+
$shipCustomerGroupId = Mage::helper('oscpflatshiprate')->getCustomerGroupId();
|
72 |
+
$shipCustomerIdArray = explode(',',$shipCustomerGroupId);
|
73 |
+
|
74 |
+
|
75 |
+
//get allow country status.
|
76 |
+
$allowscountry = $this->getConfigData('sallowspecific');
|
77 |
+
|
78 |
+
//get session customer group id
|
79 |
+
$customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
80 |
+
|
81 |
+
try {
|
82 |
+
$shippingPrice = '';
|
83 |
+
|
84 |
+
switch ($shippingMode){
|
85 |
+
|
86 |
+
case 'category':
|
87 |
+
if((!in_array($customerGroupId,$shipCustomerIdArray)) && ($customerGroupEnable==1)){
|
88 |
+
return false;
|
89 |
+
}else{
|
90 |
+
//category based shipping rate
|
91 |
+
$shippingPrice = $this->_collectCategoryRates($request);
|
92 |
+
|
93 |
+
}
|
94 |
+
break;
|
95 |
+
|
96 |
+
default:
|
97 |
+
if((!in_array($customerGroupId,$shipCustomerIdArray)) && ($customerGroupEnable==1)){
|
98 |
+
return false;
|
99 |
+
}else{
|
100 |
+
//product based shipping rate
|
101 |
+
$shippingPrice = $this->_collectProductRates($request);
|
102 |
+
|
103 |
+
}
|
104 |
+
break;
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
if ((isset($shippingPrice) && $shippingPrice == '') || (!isset($shippingPrice))) {
|
110 |
+
$shippingPrice = $shippingRate;
|
111 |
+
}
|
112 |
+
|
113 |
+
$result = $this->_getModel('shipping/rate_result');
|
114 |
+
$method = $this->_getModel('shipping/rate_result_method');
|
115 |
+
$method->setCarrier($this->_code);
|
116 |
+
$method->setCarrierTitle($shippingTitle);
|
117 |
+
$method->setMethod($this->_code);
|
118 |
+
$method->setMethodTitle($methodTitle);
|
119 |
+
$method->setPrice($shippingPrice);
|
120 |
+
|
121 |
+
$result->append($method);
|
122 |
+
return $result;
|
123 |
+
|
124 |
+
} catch (Exception $e) {
|
125 |
+
Mage::printException($e);
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Get Model
|
132 |
+
*
|
133 |
+
* @param string $modelName
|
134 |
+
*
|
135 |
+
* @return Mage_Core_Model_Abstract
|
136 |
+
*/
|
137 |
+
protected function _getModel($modelName)
|
138 |
+
{
|
139 |
+
return Mage::getModel($modelName);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Collect categories shipping rates
|
144 |
+
*
|
145 |
+
* @Param Mage_Shipping_Model_Rate_Request $request
|
146 |
+
* @return Category Rate
|
147 |
+
*
|
148 |
+
*/
|
149 |
+
private function _collectCategoryRates($request)
|
150 |
+
{
|
151 |
+
|
152 |
+
$shipPrice = '';
|
153 |
+
//Add shipping Default Price
|
154 |
+
$shippingRateDefault = $this->getConfigData('price');
|
155 |
+
//get shipping category priority
|
156 |
+
$categoryPriority = $this->getConfigData('categorypriority');
|
157 |
+
if ($request->getAllItems()) {
|
158 |
+
foreach ($request->getAllItems() as $item) {
|
159 |
+
if ($item->getHasChildren()) {
|
160 |
+
$productSku = $item->getProduct()->getData('sku');
|
161 |
+
} else {
|
162 |
+
$productSku = $item->getSku();
|
163 |
+
}
|
164 |
+
|
165 |
+
if(!$item->getProduct()->isConfigurable()){
|
166 |
+
|
167 |
+
$_product = $this->_getModel('catalog/product')
|
168 |
+
->loadByAttribute('sku', $productSku);
|
169 |
+
|
170 |
+
$cartProductCatId = $_product->getCategoryIds();
|
171 |
+
|
172 |
+
$count =0;
|
173 |
+
$indivShipPrice = array();
|
174 |
+
$cateShippingPriceFinal = '';
|
175 |
+
foreach ($cartProductCatId as $categoryID) {
|
176 |
+
$cateShippingPrice = '';
|
177 |
+
$categoryData = $this->_getModel("catalog/category")
|
178 |
+
->load($categoryID);
|
179 |
+
$cateShippingPrice = $categoryData['shipping_cost'];
|
180 |
+
|
181 |
+
//if shiiping cost is set then store the shipping cost of each category in $indivShipPrice array
|
182 |
+
if($cateShippingPrice !=''){
|
183 |
+
$cateShippingPriceFinal = $cateShippingPrice;
|
184 |
+
$indivShipPrice[] = $cateShippingPriceFinal;
|
185 |
+
}
|
186 |
+
//Set shipping method price as per the category priority selected i.e. high or low
|
187 |
+
if($count > 0 && isset($cateShippingPrice) && $cateShippingPrice!=''){
|
188 |
+
//Mage::log('',null,);
|
189 |
+
|
190 |
+
if($categoryPriority == 1){
|
191 |
+
|
192 |
+
$shipPrice = max(array_values($indivShipPrice));
|
193 |
+
}
|
194 |
+
elseif($categoryPriority == 0){
|
195 |
+
|
196 |
+
$shipPrice = min(array_values($indivShipPrice));
|
197 |
+
}
|
198 |
+
}
|
199 |
+
elseif(isset($cateShippingPrice) && $cateShippingPrice!='' && ($cateShippingPrice>0)){
|
200 |
+
|
201 |
+
$shipPrice = $cateShippingPrice;
|
202 |
+
}
|
203 |
+
elseif(!isset($cateShippingPrice) && $cateShippingPrice==''){
|
204 |
+
$shipPrice = (float)$shippingRateDefault;
|
205 |
+
}
|
206 |
+
$count++;
|
207 |
+
}
|
208 |
+
|
209 |
+
$shippingPrice += (float)$shipPrice;
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
213 |
+
//Mage::log("Query cat: ".print_r($indivShipPrice, true),null,'tt1.log');
|
214 |
+
}
|
215 |
+
return $shippingPrice;
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Collect products shipping rates
|
221 |
+
*
|
222 |
+
* @Param Mage_Shipping_Model_Rate_Request $request
|
223 |
+
* @return Product Rate
|
224 |
+
*
|
225 |
+
*/
|
226 |
+
private function _collectProductRates($request)
|
227 |
+
{
|
228 |
+
//0=> not depned on qty , 1=>Yes multiply with qty.
|
229 |
+
$shippingQtyBased = $this->getConfigData('shippingqty_base');
|
230 |
+
//Add shipping Default Price
|
231 |
+
$shippingRateDefault = 0;
|
232 |
+
$shippingPrice = 0;
|
233 |
+
$shippingPriceProduct = 0;
|
234 |
+
$productShippingCost = 0;
|
235 |
+
if ($request->getAllItems()) {
|
236 |
+
|
237 |
+
foreach ($request->getAllItems() as $item) {
|
238 |
+
if(!$item->getProduct()->isConfigurable()){
|
239 |
+
$productShippingCost = 0;
|
240 |
+
//get product order quantity
|
241 |
+
$productOrderQty = $item->getQty();
|
242 |
+
|
243 |
+
if ($item->getHasChildren()) {
|
244 |
+
$productSku = $item->getProduct()->getData('sku');
|
245 |
+
} else {
|
246 |
+
$productSku = $item->getSku();
|
247 |
+
}
|
248 |
+
|
249 |
+
$_product = $this->_getModel('catalog/product')
|
250 |
+
->loadByAttribute('sku', $productSku);
|
251 |
+
$products = $_product->getData();
|
252 |
+
if(!empty($products['shipping_cost']) && isset($products['shipping_cost'])){
|
253 |
+
$productShippingCost = $products['shipping_cost'];
|
254 |
+
|
255 |
+
} else {
|
256 |
+
$shippingRateDefault = $this->getConfigData('price');
|
257 |
+
$productShippingCost = $shippingRateDefault;
|
258 |
+
|
259 |
+
}
|
260 |
+
if ($shippingQtyBased == 1) {
|
261 |
+
//Multiply with product qty
|
262 |
+
$shippingPriceProduct = $productShippingCost * $productOrderQty;
|
263 |
+
}else{
|
264 |
+
//Not with product qty
|
265 |
+
$shippingPriceProduct = $productShippingCost;
|
266 |
+
}
|
267 |
+
$shippingPrice += (float)$shippingPriceProduct;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}//end if
|
271 |
+
return $shippingPrice;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Get allowed shipping methods
|
276 |
+
*
|
277 |
+
* @return array
|
278 |
+
*/
|
279 |
+
public function getAllowedMethods()
|
280 |
+
{
|
281 |
+
return array('oscpflatshiprate'=>$this->getConfigData('name'));
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
|
286 |
+
|
287 |
+
|
288 |
+
|
289 |
+
|
290 |
+
|
291 |
+
|
292 |
+
|
app/code/community/Oscprofessionals/Flatship/etc/config.xml
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
6 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*
|
9 |
+
* @category Oscprofessionals
|
10 |
+
* @package Oscprofessionals_Flatship
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<Oscprofessionals_Flatship>
|
15 |
+
<version>1.0.0</version>
|
16 |
+
</Oscprofessionals_Flatship>
|
17 |
+
</modules>
|
18 |
+
<admin>
|
19 |
+
<translate>
|
20 |
+
<modules>
|
21 |
+
<Oscprofessionals_Flatship>
|
22 |
+
<files>
|
23 |
+
<default>Oscprofessionals_Flatship.csv</default>
|
24 |
+
</files>
|
25 |
+
</Oscprofessionals_Flatship>
|
26 |
+
</modules>
|
27 |
+
</translate>
|
28 |
+
</admin>
|
29 |
+
<global>
|
30 |
+
<models>
|
31 |
+
<oscpflatshiprate>
|
32 |
+
<class>Oscprofessionals_Flatship_Model</class>
|
33 |
+
</oscpflatshiprate>
|
34 |
+
</models>
|
35 |
+
<resources>
|
36 |
+
<oscpflatshiprate_setup>
|
37 |
+
<setup>
|
38 |
+
<module>Oscprofessionals_Flatship</module>
|
39 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
40 |
+
</setup>
|
41 |
+
<connection>
|
42 |
+
<use>core_setup</use>
|
43 |
+
</connection>
|
44 |
+
</oscpflatshiprate_setup>
|
45 |
+
<oscpflatshiprate_write>
|
46 |
+
<connection>
|
47 |
+
<use>core_write</use>
|
48 |
+
</connection>
|
49 |
+
</oscpflatshiprate_write>
|
50 |
+
<oscpflatshiprate_read>
|
51 |
+
<connection>
|
52 |
+
<use>core_read</use>
|
53 |
+
</connection>
|
54 |
+
</oscpflatshiprate_read>
|
55 |
+
</resources>
|
56 |
+
<helpers>
|
57 |
+
<oscpflatshiprate>
|
58 |
+
<class>Oscprofessionals_Flatship_Helper</class>
|
59 |
+
</oscpflatshiprate>
|
60 |
+
</helpers>
|
61 |
+
</global>
|
62 |
+
<default>
|
63 |
+
<carriers>
|
64 |
+
<oscpflatshiprate>
|
65 |
+
<active>1</active>
|
66 |
+
<model>oscpflatshiprate/carrier_oscpflatshiprate</model>
|
67 |
+
<title>Carrier Title</title>
|
68 |
+
<name>Shipping Method Name</name>
|
69 |
+
<price>0.00</price>
|
70 |
+
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
71 |
+
</oscpflatshiprate>
|
72 |
+
</carriers>
|
73 |
+
</default>
|
74 |
+
</config>
|
app/code/community/Oscprofessionals/Flatship/etc/system.xml
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
6 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*
|
9 |
+
* @category Oscprofessionals
|
10 |
+
* @package Oscprofessionals_Flatship
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<sections>
|
14 |
+
<carriers>
|
15 |
+
<groups>
|
16 |
+
<oscpflatshiprate translate="label" module="oscpflatshiprate">
|
17 |
+
<label>Oscp Flat rate per Category and Product</label>
|
18 |
+
<frontend_type>text</frontend_type>
|
19 |
+
<sort_order>0</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
<fields>
|
24 |
+
<active translate="label">
|
25 |
+
<label>Enabled</label>
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>1</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
</active>
|
33 |
+
<title translate="label">
|
34 |
+
<label>Title</label>
|
35 |
+
<frontend_type>text</frontend_type>
|
36 |
+
<sort_order>2</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
</title>
|
41 |
+
<name translate="label">
|
42 |
+
<label>Shipping Method Name</label>
|
43 |
+
<frontend_type>text</frontend_type>
|
44 |
+
<sort_order>2</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
</name>
|
49 |
+
<price translate="label">
|
50 |
+
<label>Price</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>3</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</price>
|
57 |
+
<specificerrmsg translate="label">
|
58 |
+
<label>Displayed Error Message</label>
|
59 |
+
<frontend_type>textarea</frontend_type>
|
60 |
+
<sort_order>4</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>1</show_in_store>
|
64 |
+
</specificerrmsg>
|
65 |
+
<shipping_mode translate="label">
|
66 |
+
<label>Shipping Applied</label>
|
67 |
+
<comment>Select Category Product Shipping type</comment>
|
68 |
+
<frontend_type>select</frontend_type>
|
69 |
+
<source_model>oscpflatshiprate/adminhtml_system_config_source_option</source_model>
|
70 |
+
<sort_order>13</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>1</show_in_store>
|
74 |
+
</shipping_mode>
|
75 |
+
<shippingqty_base translate="label">
|
76 |
+
<label>Shipping per product qty</label>
|
77 |
+
<frontend_type>select</frontend_type>
|
78 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
79 |
+
<sort_order>14</sort_order>
|
80 |
+
<show_in_default>1</show_in_default>
|
81 |
+
<show_in_website>1</show_in_website>
|
82 |
+
<show_in_store>1</show_in_store>
|
83 |
+
<depends><shipping_mode>product</shipping_mode></depends>
|
84 |
+
</shippingqty_base>
|
85 |
+
<categorypriority translate="label">
|
86 |
+
<label>Shipping by category</label>
|
87 |
+
<frontend_type>select</frontend_type>
|
88 |
+
<source_model>oscpflatshiprate/adminhtml_system_config_source_priority</source_model>
|
89 |
+
<sort_order>14</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
<depends><shipping_mode>category</shipping_mode></depends>
|
94 |
+
</categorypriority>
|
95 |
+
<customer_group translate="label">
|
96 |
+
<label>Enable Customer Group</label>
|
97 |
+
<comment>Enable customer group type</comment>
|
98 |
+
<frontend_type>select</frontend_type>
|
99 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
100 |
+
<sort_order>15</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
</customer_group>
|
105 |
+
<customer_group_id translate="label">
|
106 |
+
<label>Customer Group</label>
|
107 |
+
<frontend_type>multiselect</frontend_type>
|
108 |
+
<source_model>oscpflatshiprate/adminhtml_system_config_source_country</source_model>
|
109 |
+
<sort_order>16</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
<depends><customer_group>1</customer_group></depends>
|
114 |
+
</customer_group_id>
|
115 |
+
<sallowspecific translate="label">
|
116 |
+
<label>Ship to Applicable Countries</label>
|
117 |
+
<frontend_type>select</frontend_type>
|
118 |
+
<sort_order>17</sort_order>
|
119 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
120 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<show_in_store>1</show_in_store>
|
124 |
+
</sallowspecific>
|
125 |
+
<specificcountry translate="label">
|
126 |
+
<label>Ship to Specific Countries</label>
|
127 |
+
<frontend_type>multiselect</frontend_type>
|
128 |
+
<sort_order>18</sort_order>
|
129 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
130 |
+
<show_in_default>1</show_in_default>
|
131 |
+
<show_in_website>1</show_in_website>
|
132 |
+
<show_in_store>1</show_in_store>
|
133 |
+
<can_be_empty>1</can_be_empty>
|
134 |
+
</specificcountry>
|
135 |
+
<sort_order translate="label">
|
136 |
+
<label>Sort Order</label>
|
137 |
+
<frontend_type>text</frontend_type>
|
138 |
+
<sort_order>100</sort_order>
|
139 |
+
<show_in_default>1</show_in_default>
|
140 |
+
<show_in_website>1</show_in_website>
|
141 |
+
<show_in_store>1</show_in_store>
|
142 |
+
</sort_order>
|
143 |
+
</fields>
|
144 |
+
</oscpflatshiprate>
|
145 |
+
</groups>
|
146 |
+
</carriers>
|
147 |
+
</sections>
|
148 |
+
</config>
|
app/code/community/Oscprofessionals/Flatship/sql/oscpflatshiprate_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @author Oscprofessionals Team (support@oscprofessionals.com)
|
5 |
+
* @copyright Copyright (c) 2014 Oscprofessionals (http://www.oscprofessionals.com)
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*
|
8 |
+
* @category Oscprofessionals
|
9 |
+
* @package Oscprofessionals_Flatship
|
10 |
+
*/
|
11 |
+
|
12 |
+
$installer = $this;
|
13 |
+
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
$installer->addAttribute("catalog_category", "shipping_cost", array (
|
17 |
+
"group" => 'Category Shipping',
|
18 |
+
"type" => "decimal",
|
19 |
+
"backend" => "",
|
20 |
+
"frontend" => "",
|
21 |
+
"label" => "Shipping Cost",
|
22 |
+
"input" => "text",
|
23 |
+
"class" => "",
|
24 |
+
"source" => "",
|
25 |
+
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
26 |
+
"visible" => true,
|
27 |
+
"required" => false,
|
28 |
+
"user_defined" => false,
|
29 |
+
"default" => "",
|
30 |
+
"searchable" => false,
|
31 |
+
"filterable" => false,
|
32 |
+
"comparable" => false,
|
33 |
+
"visible_on_front" => false,
|
34 |
+
"unique" => false,
|
35 |
+
)
|
36 |
+
);
|
37 |
+
$installer->addAttribute('catalog_product', 'shipping_cost', array(
|
38 |
+
'group' => 'General',
|
39 |
+
'type' => 'decimal',
|
40 |
+
'backend' => '',
|
41 |
+
'frontend' => '',
|
42 |
+
'label' => 'Shipping Cost',
|
43 |
+
'input' => 'text',
|
44 |
+
'class' => '',
|
45 |
+
'source' => '',
|
46 |
+
'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
47 |
+
'visible' => true,
|
48 |
+
'required' => false,
|
49 |
+
'user_defined' => false,
|
50 |
+
'default' => '0',
|
51 |
+
'searchable' => false,
|
52 |
+
'filterable' => false,
|
53 |
+
'comparable' => false,
|
54 |
+
'visible_on_front' => false,
|
55 |
+
'unique' => false,
|
56 |
+
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
|
57 |
+
'is_configurable' => false,
|
58 |
+
'used_in_product_listing', '1'
|
59 |
+
));
|
60 |
+
|
61 |
+
$installer->updateAttribute('catalog_product', 'shipping_cost', 'used_in_product_listing', '1');
|
62 |
+
|
63 |
+
$installer->endSetup();
|
app/etc/modules/Oscprofessionals_Flatship.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Oscprofessionals_Flatship>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Shipping />
|
9 |
+
</depends>
|
10 |
+
</Oscprofessionals_Flatship>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Oscprofessionals_Flatship</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Shipping Based On Category And Product Module allows Admin to add different shipping price for each simple product or category. This extension support all the simple product. On checkout page total shipping charges will display, by calculating shipping charges of each product.</summary>
|
10 |
+
<description>Shipping Based On Category And Product Module allows Admin to add different shipping price for each simple product or category. This extension support all the simple product. On checkout page total shipping charges will display, by calculating shipping charges of each product.
|
11 |
+
This also gives option for:
|
12 |
+

|
13 |
+
Making the sum of all simple products.
|
14 |
+
Making the sum of all products with quantity increased.
|
15 |
+
Setting a default shipping rates(Applied if shipping price is not defined in category or product).
|
16 |
+
Shipping applied on the base of customer group
|
17 |
+
Shipping allow to applicable countries</description>
|
18 |
+
<notes>There are no uploaded releases</notes>
|
19 |
+
<authors><author><name>Satish Mantri</name><user>satish</user><email>satish@oscprofessionals.com</email></author></authors>
|
20 |
+
<date>2015-07-29</date>
|
21 |
+
<time>16:48:16</time>
|
22 |
+
<contents><target name="magecommunity"><dir name="Oscprofessionals"><dir name="Flatship"><dir name="Helper"><file name="Data.php" hash="d58da9e786ec93faa594dc8f8160e902"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="176b99bb4ad02557a0dac2e23b5a0e08"/><file name="Option.php" hash="31146964ee2ce01e3d2df61d6769cdf9"/><file name="Priority.php" hash="e01a11c7284f7b540ebea92d7949a419"/></dir></dir></dir></dir><dir name="Carrier"><file name="Oscpflatshiprate.php" hash="0d685a8f2a80213534684c270c7cd51f"/></dir></dir><dir name="etc"><file name="config.xml" hash="7bbf192e5395f34a9d1d58eee1004f69"/><file name="system.xml" hash="da1341452576f54d15f7225ac96cf8ca"/></dir><dir name="sql"><dir name="oscpflatshiprate_setup"><file name="install-1.0.0.php" hash="9a9a0265378435879561dbc0564970c4"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Oscprofessionals_Flatship.xml" hash="acb9c33dd3273ef9fddbac8f7662ebf1"/></dir></target></contents>
|
23 |
+
<compatible/>
|
24 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
25 |
+
</package>
|