Version Notes
- bug fixes
- added support for Magento coupons
Download this release
Release Info
| Developer | ShipHawk |
| Extension | ShipHawk |
| Version | 2.2.0 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.0 to 2.2.0
- app/code/community/Shiphawk/.DS_Store +0 -0
- app/code/community/Shiphawk/Checkout/Model/Cart.php +51 -0
- app/code/community/Shiphawk/MyCarrier/Model/Carrier.php +116 -23
- app/code/community/Shiphawk/MyCarrier/Model/Freemethod.php +68 -0
- app/code/community/Shiphawk/MyCarrier/etc/config.xml +1 -1
- app/code/community/Shiphawk/MyCarrier/etc/system.xml +14 -1
- app/code/community/Shiphawk/Order/Model/.DS_Store +0 -0
- app/code/community/Shiphawk/Order/Model/Command/SendOrder.php +26 -14
- app/code/community/Shiphawk/Order/Model/Cron/ProcessOrderForLast14Days.php +1 -1
- app/code/community/Shiphawk/Order/etc/config.xml +1 -1
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins.php +12 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Edit.php +27 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Edit/Form.php +140 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Grid.php +97 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/Shipment/View.php +20 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/View.php +45 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/Shipment.php +623 -0
- app/code/community/Shiphawk/Shipping/Block/Adminhtml/System/Config/Form/Button.php +50 -0
- app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Disabled.php +14 -0
- app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Type.php +64 -0
- app/code/community/Shiphawk/Shipping/Block/Shipping/Tracking/Popup.php +10 -0
- app/code/community/Shiphawk/Shipping/Block/Version.php +14 -0
- app/code/community/Shiphawk/Shipping/Helper/Data.php +489 -0
- app/code/community/Shiphawk/Shipping/Helper/Origin.php +76 -0
- app/code/community/Shiphawk/Shipping/Model/Api.php +636 -0
- app/code/community/Shiphawk/Shipping/Model/Carrier.php +996 -0
- app/code/community/Shiphawk/Shipping/Model/Observer.php +371 -0
- app/code/community/Shiphawk/Shipping/Model/Origins.php +9 -0
- app/code/community/Shiphawk/Shipping/Model/Product/Attribute/Source/Location.php +25 -0
- app/code/community/Shiphawk/Shipping/Model/Resource/Origins.php +8 -0
- app/code/community/Shiphawk/Shipping/Model/Resource/Origins/Collection.php +8 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Adminratefilter.php +11 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Carriertype.php +15 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Freeshipping.php +12 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Gateway.php +11 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Location.php +11 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Ratefilter.php +15 -0
- app/code/community/Shiphawk/Shipping/Model/Source/Received.php +11 -0
- app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ImportController.php +87 -0
- app/code/community/Shiphawk/Shipping/controllers/Adminhtml/OriginsController.php +133 -0
- app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ShipmentController.php +331 -0
- app/code/community/Shiphawk/Shipping/controllers/IndexController.php +212 -0
- app/code/community/Shiphawk/Shipping/etc/adminhtml.xml +16 -0
- app/code/community/Shiphawk/Shipping/etc/config.xml +243 -0
- app/code/community/Shiphawk/Shipping/etc/system.xml +369 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-install-0.1.0.php +269 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.0-0.7.1.php +9 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.1-0.7.2.php +5 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.2-1.0.0.php +7 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.0-1.0.1.php +21 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.1-1.0.2.php +27 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.10-1.0.11.php +43 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.11-1.0.12.php +10 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.12-1.0.13.php +10 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.13-1.1.0.php +41 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.2-1.0.3.php +21 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.4-1.0.5.php +9 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.5-1.0.6.php +19 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.6-1.0.7.php +7 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.7-1.0.8.php +7 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.8-1.0.9.php +9 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.9-1.0.10.php +10 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.0-1.1.1.php +32 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.3-1.1.4.php +33 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.4-1.1.5.php +19 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.5.1-1.1.5.3.php +44 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.5.3-1.1.6.php +8 -0
- app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.7-1.1.8.php +49 -0
- package.xml +14 -11
- skin/adminhtml/default/default/images/shiphawk/shiphawkicon.png +0 -0
app/code/community/Shiphawk/.DS_Store
DELETED
|
Binary file
|
app/code/community/Shiphawk/Checkout/Model/Cart.php
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Shiphawk_Checkout_Model_Cart extends Mage_Checkout_Model_Cart
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Save cart
|
| 7 |
+
*
|
| 8 |
+
* @return Mage_Checkout_Model_Cart
|
| 9 |
+
*/
|
| 10 |
+
public function save($includeRates = false)
|
| 11 |
+
{
|
| 12 |
+
Mage::dispatchEvent('checkout_cart_save_before', array('cart'=>$this));
|
| 13 |
+
|
| 14 |
+
$calcRateOnCartChange = Mage::helper('shiphawk_shipping')->getCalcRateOnCartChange();
|
| 15 |
+
|
| 16 |
+
if($calcRateOnCartChange) {
|
| 17 |
+
parent::save();
|
| 18 |
+
}
|
| 19 |
+
else {
|
| 20 |
+
|
| 21 |
+
//retrieving previous subtotal form cookie
|
| 22 |
+
$previousCartSubTotal = Mage::getSingleton('core/session')->getData('previousCartSubTotal', true);
|
| 23 |
+
|
| 24 |
+
$this->getQuote()->getBillingAddress();
|
| 25 |
+
$this->getQuote()->getShippingAddress();
|
| 26 |
+
$this->getQuote()->collectTotals();
|
| 27 |
+
|
| 28 |
+
if ($includeRates) {
|
| 29 |
+
|
| 30 |
+
$this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
| 31 |
+
} else if ($previousCartSubTotal != $this->getQuote()->getSubtotal()) {
|
| 32 |
+
|
| 33 |
+
$this->getQuote()->getShippingAddress()->removeAllShippingRates();
|
| 34 |
+
$this->getQuote()->getShippingAddress()->setShippingMethod(false)->setShippingDescription('')->setCollectShippingRates(false);
|
| 35 |
+
//$this->getQuote()->getShippingAddress()->setShippingMethod('')->setShippingDescription('');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
$this->getQuote()->collectTotals();
|
| 39 |
+
$this->getQuote()->save();
|
| 40 |
+
$this->getCheckoutSession()->setQuoteId($this->getQuote()->getId());
|
| 41 |
+
/**
|
| 42 |
+
* Cart save usually called after changes with cart items.
|
| 43 |
+
*/
|
| 44 |
+
|
| 45 |
+
Mage::getSingleton('core/session')->setData('previousCartSubTotal', $this->getQuote()->getSubtotal());
|
| 46 |
+
|
| 47 |
+
Mage::dispatchEvent('checkout_cart_save_after', array('cart' => $this));
|
| 48 |
+
return $this;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}
|
app/code/community/Shiphawk/MyCarrier/Model/Carrier.php
CHANGED
|
@@ -36,16 +36,25 @@ class ShipHawk_MyCarrier_Model_Carrier
|
|
| 36 |
}
|
| 37 |
|
| 38 |
Mage::getSingleton('core/session')->setSHRateAarray($rateArray->rates);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
foreach($rateArray->rates as $rateRow)
|
| 40 |
{
|
| 41 |
-
$result->append($this->_buildRate($rateRow));
|
| 42 |
}
|
| 43 |
|
| 44 |
-
|
| 45 |
return $result;
|
| 46 |
}
|
| 47 |
|
| 48 |
-
protected function _buildRate($shRate)
|
| 49 |
{
|
| 50 |
Mage::log('processing rate');
|
| 51 |
Mage::log($shRate);
|
|
@@ -58,13 +67,18 @@ class ShipHawk_MyCarrier_Model_Carrier
|
|
| 58 |
* carriers/[carrier_code]/[config_key]
|
| 59 |
*/
|
| 60 |
$rate->setCarrierTitle($shRate->carrier);
|
| 61 |
-
|
| 62 |
-
$rate->setMethod($shRate->carrier. '-' . $shRate->service_name);
|
| 63 |
$rate->setMethodTitle($shRate->service_name);
|
| 64 |
|
| 65 |
-
$rate->setPrice($shRate->price);
|
| 66 |
$rate->setCost($shRate->price);
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return $rate;
|
| 69 |
}
|
| 70 |
|
|
@@ -97,21 +111,44 @@ class ShipHawk_MyCarrier_Model_Carrier
|
|
| 97 |
$skuColumn = Mage::getStoreConfig('shiphawk/datamapping/sku_column');
|
| 98 |
Mage::log('getting sku from column: ' . $skuColumn, Zend_Log::INFO, 'shiphawk_rates.log', true);
|
| 99 |
foreach ($request->getAllItems() as $item) {
|
| 100 |
-
|
| 101 |
-
$
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
'
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
|
| 117 |
|
|
@@ -125,6 +162,62 @@ class ShipHawk_MyCarrier_Model_Carrier
|
|
| 125 |
|
| 126 |
public function getAllowedMethods()
|
| 127 |
{
|
| 128 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
-
}
|
| 36 |
}
|
| 37 |
|
| 38 |
Mage::getSingleton('core/session')->setSHRateAarray($rateArray->rates);
|
| 39 |
+
|
| 40 |
+
$freeServices = array();
|
| 41 |
+
|
| 42 |
+
if ($request->getFreeShipping() === true) {
|
| 43 |
+
$freeServicesString = $this->getConfigData('free_method');
|
| 44 |
+
if ($freeServicesString) {
|
| 45 |
+
$freeServices = explode(",", $freeServicesString);
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
foreach($rateArray->rates as $rateRow)
|
| 50 |
{
|
| 51 |
+
$result->append($this->_buildRate($rateRow, $freeServices));
|
| 52 |
}
|
| 53 |
|
|
|
|
| 54 |
return $result;
|
| 55 |
}
|
| 56 |
|
| 57 |
+
protected function _buildRate($shRate, $freeServices)
|
| 58 |
{
|
| 59 |
Mage::log('processing rate');
|
| 60 |
Mage::log($shRate);
|
| 67 |
* carriers/[carrier_code]/[config_key]
|
| 68 |
*/
|
| 69 |
$rate->setCarrierTitle($shRate->carrier);
|
| 70 |
+
$rate->setMethod($shRate->service_name);
|
| 71 |
+
// $rate->setMethod($shRate->carrier. '-' . $shRate->service_name);
|
| 72 |
$rate->setMethodTitle($shRate->service_name);
|
| 73 |
|
|
|
|
| 74 |
$rate->setCost($shRate->price);
|
| 75 |
|
| 76 |
+
if (in_array($shRate->service_name, $freeServices)){
|
| 77 |
+
$rate->setPrice(0);
|
| 78 |
+
} else {
|
| 79 |
+
$rate->setPrice($shRate->price);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
return $rate;
|
| 83 |
}
|
| 84 |
|
| 111 |
$skuColumn = Mage::getStoreConfig('shiphawk/datamapping/sku_column');
|
| 112 |
Mage::log('getting sku from column: ' . $skuColumn, Zend_Log::INFO, 'shiphawk_rates.log', true);
|
| 113 |
foreach ($request->getAllItems() as $item) {
|
| 114 |
+
|
| 115 |
+
if($option = $item->getOptionByCode('simple_product')) {
|
| 116 |
+
|
| 117 |
+
$product_id = $option->getProductId();
|
| 118 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 119 |
+
//commenting out log statment to make the logs more readable. Uncomment when debugging rating.
|
| 120 |
+
//Mage::log('product data: ' . var_export($product->debug(), true), Zend_Log::INFO, 'shiphawk_rates.log', true);
|
| 121 |
+
$item_weight = $item->getWeight();
|
| 122 |
+
$items[] = array(
|
| 123 |
+
'product_sku' => $product->getData($skuColumn),
|
| 124 |
+
'quantity' => $item->getQty(),
|
| 125 |
+
'value' => $option->getPrice(),
|
| 126 |
+
'length' => $option->getLength(),
|
| 127 |
+
'width' => $option->getWidth(),
|
| 128 |
+
'height' => $option->getHeight(),
|
| 129 |
+
'weight' => $item_weight <= 70 ? $item_weight * 16 : $item_weight,
|
| 130 |
+
'item_type' => $item_weight <= 70 ? 'parcel' : 'handling_unit',
|
| 131 |
+
'handling_unit_type' => $item_weight <= 70 ? '' : 'box'
|
| 132 |
+
);
|
| 133 |
+
}
|
| 134 |
+
else if( $item->getTypeId() != 'configurable' && !$item->getParentItemId() ){
|
| 135 |
+
$product_id = $item->getProductId();
|
| 136 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 137 |
+
//commenting out log statment to make the logs more readable. Uncomment when debugging rating.
|
| 138 |
+
//Mage::log('product data: ' . var_export($product->debug(), true), Zend_Log::INFO, 'shiphawk_rates.log', true);
|
| 139 |
+
$item_weight = $item->getWeight();
|
| 140 |
+
$items[] = array(
|
| 141 |
+
'product_sku' => $product->getData($skuColumn),
|
| 142 |
+
'quantity' => $item->getQty(),
|
| 143 |
+
'value' => $item->getPrice(),
|
| 144 |
+
'length' => $item->getLength(),
|
| 145 |
+
'width' => $item->getWidth(),
|
| 146 |
+
'height' => $item->getHeight(),
|
| 147 |
+
'weight' => $item_weight <= 70 ? $item_weight * 16 : $item_weight,
|
| 148 |
+
'item_type' => $item_weight <= 70 ? 'parcel' : 'handling_unit',
|
| 149 |
+
'handling_unit_type' => $item_weight <= 70 ? '' : 'box'
|
| 150 |
+
);
|
| 151 |
+
}
|
| 152 |
|
| 153 |
|
| 154 |
|
| 162 |
|
| 163 |
public function getAllowedMethods()
|
| 164 |
{
|
| 165 |
+
return array(
|
| 166 |
+
'FedEx 2 Day' => 'FedEx 2 Day',
|
| 167 |
+
'FedEx 2 Day Am' => 'FedEx 2 Day Am',
|
| 168 |
+
'FedEx Express Saver' => 'FedEx Express Saver',
|
| 169 |
+
'FedEx First Overnight' => 'FedEx First Overnight',
|
| 170 |
+
'FedEx First Overnight Saturday Delivery' => 'FedEx First Overnight Saturday Delivery',
|
| 171 |
+
'FedEx Ground' => 'FedEx Ground',
|
| 172 |
+
'FedEx Ground Home Delivery' => 'FedEx Ground Home Delivery',
|
| 173 |
+
'FedEx International Economy' => 'FedEx International Economy',
|
| 174 |
+
'FedEx International First' => 'FedEx International First',
|
| 175 |
+
'FedEx International Ground' => 'FedEx International Ground',
|
| 176 |
+
'FedEx International Priority' => 'FedEx International Priority',
|
| 177 |
+
'FedEx Priority Overnight' => 'FedEx Priority Overnight',
|
| 178 |
+
'FedEx Priority Overnight Saturday Delivery' => 'FedEx Priority Overnight Saturday Delivery',
|
| 179 |
+
'FedEx Standard Overnight' => 'FedEx Standard Overnight',
|
| 180 |
+
'First Class Mail International' => 'First Class Mail International',
|
| 181 |
+
'First Class Package International Service' => 'First Class Package International Service',
|
| 182 |
+
'First-Class Mail' => 'First-Class Mail',
|
| 183 |
+
'Global Express Guaranteed' => 'Global Express Guaranteed',
|
| 184 |
+
'Library Mail' => 'Library Mail',
|
| 185 |
+
'Media Mail' => 'Media Mail',
|
| 186 |
+
'Parcel Select Ground' => 'Parcel Select Ground',
|
| 187 |
+
'Priority Mail' => 'Priority Mail',
|
| 188 |
+
'Priority Mail Express' => 'Priority Mail Express',
|
| 189 |
+
'Priority Mail Express Flat Rate Envelope' => 'Priority Mail Express Flat Rate Envelope',
|
| 190 |
+
'Priority Mail Express Flat Rate Legal Envelope' => 'Priority Mail Express Flat Rate Legal Envelope',
|
| 191 |
+
'Priority Mail Express International' => 'Priority Mail Express International',
|
| 192 |
+
'Priority Mail Express International Flat Rate Envelope' => 'Priority Mail Express International Flat Rate Envelope',
|
| 193 |
+
'Priority Mail Express International Flat Rate Legal Envelope' => 'Priority Mail Express International Flat Rate Legal Envelope',
|
| 194 |
+
'Priority Mail Express International Flat Rate Padded Envelope' => 'Priority Mail Express International Flat Rate Padded Envelope',
|
| 195 |
+
'Priority Mail Flat Rate Envelope' => 'Priority Mail Flat Rate Envelope',
|
| 196 |
+
'Priority Mail Flat Rate Legal Envelope' => 'Priority Mail Flat Rate Legal Envelope',
|
| 197 |
+
'Priority Mail International' => 'Priority Mail International',
|
| 198 |
+
'Priority Mail International Flat Rate Envelope' => 'Priority Mail International Flat Rate Envelope',
|
| 199 |
+
'Priority Mail International Flat Rate Legal Envelope' => 'Priority Mail International Flat Rate Legal Envelope',
|
| 200 |
+
'Priority Mail International Flat Rate Padded Envelope' => 'Priority Mail International Flat Rate Padded Envelope',
|
| 201 |
+
'Priority Mail International Large Flat Rate Box' => 'Priority Mail International Large Flat Rate Box',
|
| 202 |
+
'Priority Mail International Medium Flat Rate Box' => 'Priority Mail International Medium Flat Rate Box',
|
| 203 |
+
'Priority Mail International Small Flat Rate Box' => 'Priority Mail International Small Flat Rate Box',
|
| 204 |
+
'Priority Mail Large Flat Rate Box' => 'Priority Mail Large Flat Rate Box',
|
| 205 |
+
'Priority Mail Medium Flat Rate Box' => 'Priority Mail Medium Flat Rate Box',
|
| 206 |
+
'Priority Mail Small Flat Rate Box' => 'Priority Mail Small Flat Rate Box',
|
| 207 |
+
'UPS Ground' => 'UPS Ground',
|
| 208 |
+
'UPS Next Day Air' => 'UPS Next Day Air',
|
| 209 |
+
'UPS Next Day Air Early' => 'UPS Next Day Air Early',
|
| 210 |
+
'UPS Next Day Air Saver' => 'UPS Next Day Air Saver',
|
| 211 |
+
'UPS Second Day Air' => 'UPS Second Day Air',
|
| 212 |
+
'UPS Second Day Air A.M.' => 'UPS Second Day Air A.M.',
|
| 213 |
+
'UPS Standard' => 'UPS Standard',
|
| 214 |
+
'UPS SurePost' => 'UPS SurePost',
|
| 215 |
+
'UPS Three-Day Select' => 'UPS Three-Day Select',
|
| 216 |
+
'UPS Worldwide Expedited' => 'UPS Worldwide Expedited',
|
| 217 |
+
'UPS Worldwide Express' => 'UPS Worldwide Express',
|
| 218 |
+
'UPS Worldwide Express Freight' => 'UPS Worldwide Express Freight',
|
| 219 |
+
'UPS Worldwide Express Plus' => 'UPS Worldwide Express Plus',
|
| 220 |
+
'UPS Worldwide Saver' => 'UPS Worldwide Saver'
|
| 221 |
+
);
|
| 222 |
}
|
| 223 |
+
}
|
app/code/community/Shiphawk/MyCarrier/Model/Freemethod.php
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ShipHawk freemethod source implementation
|
| 4 |
+
*/
|
| 5 |
+
class ShipHawk_MyCarrier_Model_FreeMethod
|
| 6 |
+
extends Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Method
|
| 7 |
+
{
|
| 8 |
+
public function toOptionArray()
|
| 9 |
+
{
|
| 10 |
+
return array(
|
| 11 |
+
array('label' => 'FedEx 2 Day', 'value' => 'FedEx 2 Day'),
|
| 12 |
+
array('label' => 'FedEx 2 Day Am', 'value' => 'FedEx 2 Day Am'),
|
| 13 |
+
array('label' => 'FedEx Express Saver', 'value' => 'FedEx Express Saver'),
|
| 14 |
+
array('label' => 'FedEx First Overnight', 'value' => 'FedEx First Overnight'),
|
| 15 |
+
array('label' => 'FedEx First Overnight Saturday Delivery', 'value' => 'FedEx First Overnight Saturday Delivery'),
|
| 16 |
+
array('label' => 'FedEx Ground', 'value' => 'FedEx Ground'),
|
| 17 |
+
array('label' => 'FedEx Ground Home Delivery', 'value' => 'FedEx Ground Home Delivery'),
|
| 18 |
+
array('label' => 'FedEx International Economy', 'value' => 'FedEx International Economy'),
|
| 19 |
+
array('label' => 'FedEx International First', 'value' => 'FedEx International First'),
|
| 20 |
+
array('label' => 'FedEx International Ground', 'value' => 'FedEx International Ground'),
|
| 21 |
+
array('label' => 'FedEx International Priority', 'value' => 'FedEx International Priority'),
|
| 22 |
+
array('label' => 'FedEx Priority Overnight', 'value' => 'FedEx Priority Overnight'),
|
| 23 |
+
array('label' => 'FedEx Priority Overnight Saturday Delivery', 'value' => 'FedEx Priority Overnight Saturday Delivery'),
|
| 24 |
+
array('label' => 'FedEx Standard Overnight', 'value' => 'FedEx Standard Overnight'),
|
| 25 |
+
array('label' => 'First Class Mail International', 'value' => 'First Class Mail International'),
|
| 26 |
+
array('label' => 'First Class Package International Service', 'value' => 'First Class Package International Service'),
|
| 27 |
+
array('label' => 'First-Class Mail', 'value' => 'First-Class Mail'),
|
| 28 |
+
array('label' => 'Global Express Guaranteed', 'value' => 'Global Express Guaranteed'),
|
| 29 |
+
array('label' => 'Library Mail', 'value' => 'Library Mail'),
|
| 30 |
+
array('label' => 'Media Mail', 'value' => 'Media Mail'),
|
| 31 |
+
array('label' => 'Parcel Select Ground', 'value' => 'Parcel Select Ground'),
|
| 32 |
+
array('label' => 'Priority Mail', 'value' => 'Priority Mail'),
|
| 33 |
+
array('label' => 'Priority Mail Express', 'value' => 'Priority Mail Express'),
|
| 34 |
+
array('label' => 'Priority Mail Express Flat Rate Envelope', 'value' => 'Priority Mail Express Flat Rate Envelope'),
|
| 35 |
+
array('label' => 'Priority Mail Express Flat Rate Legal Envelope', 'value' => 'Priority Mail Express Flat Rate Legal Envelope'),
|
| 36 |
+
array('label' => 'Priority Mail Express International', 'value' => 'Priority Mail Express International'),
|
| 37 |
+
array('label' => 'Priority Mail Express International Flat Rate Envelope', 'value' => 'Priority Mail Express International Flat Rate Envelope'),
|
| 38 |
+
array('label' => 'Priority Mail Express International Flat Rate Legal Envelope', 'value' => 'Priority Mail Express International Flat Rate Legal Envelope'),
|
| 39 |
+
array('label' => 'Priority Mail Express International Flat Rate Padded Envelope', 'value' => 'Priority Mail Express International Flat Rate Padded Envelope'),
|
| 40 |
+
array('label' => 'Priority Mail Flat Rate Envelope', 'value' => 'Priority Mail Flat Rate Envelope'),
|
| 41 |
+
array('label' => 'Priority Mail Flat Rate Legal Envelope', 'value' => 'Priority Mail Flat Rate Legal Envelope'),
|
| 42 |
+
array('label' => 'Priority Mail International', 'value' => 'Priority Mail International'),
|
| 43 |
+
array('label' => 'Priority Mail International Flat Rate Envelope', 'value' => 'Priority Mail International Flat Rate Envelope'),
|
| 44 |
+
array('label' => 'Priority Mail International Flat Rate Legal Envelope', 'value' => 'Priority Mail International Flat Rate Legal Envelope'),
|
| 45 |
+
array('label' => 'Priority Mail International Flat Rate Padded Envelope', 'value' => 'Priority Mail International Flat Rate Padded Envelope'),
|
| 46 |
+
array('label' => 'Priority Mail International Large Flat Rate Box', 'value' => 'Priority Mail International Large Flat Rate Box'),
|
| 47 |
+
array('label' => 'Priority Mail International Medium Flat Rate Box', 'value' => 'Priority Mail International Medium Flat Rate Box'),
|
| 48 |
+
array('label' => 'Priority Mail International Small Flat Rate Box', 'value' => 'Priority Mail International Small Flat Rate Box'),
|
| 49 |
+
array('label' => 'Priority Mail Large Flat Rate Box', 'value' => 'Priority Mail Large Flat Rate Box'),
|
| 50 |
+
array('label' => 'Priority Mail Medium Flat Rate Box', 'value' => 'Priority Mail Medium Flat Rate Box'),
|
| 51 |
+
array('label' => 'Priority Mail Small Flat Rate Box', 'value' => 'Priority Mail Small Flat Rate Box'),
|
| 52 |
+
array('label' => 'UPS Ground', 'value' => 'UPS Ground'),
|
| 53 |
+
array('label' => 'UPS Next Day Air', 'value' => 'UPS Next Day Air'),
|
| 54 |
+
array('label' => 'UPS Next Day Air Early', 'value' => 'UPS Next Day Air Early'),
|
| 55 |
+
array('label' => 'UPS Next Day Air Saver', 'value' => 'UPS Next Day Air Saver'),
|
| 56 |
+
array('label' => 'UPS Second Day Air', 'value' => 'UPS Second Day Air'),
|
| 57 |
+
array('label' => 'UPS Second Day Air A.M.', 'value' => 'UPS Second Day Air A.M.'),
|
| 58 |
+
array('label' => 'UPS Standard', 'value' => 'UPS Standard'),
|
| 59 |
+
array('label' => 'UPS SurePost', 'value' => 'UPS SurePost'),
|
| 60 |
+
array('label' => 'UPS Three-Day Select', 'value' => 'UPS Three-Day Select'),
|
| 61 |
+
array('label' => 'UPS Worldwide Expedited', 'value' => 'UPS Worldwide Expedited'),
|
| 62 |
+
array('label' => 'UPS Worldwide Express', 'value' => 'UPS Worldwide Express'),
|
| 63 |
+
array('label' => 'UPS Worldwide Express Freight', 'value' => 'UPS Worldwide Express Freight'),
|
| 64 |
+
array('label' => 'UPS Worldwide Express Plus', 'value' => 'UPS Worldwide Express Plus'),
|
| 65 |
+
array('label' => 'UPS Worldwide Saver', 'value' => 'UPS Worldwide Saver')
|
| 66 |
+
);
|
| 67 |
+
}
|
| 68 |
+
}
|
app/code/community/Shiphawk/MyCarrier/etc/config.xml
CHANGED
|
@@ -46,4 +46,4 @@
|
|
| 46 |
</shiphawk_mycarrier>
|
| 47 |
</carriers>
|
| 48 |
</default>
|
| 49 |
-
</config>
|
| 46 |
</shiphawk_mycarrier>
|
| 47 |
</carriers>
|
| 48 |
</default>
|
| 49 |
+
</config>
|
app/code/community/Shiphawk/MyCarrier/etc/system.xml
CHANGED
|
@@ -56,6 +56,7 @@
|
|
| 56 |
<show_in_website>1</show_in_website>
|
| 57 |
<show_in_store>0</show_in_store>
|
| 58 |
</sort_order>
|
|
|
|
| 59 |
<!--
|
| 60 |
This value is used to specify whether
|
| 61 |
the carrier is available only for
|
|
@@ -90,9 +91,21 @@
|
|
| 90 |
<show_in_store>0</show_in_store>
|
| 91 |
<can_be_empty>1</can_be_empty>
|
| 92 |
</specificcountry>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
</fields>
|
| 94 |
</shiphawk_mycarrier>
|
| 95 |
</groups>
|
| 96 |
</carriers>
|
| 97 |
</sections>
|
| 98 |
-
</config>
|
| 56 |
<show_in_website>1</show_in_website>
|
| 57 |
<show_in_store>0</show_in_store>
|
| 58 |
</sort_order>
|
| 59 |
+
|
| 60 |
<!--
|
| 61 |
This value is used to specify whether
|
| 62 |
the carrier is available only for
|
| 91 |
<show_in_store>0</show_in_store>
|
| 92 |
<can_be_empty>1</can_be_empty>
|
| 93 |
</specificcountry>
|
| 94 |
+
|
| 95 |
+
<free_method translate="label">
|
| 96 |
+
<label>Free Method</label>
|
| 97 |
+
<frontend_type>multiselect</frontend_type>
|
| 98 |
+
<frontend_class>free-method</frontend_class>
|
| 99 |
+
<source_model>shiphawk_mycarrier/freemethod</source_model>
|
| 100 |
+
<sort_order>1200</sort_order>
|
| 101 |
+
<show_in_default>1</show_in_default>
|
| 102 |
+
<show_in_website>1</show_in_website>
|
| 103 |
+
<show_in_store>0</show_in_store>
|
| 104 |
+
<can_be_empty>1</can_be_empty>
|
| 105 |
+
</free_method>
|
| 106 |
</fields>
|
| 107 |
</shiphawk_mycarrier>
|
| 108 |
</groups>
|
| 109 |
</carriers>
|
| 110 |
</sections>
|
| 111 |
+
</config>
|
app/code/community/Shiphawk/Order/Model/.DS_Store
DELETED
|
Binary file
|
app/code/community/Shiphawk/Order/Model/Command/SendOrder.php
CHANGED
|
@@ -25,24 +25,36 @@ class Shiphawk_Order_Model_Command_SendOrder
|
|
| 25 |
}
|
| 26 |
|
| 27 |
$skuColumn = Mage::getStoreConfig('shiphawk/datamapping/sku_column');
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
$product_id = $item->getProductId();
|
| 31 |
$product = Mage::getModel('catalog/product')->load($product_id);
|
|
|
|
| 32 |
$itemsRequest[] = array(
|
| 33 |
-
'name'
|
| 34 |
-
'sku'
|
| 35 |
-
'quantity'
|
| 36 |
-
'value'
|
| 37 |
-
'length'
|
| 38 |
-
'width'
|
| 39 |
-
'height'
|
| 40 |
-
'weight'
|
| 41 |
-
'can_ship_parcel'
|
| 42 |
-
'item_type'
|
| 43 |
-
'handling_unit_type' => $
|
|
|
|
| 44 |
);
|
| 45 |
-
|
| 46 |
}
|
| 47 |
|
| 48 |
$orderRequest = json_encode(
|
| 25 |
}
|
| 26 |
|
| 27 |
$skuColumn = Mage::getStoreConfig('shiphawk/datamapping/sku_column');
|
| 28 |
+
$SimpleItems = array();
|
| 29 |
+
foreach($order->getAllVisibleItems() as $item){
|
| 30 |
+
if($item->getHasChildren()) {
|
| 31 |
+
foreach($item->getChildrenItems() as $child) {
|
| 32 |
+
$SimpleItems[] = $child;
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
else if(!$item->getHasParent()) {
|
| 36 |
+
$SimpleItems[] = $item;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
foreach ($SimpleItems as $item) {
|
| 41 |
$product_id = $item->getProductId();
|
| 42 |
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 43 |
+
$item_weight = $item->getWeight();
|
| 44 |
$itemsRequest[] = array(
|
| 45 |
+
'name' => $item->getName(),
|
| 46 |
+
'sku' => $product->getData($skuColumn),
|
| 47 |
+
'quantity' => $item->getQtyOrdered(),
|
| 48 |
+
'value' => $item->getPrice(),
|
| 49 |
+
'length' => $item->getLength(),
|
| 50 |
+
'width' => $item->getWidth(),
|
| 51 |
+
'height' => $item->getHeight(),
|
| 52 |
+
'weight' => $item_weight <= 70 ? $item_weight * 16 : $item_weight,
|
| 53 |
+
'can_ship_parcel' => true,
|
| 54 |
+
'item_type' => $item_weight <= 70 ? 'parcel' : 'handling_unit',
|
| 55 |
+
'handling_unit_type' => $item_weight <= 70 ? '' : 'box',
|
| 56 |
+
'source_system_id' => $item->getItemId()
|
| 57 |
);
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
$orderRequest = json_encode(
|
app/code/community/Shiphawk/Order/Model/Cron/ProcessOrderForLast14Days.php
CHANGED
|
@@ -14,7 +14,7 @@ class Shiphawk_Order_Model_Cron_ProcessOrderForLast14Days
|
|
| 14 |
|
| 15 |
$orders = Mage::getSingleton('sales/order')->getCollection()->addAttributeToFilter(
|
| 16 |
'created_at',
|
| 17 |
-
['gt' => strtotime('now - 14 days')]
|
| 18 |
);
|
| 19 |
|
| 20 |
foreach ($orders as $order) {
|
| 14 |
|
| 15 |
$orders = Mage::getSingleton('sales/order')->getCollection()->addAttributeToFilter(
|
| 16 |
'created_at',
|
| 17 |
+
['gt' => date("Y-m-d", strtotime('now - 14 days'))]
|
| 18 |
);
|
| 19 |
|
| 20 |
foreach ($orders as $order) {
|
app/code/community/Shiphawk/Order/etc/config.xml
CHANGED
|
@@ -68,7 +68,7 @@
|
|
| 68 |
<gateway_url>https://shiphawk.com/api/v4/</gateway_url>
|
| 69 |
</order>
|
| 70 |
<datamapping>
|
| 71 |
-
<sku_column>
|
| 72 |
</datamapping>
|
| 73 |
</shiphawk>
|
| 74 |
</default>
|
| 68 |
<gateway_url>https://shiphawk.com/api/v4/</gateway_url>
|
| 69 |
</order>
|
| 70 |
<datamapping>
|
| 71 |
+
<sku_column>sku</sku_column>
|
| 72 |
</datamapping>
|
| 73 |
</shiphawk>
|
| 74 |
</default>
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Origins extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_addButtonLabel = Mage::helper('shiphawk_shipping')->__('Add New Origins');
|
| 7 |
+
|
| 8 |
+
$this->_blockGroup = 'shiphawk_shipping';
|
| 9 |
+
$this->_controller = 'adminhtml_origins';
|
| 10 |
+
$this->_headerText = Mage::helper('shiphawk_shipping')->__('Origins');
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Edit.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Origins_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_blockGroup = 'shiphawk_shipping';
|
| 7 |
+
$this->_mode = 'edit';
|
| 8 |
+
$this->_controller = 'adminhtml_origins';
|
| 9 |
+
|
| 10 |
+
$faq_id = (int)$this->getRequest()->getParam($this->_objectId);
|
| 11 |
+
|
| 12 |
+
$faq = Mage::getModel('shiphawk_shipping/origins')->load($faq_id);
|
| 13 |
+
Mage::register('current_origins', $faq);
|
| 14 |
+
|
| 15 |
+
$this->_removeButton('reset');
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public function getHeaderText()
|
| 19 |
+
{
|
| 20 |
+
$faq = Mage::registry('current_origins');
|
| 21 |
+
if ($faq->getId()) {
|
| 22 |
+
return Mage::helper('shiphawk_shipping')->__("Edit origins '%s'", $this->escapeHtml($faq->getShiphawkOriginTitle()));
|
| 23 |
+
} else {
|
| 24 |
+
return Mage::helper('shiphawk_shipping')->__("Add new origins");
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Edit/Form.php
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Origins_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 3 |
+
{
|
| 4 |
+
protected function _prepareForm()
|
| 5 |
+
{
|
| 6 |
+
$faq = Mage::registry('current_origins');
|
| 7 |
+
$form = new Varien_Data_Form();
|
| 8 |
+
$fieldset = $form->addFieldset('edit_origins', array(
|
| 9 |
+
'legend' => Mage::helper('shiphawk_shipping')->__('Origins Details')
|
| 10 |
+
));
|
| 11 |
+
|
| 12 |
+
if ($faq->getId()) {
|
| 13 |
+
$fieldset->addField('id', 'hidden', array(
|
| 14 |
+
'name' => 'id',
|
| 15 |
+
'required' => true
|
| 16 |
+
));
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
$fieldset->addField('shiphawk_origin_title', 'text', array(
|
| 21 |
+
'name' => 'shiphawk_origin_title',
|
| 22 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Title'),
|
| 23 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Title'),
|
| 24 |
+
'required' => true,
|
| 25 |
+
'width' => '400px'
|
| 26 |
+
));
|
| 27 |
+
|
| 28 |
+
$fieldset->addField('shiphawk_origin_firstname', 'text', array(
|
| 29 |
+
'name' => 'shiphawk_origin_firstname',
|
| 30 |
+
'title' => Mage::helper('shiphawk_shipping')->__('First Name'),
|
| 31 |
+
'label' => Mage::helper('shiphawk_shipping')->__('First Name'),
|
| 32 |
+
'required' => true,
|
| 33 |
+
'width' => '400px'
|
| 34 |
+
));
|
| 35 |
+
|
| 36 |
+
$fieldset->addField('shiphawk_origin_lastname', 'text', array(
|
| 37 |
+
'name' => 'shiphawk_origin_lastname',
|
| 38 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Last Name'),
|
| 39 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Last Name'),
|
| 40 |
+
'required' => true,
|
| 41 |
+
'width' => '400px'
|
| 42 |
+
));
|
| 43 |
+
|
| 44 |
+
$fieldset->addField('shiphawk_origin_addressline1', 'text', array(
|
| 45 |
+
'name' => 'shiphawk_origin_addressline1',
|
| 46 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Address'),
|
| 47 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Address'),
|
| 48 |
+
'required' => true,
|
| 49 |
+
'width' => '400px'
|
| 50 |
+
));
|
| 51 |
+
|
| 52 |
+
$fieldset->addField('shiphawk_origin_addressline2', 'text', array(
|
| 53 |
+
'name' => 'shiphawk_origin_addressline2',
|
| 54 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Address'),
|
| 55 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Address Line 2'),
|
| 56 |
+
'required' => false,
|
| 57 |
+
'width' => '400px'
|
| 58 |
+
));
|
| 59 |
+
|
| 60 |
+
$fieldset->addField('shiphawk_origin_city', 'text', array(
|
| 61 |
+
'name' => 'shiphawk_origin_city',
|
| 62 |
+
'title' => Mage::helper('shiphawk_shipping')->__('City'),
|
| 63 |
+
'label' => Mage::helper('shiphawk_shipping')->__('City'),
|
| 64 |
+
'required' => true,
|
| 65 |
+
'width' => '400px'
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
$regions = $this->getRegions();
|
| 69 |
+
|
| 70 |
+
$fieldset->addField('shiphawk_origin_state', 'select', array(
|
| 71 |
+
'name' => 'shiphawk_origin_state',
|
| 72 |
+
'title' => Mage::helper('shiphawk_shipping')->__('State'),
|
| 73 |
+
'label' => Mage::helper('shiphawk_shipping')->__('State'),
|
| 74 |
+
'required' => true,
|
| 75 |
+
'values' => $regions,
|
| 76 |
+
'width' => '100%'
|
| 77 |
+
));
|
| 78 |
+
|
| 79 |
+
$fieldset->addField('shiphawk_origin_zipcode', 'text', array(
|
| 80 |
+
'name' => 'shiphawk_origin_zipcode',
|
| 81 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Zip Code'),
|
| 82 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Zip Code'),
|
| 83 |
+
'required' => true,
|
| 84 |
+
'width' => '400px'
|
| 85 |
+
));
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
$fieldset->addField('shiphawk_origin_phonenum', 'text', array(
|
| 89 |
+
'name' => 'shiphawk_origin_phonenum',
|
| 90 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Phone number'),
|
| 91 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Phone number'),
|
| 92 |
+
'required' => true,
|
| 93 |
+
'width' => '400px'
|
| 94 |
+
));
|
| 95 |
+
|
| 96 |
+
$fieldset->addField('shiphawk_origin_location', 'select', array(
|
| 97 |
+
'name' => 'shiphawk_origin_location',
|
| 98 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Location'),
|
| 99 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Location'),
|
| 100 |
+
'required' => true,
|
| 101 |
+
'values' => array(
|
| 102 |
+
array( 'value'=>'commercial', 'label'=>'commercial'),
|
| 103 |
+
array( 'value'=>'residential', 'label'=>'residential'),
|
| 104 |
+
),
|
| 105 |
+
'width' => '400px'
|
| 106 |
+
));
|
| 107 |
+
|
| 108 |
+
$fieldset->addField('shiphawk_origin_email', 'text', array(
|
| 109 |
+
'name' => 'shiphawk_origin_email',
|
| 110 |
+
'title' => Mage::helper('shiphawk_shipping')->__('Email'),
|
| 111 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Email'),
|
| 112 |
+
'required' => false,
|
| 113 |
+
'width' => '400px'
|
| 114 |
+
));
|
| 115 |
+
|
| 116 |
+
$form->setMethod('post');
|
| 117 |
+
$form->setUseContainer(true);
|
| 118 |
+
$form->setId('edit_form');
|
| 119 |
+
$form->setAction($this->getUrl('*/*/save'));
|
| 120 |
+
$form->setValues($faq->getData());
|
| 121 |
+
|
| 122 |
+
$this->setForm($form);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
public function getRegions($county_code = 'US') {
|
| 126 |
+
$regions = array();
|
| 127 |
+
$regionCollection = Mage::getModel('directory/region_api')->items($county_code);
|
| 128 |
+
foreach($regionCollection as $region) {
|
| 129 |
+
$regions[]= array(
|
| 130 |
+
'value' => $region['code'],
|
| 131 |
+
'label' => $region['name']
|
| 132 |
+
);
|
| 133 |
+
}
|
| 134 |
+
return $regions;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Origins/Grid.php
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Origins_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
$this->setId('originsGrid');
|
| 8 |
+
$this->_controller = 'adminhtml_origins';
|
| 9 |
+
$this->setUseAjax(true);
|
| 10 |
+
|
| 11 |
+
$this->setDefaultSort('id');
|
| 12 |
+
$this->setDefaultDir('desc');
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
protected function _prepareCollection()
|
| 16 |
+
{
|
| 17 |
+
$collection = Mage::getModel('shiphawk_shipping/origins')->getCollection();
|
| 18 |
+
$this->setCollection($collection);
|
| 19 |
+
|
| 20 |
+
return parent::_prepareCollection();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
protected function _prepareColumns()
|
| 24 |
+
{
|
| 25 |
+
$this->addColumn('id', array(
|
| 26 |
+
'header' => Mage::helper('shiphawk_shipping')->__('ID'),
|
| 27 |
+
'align' => 'right',
|
| 28 |
+
'width' => '20px',
|
| 29 |
+
'filter_index' => 'id',
|
| 30 |
+
'index' => 'id'
|
| 31 |
+
));
|
| 32 |
+
|
| 33 |
+
$this->addColumn('shiphawk_origin_title', array(
|
| 34 |
+
'header' => Mage::helper('shiphawk_shipping')->__('Title'),
|
| 35 |
+
'align' => 'right',
|
| 36 |
+
|
| 37 |
+
'filter_index' => 'shiphawk_origin_title',
|
| 38 |
+
'index' => 'shiphawk_origin_title'
|
| 39 |
+
));
|
| 40 |
+
|
| 41 |
+
$this->addColumn('shiphawk_origin_firstname', array(
|
| 42 |
+
'header' => Mage::helper('shiphawk_shipping')->__('First name'),
|
| 43 |
+
'align' => 'left',
|
| 44 |
+
'filter_index' => 'shiphawk_origin_firstname',
|
| 45 |
+
'index' => 'shiphawk_origin_firstname',
|
| 46 |
+
|
| 47 |
+
));
|
| 48 |
+
|
| 49 |
+
$this->addColumn('shiphawk_origin_lastname', array(
|
| 50 |
+
'header' => Mage::helper('shiphawk_shipping')->__('Last name'),
|
| 51 |
+
'align' => 'left',
|
| 52 |
+
'filter_index' => 'shiphawk_origin_lastname',
|
| 53 |
+
'index' => 'shiphawk_origin_lastname',
|
| 54 |
+
|
| 55 |
+
));
|
| 56 |
+
|
| 57 |
+
$this->addColumn('shiphawk_origin_zipcode', array(
|
| 58 |
+
'header' => Mage::helper('shiphawk_shipping')->__('Origin Zip Code'),
|
| 59 |
+
'align' => 'left',
|
| 60 |
+
'filter_index' => 'shiphawk_origin_zipcode',
|
| 61 |
+
'index' => 'shiphawk_origin_zipcode',
|
| 62 |
+
|
| 63 |
+
));
|
| 64 |
+
|
| 65 |
+
$this->addExportType('*/*/export', Mage::helper('shiphawk_shipping')->__('CSV'));
|
| 66 |
+
|
| 67 |
+
return parent::_prepareColumns();
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
protected function _prepareMassaction()
|
| 71 |
+
{
|
| 72 |
+
$this->setMassactionIdField('id');
|
| 73 |
+
$this->getMassactionBlock()->setFormFieldName('origins');
|
| 74 |
+
|
| 75 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 76 |
+
'label' => Mage::helper('shiphawk_shipping')->__('Delete'),
|
| 77 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 78 |
+
'confirm' => Mage::helper('shiphawk_shipping')->__('Are you sure?')
|
| 79 |
+
));
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
return $this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
public function getRowUrl($faqs)
|
| 87 |
+
{
|
| 88 |
+
return $this->getUrl('*/*/edit', array(
|
| 89 |
+
'id' => $faqs->getId(),
|
| 90 |
+
));
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
public function getGridUrl()
|
| 94 |
+
{
|
| 95 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
| 96 |
+
}
|
| 97 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/Shipment/View.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Sales_Order_Shipment_View extends Mage_Adminhtml_Block_Sales_Order_Shipment_View {
|
| 3 |
+
public function __construct() {
|
| 4 |
+
|
| 5 |
+
parent::__construct();
|
| 6 |
+
|
| 7 |
+
/* if ($this->getShipment()->getId()) {
|
| 8 |
+
$this->_addButton('subscribe', array(
|
| 9 |
+
'label' => Mage::helper('sales')->__('Subscribe to Tracking Information'),
|
| 10 |
+
'class' => 'save',
|
| 11 |
+
'onclick' => 'setLocation(\''.$this->getShipTrackUrl($this->getShipment()->getId()).'\')'
|
| 12 |
+
)
|
| 13 |
+
);
|
| 14 |
+
}*/
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function getShipTrackUrl($shipment_id) {
|
| 18 |
+
return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_shipment/subscribe", array('shipment_id' => $shipment_id));
|
| 19 |
+
}
|
| 20 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/View.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
|
| 3 |
+
public function __construct() {
|
| 4 |
+
|
| 5 |
+
parent::__construct();
|
| 6 |
+
|
| 7 |
+
$order_id = $this->getOrderId();
|
| 8 |
+
$order = $this->getOrder();
|
| 9 |
+
|
| 10 |
+
$manual_shipping = Mage::getStoreConfig('carriers/shiphawk_shipping/book_shipment');
|
| 11 |
+
$shipping_code = $order->getShippingMethod();
|
| 12 |
+
|
| 13 |
+
$confirm_messsage = $this->__('Are you sure to process?');
|
| 14 |
+
$check_shiphawk = Mage::helper('shiphawk_shipping')->isShipHawkShipping($shipping_code);
|
| 15 |
+
if($check_shiphawk !== false) {
|
| 16 |
+
if ($order->canShip()) {
|
| 17 |
+
if($manual_shipping) {
|
| 18 |
+
$this->_addButton('shiphawk_shipping', array(
|
| 19 |
+
'label' => Mage::helper('shiphawk_shipping')->__('ShipHawk Shipment'),
|
| 20 |
+
//'onclick' => "confirmSetLocation('{$confirm_messsage}', '{$this->getShipHawkUrl($order_id)}')",
|
| 21 |
+
'onclick' => "reBook('{$this->getShipHawkUrl($order_id)}', '{$order_id}', '{$this->getNewShipHawkUrl($order_id)}')",
|
| 22 |
+
'class' => 'go'
|
| 23 |
+
), 0, 100, 'header', 'header');
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}else{
|
| 27 |
+
if ($order->canShip()) {
|
| 28 |
+
$this->_addButton('shiphawk_shipping_new', array(
|
| 29 |
+
'label' => Mage::helper('shiphawk_shipping')->__('New ShipHawk Shipment'),
|
| 30 |
+
'class' => 'newshipment',
|
| 31 |
+
'onclick' => "showPopup('{$this->getNewShipHawkUrl($order_id)}')"
|
| 32 |
+
), 0, 150, 'header', 'header');
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
public function getShipHawkUrl($order_id) {
|
| 39 |
+
return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_shipment/saveshipment", array('order_id' => $order_id));
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
public function getNewShipHawkUrl($order_id) {
|
| 43 |
+
return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_shipment/newshipment", array('order_id' => $order_id));
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Shipment.php
ADDED
|
@@ -0,0 +1,623 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_Shipment extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Get ShipHawk Shipping Rate for order with not ShipHawk shipping method
|
| 6 |
+
* @param $order
|
| 7 |
+
* @return array|null
|
| 8 |
+
*/
|
| 9 |
+
public function getNewShipHawkRate($order) {
|
| 10 |
+
|
| 11 |
+
$carrier = Mage::getModel('shiphawk_shipping/carrier');
|
| 12 |
+
$api = Mage::getModel('shiphawk_shipping/api');
|
| 13 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 14 |
+
|
| 15 |
+
$shLocationType = $order->getShiphawkLocationType();
|
| 16 |
+
|
| 17 |
+
$result = array();
|
| 18 |
+
|
| 19 |
+
$items = $carrier->getShiphawkItems($order);
|
| 20 |
+
|
| 21 |
+
/* sort items by origin id */
|
| 22 |
+
$grouped_items_by_zip = $carrier->getGroupedItemsByZip($items);
|
| 23 |
+
|
| 24 |
+
// sort items by carrier type
|
| 25 |
+
$grouped_items_by_carrier_type = $carrier->getGroupedItemsByCarrierType($items);
|
| 26 |
+
|
| 27 |
+
$error_message = 'Sorry, not all products have necessary ShipHawk fields filled in. Please add necessary data for next products (or check required attributes):';
|
| 28 |
+
|
| 29 |
+
$shippingAddress = $order->getShippingAddress();
|
| 30 |
+
$to_zip = $shippingAddress->getPostcode();
|
| 31 |
+
|
| 32 |
+
$ship_responces = array();
|
| 33 |
+
$toOrder= array();
|
| 34 |
+
$api_error = false;
|
| 35 |
+
$is_multi_zip = false;
|
| 36 |
+
$is_multi_carrier = false;
|
| 37 |
+
|
| 38 |
+
if(count($grouped_items_by_zip) > 1) {
|
| 39 |
+
$is_multi_zip = true;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if(count($grouped_items_by_carrier_type) > 1) {
|
| 43 |
+
$is_multi_carrier = true;
|
| 44 |
+
$is_multi_zip = true;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
$is_admin = $helper->checkIsAdmin();
|
| 48 |
+
$rate_filter = Mage::helper('shiphawk_shipping')->getRateFilter($is_admin, $order);
|
| 49 |
+
$carrier_type = Mage::getStoreConfig('carriers/shiphawk_shipping/carrier_type');
|
| 50 |
+
|
| 51 |
+
$custom_packing_price_setting = Mage::getStoreConfig('carriers/shiphawk_shipping/shiphawk_custom_packing_price');
|
| 52 |
+
|
| 53 |
+
$self_pack = $helper->getSelfPacked();
|
| 54 |
+
|
| 55 |
+
$charge_customer_for_packing = Mage::getStoreConfig('carriers/shiphawk_shipping/charge_customer_for_packing');
|
| 56 |
+
|
| 57 |
+
$result['error'] = '';
|
| 58 |
+
//default origin zip code
|
| 59 |
+
$from_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
|
| 60 |
+
|
| 61 |
+
/* items has various carrier type */
|
| 62 |
+
if($is_multi_carrier) {
|
| 63 |
+
foreach($grouped_items_by_carrier_type as $carrier_type=>$items_) {
|
| 64 |
+
|
| 65 |
+
if($carrier_type) {
|
| 66 |
+
$carrier_type = explode(',', $carrier_type);
|
| 67 |
+
}else{
|
| 68 |
+
$carrier_type = '';
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
$grouped_items_by_origin = $carrier->getGroupedItemsByZip($items_);
|
| 72 |
+
|
| 73 |
+
foreach($grouped_items_by_origin as $origin_id=>$items__) {
|
| 74 |
+
|
| 75 |
+
if ($origin_id != 'origin_per_product') { // product has origin id or primary origin
|
| 76 |
+
|
| 77 |
+
$rate_filter = 'best'; // multi carrier
|
| 78 |
+
|
| 79 |
+
if($origin_id) {
|
| 80 |
+
$shipHawkOrigin = Mage::getModel('shiphawk_shipping/origins')->load($origin_id);
|
| 81 |
+
$from_zip = $shipHawkOrigin->getShiphawkOriginZipcode();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items__, $rate_filter);
|
| 85 |
+
|
| 86 |
+
if(empty($checkattributes)) {
|
| 87 |
+
|
| 88 |
+
$grouped_items_by_discount_or_markup = $carrier->getGroupedItemsByDiscountOrMarkup($items__);
|
| 89 |
+
|
| 90 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 91 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 92 |
+
$from_zip = $items__[0]['zip'];
|
| 93 |
+
$location_type = $items__[0]['location_type'];
|
| 94 |
+
// 1. multi carrier, multi origin, not origin per product
|
| 95 |
+
$responceObject = $api->getShiphawkRate($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 96 |
+
if(empty($responceObject)) {
|
| 97 |
+
$api_error = true;
|
| 98 |
+
$helper->shlog('ShipHawk response is empty');
|
| 99 |
+
$helper->sendErrorMessageToShipHawk('ShipHawk response is empty');
|
| 100 |
+
break;
|
| 101 |
+
}
|
| 102 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 103 |
+
|
| 104 |
+
$custom_products_packing_price = 0;
|
| 105 |
+
|
| 106 |
+
if($custom_packing_price_setting) {
|
| 107 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
$ship_responces[] = $responceObject;
|
| 111 |
+
|
| 112 |
+
if(property_exists($responceObject, 'error')) {
|
| 113 |
+
$api_error = true;
|
| 114 |
+
$shiphawk_error = (string) $responceObject->error;
|
| 115 |
+
//Mage::log('ShipHawk response: '. $shiphawk_error, null, 'ShipHawk.log');
|
| 116 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 117 |
+
$error_message = 'ShipHawk error: '. $shiphawk_error;
|
| 118 |
+
echo $error_message ;
|
| 119 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 120 |
+
return null;
|
| 121 |
+
}else{
|
| 122 |
+
// if $rate_filter = 'best' then it is only one rate
|
| 123 |
+
if(($is_multi_zip)||($rate_filter == 'best')) {
|
| 124 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 125 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 126 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 127 |
+
|
| 128 |
+
$toOrder[$responceObject->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 129 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject);
|
| 130 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getShipHawkPrice($responceObject, $self_pack, $charge_customer_for_packing);
|
| 131 |
+
$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 132 |
+
$toOrder[$responceObject->id]['name'] = $responceObject->shipping->service;//
|
| 133 |
+
$toOrder[$responceObject->id]['items'] = $discount_items;
|
| 134 |
+
$toOrder[$responceObject->id]['from_zip'] = $from_zip;
|
| 135 |
+
$toOrder[$responceObject->id]['to_zip'] = $to_zip;
|
| 136 |
+
$toOrder[$responceObject->id]['carrier'] = $carrier->getCarrierName($responceObject);
|
| 137 |
+
$toOrder[$responceObject->id]['packing_info'] = $carrier->getPackeges($responceObject);
|
| 138 |
+
$toOrder[$responceObject->id]['carrier_type'] = $carrier_type;
|
| 139 |
+
$toOrder[$responceObject->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 140 |
+
$toOrder[$responceObject->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 141 |
+
$toOrder[$responceObject->id]['self_pack'] = $self_pack;
|
| 142 |
+
$toOrder[$responceObject->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 143 |
+
$toOrder[$responceObject->id]['carrier_accessorial'] = $responceObject->shipping->carrier_accessorial;
|
| 144 |
+
//$responce->shipping->carrier_accessorial;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
if($is_multi_zip) {
|
| 149 |
+
Mage::getSingleton('core/session')->setMultiZipCode(true);
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
}else{
|
| 154 |
+
$api_error = true;
|
| 155 |
+
/*foreach($checkattributes as $rate_error) {
|
| 156 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 157 |
+
}*/
|
| 158 |
+
echo $error_message . '<br />';
|
| 159 |
+
if(!empty($checkattributes['items']['name']))
|
| 160 |
+
if(count($checkattributes['items']['name'])>0)
|
| 161 |
+
foreach($checkattributes['items']['name'] as $names) {
|
| 162 |
+
echo $names . '<br />';
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
if (!empty($checkattributes['from_zip'])) {
|
| 166 |
+
echo 'From Zip' . '<br />';
|
| 167 |
+
}
|
| 168 |
+
if (!empty($checkattributes['to_zip'])) {
|
| 169 |
+
echo 'To Zip' . '<br />';
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
if (!empty($checkattributes['rate_filter'])) {
|
| 173 |
+
echo 'Rate Filter' . '<br />';
|
| 174 |
+
}
|
| 175 |
+
return null;
|
| 176 |
+
}
|
| 177 |
+
}else{ // product items has all required shipping origin fields
|
| 178 |
+
|
| 179 |
+
$grouped_items_per_product_by_zip = $carrier->getGroupedItemsByZipPerProduct($items__);
|
| 180 |
+
|
| 181 |
+
if(count($grouped_items_per_product_by_zip) > 1 ) {
|
| 182 |
+
$is_multi_zip = true;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
if($is_multi_zip) {
|
| 186 |
+
$rate_filter = 'best';
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
foreach ($grouped_items_per_product_by_zip as $from_zip=>$items_per_product) {
|
| 190 |
+
|
| 191 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_per_product, $rate_filter);
|
| 192 |
+
|
| 193 |
+
if(empty($checkattributes)) {
|
| 194 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 195 |
+
$from_zip = $items_[0]['zip'];
|
| 196 |
+
$location_type = $items_[0]['location_type'];
|
| 197 |
+
|
| 198 |
+
$grouped_items_by_discount_or_markup = $carrier->getGroupedItemsByDiscountOrMarkup($items_per_product);
|
| 199 |
+
|
| 200 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 201 |
+
|
| 202 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 203 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 204 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 205 |
+
|
| 206 |
+
if($carrier_type) {
|
| 207 |
+
$carrier_type = explode(',', $carrier_type);
|
| 208 |
+
}else{
|
| 209 |
+
$carrier_type = '';
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// 2. multi carrier, multi origin, origin per product
|
| 213 |
+
$responceObject = $api->getShiphawkRate($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 214 |
+
if(empty($responceObject)) {
|
| 215 |
+
$api_error = true;
|
| 216 |
+
$helper->shlog('ShipHawk response is empty');
|
| 217 |
+
$helper->sendErrorMessageToShipHawk('ShipHawk response is empty');
|
| 218 |
+
break;
|
| 219 |
+
}
|
| 220 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 221 |
+
|
| 222 |
+
$custom_products_packing_price = 0;
|
| 223 |
+
|
| 224 |
+
if($custom_packing_price_setting) {
|
| 225 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
$ship_responces[] = $responceObject;
|
| 229 |
+
|
| 230 |
+
if(property_exists($responceObject, 'error')) {
|
| 231 |
+
$api_error = true;
|
| 232 |
+
$shiphawk_error = (string) $responceObject->error;
|
| 233 |
+
//Mage::log('ShipHawk response: '. $shiphawk_error, null, 'ShipHawk.log');
|
| 234 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 235 |
+
$error_message = 'ShipHawk error: '. $shiphawk_error;
|
| 236 |
+
echo $error_message ;
|
| 237 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 238 |
+
return null;
|
| 239 |
+
}else{
|
| 240 |
+
// if $rate_filter = 'best' then it is only one rate
|
| 241 |
+
if(($is_multi_zip)||($rate_filter == 'best')) {
|
| 242 |
+
|
| 243 |
+
$toOrder[$responceObject->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 244 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject);
|
| 245 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getShipHawkPrice($responceObject, $self_pack, $charge_customer_for_packing);
|
| 246 |
+
$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 247 |
+
$toOrder[$responceObject->id]['name'] = $responceObject->shipping->service;//
|
| 248 |
+
$toOrder[$responceObject->id]['items'] = $discount_items;
|
| 249 |
+
$toOrder[$responceObject->id]['from_zip'] = $from_zip;
|
| 250 |
+
$toOrder[$responceObject->id]['to_zip'] = $to_zip;
|
| 251 |
+
$toOrder[$responceObject->id]['carrier'] = $carrier->getCarrierName($responceObject);
|
| 252 |
+
$toOrder[$responceObject->id]['packing_info'] = $carrier->getPackeges($responceObject);
|
| 253 |
+
$toOrder[$responceObject->id]['carrier_type'] = $carrier_type;
|
| 254 |
+
$toOrder[$responceObject->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 255 |
+
$toOrder[$responceObject->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 256 |
+
$toOrder[$responceObject->id]['self_pack'] = $self_pack;
|
| 257 |
+
$toOrder[$responceObject->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 258 |
+
$toOrder[$responceObject->id]['carrier_accessorial'] = $responceObject->shipping->carrier_accessorial;
|
| 259 |
+
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
if($is_multi_zip) {
|
| 264 |
+
Mage::getSingleton('core/session')->setMultiZipCode(true);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
}else{
|
| 270 |
+
$api_error = true;
|
| 271 |
+
/*foreach($checkattributes as $rate_error) {
|
| 272 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 273 |
+
}*/
|
| 274 |
+
echo $error_message . '<br />';
|
| 275 |
+
if(!empty($checkattributes['items']['name']))
|
| 276 |
+
if(count($checkattributes['items']['name'])>0)
|
| 277 |
+
foreach($checkattributes['items']['name'] as $names) {
|
| 278 |
+
echo $names . '<br />';
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
if (!empty($checkattributes['from_zip'])) {
|
| 282 |
+
echo 'From Zip' . '<br />';
|
| 283 |
+
}
|
| 284 |
+
if (!empty($checkattributes['to_zip'])) {
|
| 285 |
+
echo 'To Zip' . '<br />';
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
if (!empty($checkattributes['rate_filter'])) {
|
| 289 |
+
echo 'Rate Filter' . '<br />';
|
| 290 |
+
}
|
| 291 |
+
return null;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
}else{
|
| 301 |
+
|
| 302 |
+
/* all product items has one carrier type or carrier type is null in all items */
|
| 303 |
+
foreach($grouped_items_by_zip as $origin_id=>$items_) {
|
| 304 |
+
|
| 305 |
+
/* get carrier type from first item because items grouped by carrier type and not multi carrier */
|
| 306 |
+
/* if carrier type is null, get default carrier type from settings */
|
| 307 |
+
if($items_[0]['shiphawk_carrier_type']) {
|
| 308 |
+
$carrier_type = (explode(',', $items_[0]['shiphawk_carrier_type'])) ? (explode(',', $items_[0]['shiphawk_carrier_type'])) : Mage::getStoreConfig('carriers/shiphawk_shipping/carrier_type');
|
| 309 |
+
}else{
|
| 310 |
+
$carrier_type = '';
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
if ($origin_id != 'origin_per_product') {
|
| 314 |
+
|
| 315 |
+
if($is_multi_zip) {
|
| 316 |
+
$rate_filter = 'best';
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
if($origin_id) {
|
| 320 |
+
$shipHawkOrigin = Mage::getModel('shiphawk_shipping/origins')->load($origin_id);
|
| 321 |
+
$from_zip = $shipHawkOrigin->getShiphawkOriginZipcode();
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_, $rate_filter);
|
| 325 |
+
|
| 326 |
+
if(empty($checkattributes)) {
|
| 327 |
+
|
| 328 |
+
$grouped_items_by_discount_or_markup = $carrier->getGroupedItemsByDiscountOrMarkup($items_);
|
| 329 |
+
|
| 330 |
+
if(count($grouped_items_by_discount_or_markup)>1) {
|
| 331 |
+
$is_multi_zip = true;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
if($is_multi_zip) {
|
| 335 |
+
$rate_filter = 'best';
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 339 |
+
|
| 340 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 341 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 342 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 343 |
+
|
| 344 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 345 |
+
$from_zip = $discount_items[0]['zip'];
|
| 346 |
+
$location_type = $discount_items[0]['location_type'];
|
| 347 |
+
|
| 348 |
+
// 3. one carrier, multi origin, not origin per product
|
| 349 |
+
$responceObject = $api->getShiphawkRate($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 350 |
+
if(empty($responceObject)) {
|
| 351 |
+
$api_error = true;
|
| 352 |
+
$helper->shlog('ShipHawk response is empty');
|
| 353 |
+
$helper->sendErrorMessageToShipHawk('ShipHawk response is empty');
|
| 354 |
+
break;
|
| 355 |
+
}
|
| 356 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 357 |
+
|
| 358 |
+
$custom_products_packing_price = 0;
|
| 359 |
+
|
| 360 |
+
if($custom_packing_price_setting) {
|
| 361 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
$ship_responces[] = $responceObject;
|
| 365 |
+
|
| 366 |
+
if(property_exists($responceObject, 'error')) {
|
| 367 |
+
$api_error = true;
|
| 368 |
+
$shiphawk_error = (string) $responceObject->error;
|
| 369 |
+
//Mage::log('ShipHawk response: '. $shiphawk_error, null, 'ShipHawk.log');
|
| 370 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 371 |
+
$error_message = 'ShipHawk error: '. $shiphawk_error;
|
| 372 |
+
echo $error_message ;
|
| 373 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 374 |
+
return null;
|
| 375 |
+
}else{
|
| 376 |
+
// if $rate_filter = 'best' then it is only one rate
|
| 377 |
+
if(($is_multi_zip)||($rate_filter == 'best')) {
|
| 378 |
+
|
| 379 |
+
$toOrder[$responceObject->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 380 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject);
|
| 381 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getShipHawkPrice($responceObject, $self_pack, $charge_customer_for_packing);
|
| 382 |
+
$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 383 |
+
$toOrder[$responceObject->id]['name'] = $responceObject->shipping->service;//
|
| 384 |
+
$toOrder[$responceObject->id]['items'] = $discount_items;
|
| 385 |
+
$toOrder[$responceObject->id]['from_zip'] = $from_zip;
|
| 386 |
+
$toOrder[$responceObject->id]['to_zip'] = $to_zip;
|
| 387 |
+
$toOrder[$responceObject->id]['carrier'] = $carrier->getCarrierName($responceObject);
|
| 388 |
+
$toOrder[$responceObject->id]['packing_info'] = $carrier->getPackeges($responceObject);
|
| 389 |
+
$toOrder[$responceObject->id]['carrier_type'] = $carrier_type;
|
| 390 |
+
$toOrder[$responceObject->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 391 |
+
$toOrder[$responceObject->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 392 |
+
$toOrder[$responceObject->id]['self_pack'] = $self_pack;
|
| 393 |
+
$toOrder[$responceObject->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 394 |
+
$toOrder[$responceObject->id]['carrier_accessorial'] = $responceObject->shipping->carrier_accessorial;
|
| 395 |
+
}else{
|
| 396 |
+
Mage::getSingleton('core/session')->setMultiZipCode(false);
|
| 397 |
+
foreach ($responceObject as $responce) {
|
| 398 |
+
$toOrder[$responce->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 399 |
+
//$toOrder[$responce->id]['price'] = $helper->getSummaryPrice($responce);
|
| 400 |
+
//$toOrder[$responce->id]['price'] = $helper->getShipHawkPrice($responce, $self_pack, $charge_customer_for_packing);
|
| 401 |
+
$toOrder[$responce->id]['price'] = $helper->getSummaryPrice($responce, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 402 |
+
$toOrder[$responce->id]['name'] = $responce->shipping->service;//
|
| 403 |
+
$toOrder[$responce->id]['items'] = $discount_items;
|
| 404 |
+
$toOrder[$responce->id]['from_zip'] = $from_zip;
|
| 405 |
+
$toOrder[$responce->id]['to_zip'] = $to_zip;
|
| 406 |
+
$toOrder[$responce->id]['carrier'] = $carrier->getCarrierName($responce);
|
| 407 |
+
$toOrder[$responce->id]['packing_info'] = $carrier->getPackeges($responce);
|
| 408 |
+
$toOrder[$responce->id]['carrier_type'] = $carrier_type;
|
| 409 |
+
$toOrder[$responce->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 410 |
+
$toOrder[$responce->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 411 |
+
$toOrder[$responce->id]['self_pack'] = $self_pack;
|
| 412 |
+
$toOrder[$responce->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 413 |
+
$toOrder[$responce->id]['carrier_accessorial'] = $responce->shipping->carrier_accessorial;
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
if($is_multi_zip) {
|
| 418 |
+
Mage::getSingleton('core/session')->setMultiZipCode(true);
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
}else{
|
| 423 |
+
$api_error = true;
|
| 424 |
+
/*foreach($checkattributes as $rate_error) {
|
| 425 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 426 |
+
}*/
|
| 427 |
+
echo $error_message . '<br />';
|
| 428 |
+
if(!empty($checkattributes['items']['name']))
|
| 429 |
+
if(count($checkattributes['items']['name'])>0)
|
| 430 |
+
foreach($checkattributes['items']['name'] as $names) {
|
| 431 |
+
echo $names . '<br />';
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
if (!empty($checkattributes['from_zip'])) {
|
| 435 |
+
echo 'From Zip' . '<br />';
|
| 436 |
+
}
|
| 437 |
+
if (!empty($checkattributes['to_zip'])) {
|
| 438 |
+
echo 'To Zip' . '<br />';
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
if (!empty($checkattributes['rate_filter'])) {
|
| 442 |
+
echo 'Rate Filter' . '<br />';
|
| 443 |
+
}
|
| 444 |
+
return null;
|
| 445 |
+
}
|
| 446 |
+
}else{
|
| 447 |
+
|
| 448 |
+
/* product items has per product origin, grouped by zip code */
|
| 449 |
+
$grouped_items_per_product_by_zip = $carrier->getGroupedItemsByZipPerProduct($items_);
|
| 450 |
+
|
| 451 |
+
if(count($grouped_items_per_product_by_zip) > 1 ) {
|
| 452 |
+
$is_multi_zip = true;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
if($is_multi_zip) {
|
| 456 |
+
$rate_filter = 'best';
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
foreach ($grouped_items_per_product_by_zip as $from_zip=>$items_per_product) {
|
| 460 |
+
|
| 461 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_per_product, $rate_filter);
|
| 462 |
+
|
| 463 |
+
if(empty($checkattributes)) {
|
| 464 |
+
|
| 465 |
+
$grouped_items_by_discount_or_markup = $carrier->getGroupedItemsByDiscountOrMarkup($items_per_product);
|
| 466 |
+
|
| 467 |
+
if(count($grouped_items_by_discount_or_markup)>1) {
|
| 468 |
+
$is_multi_zip = true;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
if($is_multi_zip) {
|
| 472 |
+
$rate_filter = 'best';
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 476 |
+
|
| 477 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 478 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 479 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 480 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 481 |
+
$from_zip = $discount_items[0]['zip'];
|
| 482 |
+
$location_type = $discount_items[0]['location_type'];
|
| 483 |
+
|
| 484 |
+
// 4. one carrier, multi origin, origin per product
|
| 485 |
+
$responceObject = $api->getShiphawkRate($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 486 |
+
if(empty($responceObject)) {
|
| 487 |
+
$api_error = true;
|
| 488 |
+
$helper->shlog('ShipHawk response is empty');
|
| 489 |
+
$helper->sendErrorMessageToShipHawk('ShipHawk response is empty');
|
| 490 |
+
break;
|
| 491 |
+
}
|
| 492 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 493 |
+
|
| 494 |
+
$custom_products_packing_price = 0;
|
| 495 |
+
|
| 496 |
+
if($custom_packing_price_setting) {
|
| 497 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
$ship_responces[] = $responceObject;
|
| 501 |
+
|
| 502 |
+
if(property_exists($responceObject, 'error')) {
|
| 503 |
+
$api_error = true;
|
| 504 |
+
$shiphawk_error = (string) $responceObject->error;
|
| 505 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 506 |
+
$error_message = 'ShipHawk error: '. $shiphawk_error;
|
| 507 |
+
echo $error_message ;
|
| 508 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 509 |
+
return null;
|
| 510 |
+
}else{
|
| 511 |
+
// if $rate_filter = 'best' then it is only one rate
|
| 512 |
+
if(($is_multi_zip)||($rate_filter == 'best')) {
|
| 513 |
+
|
| 514 |
+
$toOrder[$responceObject->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 515 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject);
|
| 516 |
+
//$toOrder[$responceObject->id]['price'] = $helper->getShipHawkPrice($responceObject, $self_pack, $charge_customer_for_packing);
|
| 517 |
+
$toOrder[$responceObject->id]['price'] = $helper->getSummaryPrice($responceObject, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 518 |
+
$toOrder[$responceObject->id]['name'] = $responceObject->shipping->service;//
|
| 519 |
+
$toOrder[$responceObject->id]['items'] = $discount_items;
|
| 520 |
+
$toOrder[$responceObject->id]['from_zip'] = $from_zip;
|
| 521 |
+
$toOrder[$responceObject->id]['to_zip'] = $to_zip;
|
| 522 |
+
$toOrder[$responceObject->id]['carrier'] = $carrier->getCarrierName($responceObject);
|
| 523 |
+
$toOrder[$responceObject->id]['packing_info'] = $carrier->getPackeges($responceObject);
|
| 524 |
+
$toOrder[$responceObject->id]['carrier_type'] = $carrier_type;
|
| 525 |
+
$toOrder[$responceObject->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 526 |
+
$toOrder[$responceObject->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 527 |
+
$toOrder[$responceObject->id]['self_pack'] = $self_pack;
|
| 528 |
+
$toOrder[$responceObject->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 529 |
+
$toOrder[$responceObject->id]['carrier_accessorial'] = $responceObject->shipping->carrier_accessorial;
|
| 530 |
+
}else{
|
| 531 |
+
Mage::getSingleton('core/session')->setMultiZipCode(false);
|
| 532 |
+
foreach ($responceObject as $responce) {
|
| 533 |
+
$toOrder[$responce->id]['product_ids'] = $carrier->getProductIds($discount_items);
|
| 534 |
+
//$toOrder[$responce->id]['price'] = $helper->getSummaryPrice($responce);
|
| 535 |
+
//$toOrder[$responce->id]['price'] = $helper->getShipHawkPrice($responce, $self_pack, $charge_customer_for_packing);
|
| 536 |
+
$toOrder[$responce->id]['price'] = $helper->getSummaryPrice($responce, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 537 |
+
$toOrder[$responce->id]['name'] = $responce->shipping->service;//
|
| 538 |
+
$toOrder[$responce->id]['items'] = $discount_items;
|
| 539 |
+
$toOrder[$responce->id]['from_zip'] = $from_zip;
|
| 540 |
+
$toOrder[$responce->id]['to_zip'] = $to_zip;
|
| 541 |
+
$toOrder[$responce->id]['carrier'] = $carrier->getCarrierName($responce);
|
| 542 |
+
$toOrder[$responce->id]['packing_info'] = $carrier->getPackeges($responce);
|
| 543 |
+
$toOrder[$responce->id]['carrier_type'] = $carrier_type;
|
| 544 |
+
$toOrder[$responce->id]['shiphawk_discount_fixed'] = $flat_markup_discount;
|
| 545 |
+
$toOrder[$responce->id]['shiphawk_discount_percentage'] = $percentage_markup_discount;
|
| 546 |
+
$toOrder[$responce->id]['self_pack'] = $self_pack;
|
| 547 |
+
$toOrder[$responce->id]['custom_products_packing_price'] = $custom_products_packing_price;
|
| 548 |
+
$toOrder[$responce->id]['carrier_accessorial'] = $responce->shipping->carrier_accessorial;
|
| 549 |
+
}
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
if($is_multi_zip) {
|
| 553 |
+
Mage::getSingleton('core/session')->setMultiZipCode(true);
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
}
|
| 557 |
+
}else{
|
| 558 |
+
$api_error = true;
|
| 559 |
+
/*foreach($checkattributes as $rate_error) {
|
| 560 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 561 |
+
}*/
|
| 562 |
+
|
| 563 |
+
echo $error_message . '<br />';
|
| 564 |
+
if(!empty($checkattributes['items']['name']))
|
| 565 |
+
if(count($checkattributes['items']['name'])>0)
|
| 566 |
+
foreach($checkattributes['items']['name'] as $names) {
|
| 567 |
+
echo $names . '<br />';
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
if (!empty($checkattributes['from_zip'])) {
|
| 571 |
+
echo 'From Zip' . '<br />';
|
| 572 |
+
}
|
| 573 |
+
if (!empty($checkattributes['to_zip'])) {
|
| 574 |
+
echo 'To Zip' . '<br />';
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
if (!empty($checkattributes['rate_filter'])) {
|
| 578 |
+
echo 'Rate Filter' . '<br />';
|
| 579 |
+
}
|
| 580 |
+
return null;
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
}
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
$name_service = '';
|
| 590 |
+
$summ_price = 0;
|
| 591 |
+
if(!$api_error) {
|
| 592 |
+
|
| 593 |
+
$services = $carrier->getServices($ship_responces, $toOrder, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting);
|
| 594 |
+
|
| 595 |
+
foreach ($services as $id_service=>$service) {
|
| 596 |
+
if (!$is_multi_zip) {
|
| 597 |
+
|
| 598 |
+
}else{
|
| 599 |
+
$name_service .= $service['name'] . ', ';
|
| 600 |
+
$summ_price += $service['price'];
|
| 601 |
+
}
|
| 602 |
+
}
|
| 603 |
+
//save rate_id info for Book in PopUP
|
| 604 |
+
Mage::getSingleton('core/session')->setNewShiphawkBookId($toOrder);
|
| 605 |
+
|
| 606 |
+
//remove last comma
|
| 607 |
+
if(strlen($name_service) >2) {
|
| 608 |
+
if ($name_service{strlen($name_service)-2} == ',') {
|
| 609 |
+
$name_service = substr($name_service,0,-2);
|
| 610 |
+
}
|
| 611 |
+
}
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
$result['name_service'] = $name_service;
|
| 615 |
+
$result['summ_price'] = $summ_price;
|
| 616 |
+
$result['rate_filter'] = $rate_filter;
|
| 617 |
+
$result['is_multi_zip'] = $is_multi_zip;
|
| 618 |
+
$result['to_order'] = $toOrder;
|
| 619 |
+
|
| 620 |
+
return $result;
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Adminhtml/System/Config/Form/Button.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 3 |
+
{
|
| 4 |
+
/*
|
| 5 |
+
* Set template
|
| 6 |
+
*/
|
| 7 |
+
protected function _construct()
|
| 8 |
+
{
|
| 9 |
+
parent::_construct();
|
| 10 |
+
$this->setTemplate('shiphawk/button.phtml');
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Return element html
|
| 15 |
+
*
|
| 16 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 17 |
+
* @return string
|
| 18 |
+
*/
|
| 19 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 20 |
+
{
|
| 21 |
+
return $this->_toHtml();
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Return ajax url for button
|
| 26 |
+
*
|
| 27 |
+
* @return string
|
| 28 |
+
*/
|
| 29 |
+
public function getAjaxCheckUrl()
|
| 30 |
+
{
|
| 31 |
+
return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_import/import");
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Generate button html
|
| 36 |
+
*
|
| 37 |
+
* @return string
|
| 38 |
+
*/
|
| 39 |
+
public function getButtonHtml()
|
| 40 |
+
{
|
| 41 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 42 |
+
->setData(array(
|
| 43 |
+
'id' => 'faqs_button',
|
| 44 |
+
'label' => $this->helper('adminhtml')->__('Start Import'),
|
| 45 |
+
'onclick' => 'javascript:importcsv(); return false;'
|
| 46 |
+
));
|
| 47 |
+
|
| 48 |
+
return $button->toHtml();
|
| 49 |
+
}
|
| 50 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Disabled.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Catalog_Product_Helper_Form_Disabled extends Varien_Data_Form_Element_Text
|
| 3 |
+
{
|
| 4 |
+
public function getAfterElementHtml()
|
| 5 |
+
{
|
| 6 |
+
$html = parent::getAfterElementHtml();
|
| 7 |
+
return $html." <script>
|
| 8 |
+
$('".$this->getHtmlId()."').hide();
|
| 9 |
+
</script>";
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Type.php
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Catalog_Product_Helper_Form_Type extends Varien_Data_Form_Element_Text
|
| 3 |
+
{
|
| 4 |
+
public function getAfterElementHtml()
|
| 5 |
+
{
|
| 6 |
+
$html = parent::getAfterElementHtml();
|
| 7 |
+
|
| 8 |
+
$html .= '<style>
|
| 9 |
+
.type_link:hover {
|
| 10 |
+
text-decoration: underline;
|
| 11 |
+
cursor: pointer;
|
| 12 |
+
}
|
| 13 |
+
</style>';
|
| 14 |
+
|
| 15 |
+
$html .= '<div id="type_product" style="position: absolute; z-index: 99; background-color: #ffffff" ></div>';
|
| 16 |
+
return $html." <script>
|
| 17 |
+
|
| 18 |
+
var typeloader;
|
| 19 |
+
$('".$this->getHtmlId()."').observe('keyup', function(event){
|
| 20 |
+
clearTimeout(typeloader);
|
| 21 |
+
typeloader = setTimeout(function(){ respondToClick(event); }, 750);
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
function setIdValue(el) {
|
| 25 |
+
|
| 26 |
+
$('shiphawk_type_of_product').value = el.innerHTML;
|
| 27 |
+
$('shiphawk_type_of_product_value').value = el.id;
|
| 28 |
+
$('type_product').hide();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function respondToClick(event) {
|
| 32 |
+
|
| 33 |
+
var element = event.element();
|
| 34 |
+
|
| 35 |
+
var minlength = 3;
|
| 36 |
+
|
| 37 |
+
var url = '".$this->getTypeUrl()."';
|
| 38 |
+
var parameters = {
|
| 39 |
+
search_tag: element.value
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
if(element.value.length >= minlength ) {
|
| 43 |
+
new Ajax.Request(url, {
|
| 44 |
+
method: 'post',
|
| 45 |
+
parameters: parameters,
|
| 46 |
+
onSuccess: function(transport) {
|
| 47 |
+
$('type_product').update(transport.responseText);
|
| 48 |
+
$('type_product').show();
|
| 49 |
+
},
|
| 50 |
+
onLoading:function(transport)
|
| 51 |
+
{
|
| 52 |
+
}
|
| 53 |
+
});
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
</script>";
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
public function getTypeUrl() {
|
| 61 |
+
return Mage::getUrl('shiphawk/index/search');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Shipping/Tracking/Popup.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Block_Shipping_Tracking_Popup extends Mage_Shipping_Block_Tracking_Popup
|
| 3 |
+
{
|
| 4 |
+
public function getTrackingInfo()
|
| 5 |
+
{
|
| 6 |
+
$_results = parent::getTrackingInfo();
|
| 7 |
+
return $_results;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
}
|
app/code/community/Shiphawk/Shipping/Block/Version.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Shiphawk_Shipping_Block_Version extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 7 |
+
{
|
| 8 |
+
$ver = (Mage::getConfig()->getModuleConfig('Shiphawk_Shipping')->version);
|
| 9 |
+
$html = 'You current config version is ' . $ver;
|
| 10 |
+
|
| 11 |
+
return $html;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
}
|
app/code/community/Shiphawk/Shipping/Helper/Data.php
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Shiphawk_Shipping_Helper_Data extends
|
| 4 |
+
Mage_Core_Helper_Abstract
|
| 5 |
+
{
|
| 6 |
+
/**
|
| 7 |
+
* Get api key
|
| 8 |
+
*
|
| 9 |
+
* @return mixed
|
| 10 |
+
*/
|
| 11 |
+
public function getApiKey()
|
| 12 |
+
{
|
| 13 |
+
return Mage::getStoreConfig('carriers/shiphawk_shipping/api_key');
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Get Calculate Rate on Cart Change
|
| 18 |
+
*
|
| 19 |
+
* @return mixed
|
| 20 |
+
*/
|
| 21 |
+
public function getCalcRateOnCartChange()
|
| 22 |
+
{
|
| 23 |
+
return Mage::getStoreConfig('carriers/shiphawk_shipping/calc_rate_on_cart_change');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Get callback url for shipments
|
| 28 |
+
*
|
| 29 |
+
* @return mixed
|
| 30 |
+
*/
|
| 31 |
+
public function getCallbackUrl($api_key)
|
| 32 |
+
{
|
| 33 |
+
return Mage::getUrl('shiphawk/index/tracking', array('api_key' => $api_key));
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public function getRateFilter($is_admin = false, $order = null)
|
| 37 |
+
{
|
| 38 |
+
if($order) {
|
| 39 |
+
if($order->getShiphawkRateFilter()) {
|
| 40 |
+
return $order->getShiphawkRateFilter();
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if ($is_admin == true) {
|
| 45 |
+
return Mage::getStoreConfig('carriers/shiphawk_shipping/admin_rate_filter');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
return Mage::getStoreConfig('carriers/shiphawk_shipping/rate_filter');
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Get api url
|
| 53 |
+
*
|
| 54 |
+
* @return mixed
|
| 55 |
+
*/
|
| 56 |
+
public function getApiUrl()
|
| 57 |
+
{
|
| 58 |
+
//return 'https://sandbox.shiphawk.com/api/v1/';
|
| 59 |
+
return Mage::getStoreConfig('carriers/shiphawk_shipping/gateway_url');
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Get Shiphawk attributes codes
|
| 64 |
+
*
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
public function getAttributes()
|
| 68 |
+
{
|
| 69 |
+
$shiphawk_attributes = array('shiphawk_length','shiphawk_width', 'shiphawk_height', 'shiphawk_origin_zipcode', 'shiphawk_origin_firstname', 'shiphawk_origin_lastname'
|
| 70 |
+
,'shiphawk_origin_addressline1','shiphawk_origin_phonenum','shiphawk_origin_city','shiphawk_origin_state','shiphawk_type_of_product','shiphawk_type_of_product_value'
|
| 71 |
+
,'shiphawk_quantity', 'shiphawk_item_value','shiphawk_item_is_packed','shiphawk_origin_location');
|
| 72 |
+
|
| 73 |
+
return $shiphawk_attributes;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
public function isShipHawkShipping($shipping_code) {
|
| 77 |
+
$result = strpos($shipping_code, 'shiphawk_shipping');
|
| 78 |
+
return $result;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
public function getShipHawkCode($shiphawk_book_id, $shipping_code) {
|
| 82 |
+
$result = array();
|
| 83 |
+
|
| 84 |
+
foreach ($shiphawk_book_id as $rate_id=>$method_data) {
|
| 85 |
+
//if( strpos($shipping_description, $method_data['name']) !== false ) {
|
| 86 |
+
//if( $shipping_code == $method_data['price'] ) {
|
| 87 |
+
$shipping_price = (string) $method_data['price'];
|
| 88 |
+
if($this->getOriginalShipHawkShippingPrice($shipping_code, $shipping_price)) {
|
| 89 |
+
$result = array($rate_id => $method_data);
|
| 90 |
+
return $result;
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
return $result;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
public function checkIsAdmin () {
|
| 97 |
+
if(Mage::app()->getStore()->isAdmin())
|
| 98 |
+
{
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if(Mage::getDesign()->getArea() == 'adminhtml')
|
| 103 |
+
{
|
| 104 |
+
return true;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return false;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
public function generateRandomString($length = 10) {
|
| 111 |
+
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
| 112 |
+
$charactersLength = strlen($characters);
|
| 113 |
+
$randomString = '';
|
| 114 |
+
for ($i = 0; $i < $length; $i++) {
|
| 115 |
+
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
| 116 |
+
}
|
| 117 |
+
return $randomString;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
public function checkShipHawkAttributes($from_zip, $to_zip, $items_, $rate_filter) {
|
| 121 |
+
$error = array();
|
| 122 |
+
if (empty($from_zip)) {
|
| 123 |
+
$error['from_zip'] = 'empty from zip';
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
if (empty($to_zip)) {
|
| 127 |
+
$error['to_zip'] = 'empty to zip';
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
if (empty($rate_filter)) {
|
| 131 |
+
$error['rate_filter'] = 'rate_filter error';
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
foreach ($items_ as $item) {
|
| 135 |
+
|
| 136 |
+
if($this->checkItem($item)) {
|
| 137 |
+
$error['items'][] = $this->checkItem($item);
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
return $error;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
public function checkItem($item) {
|
| 145 |
+
$product_name = Mage::getModel('catalog/product')->load($item['product_id'])->getName();
|
| 146 |
+
|
| 147 |
+
if(empty($item['width'])) return $product_name . " doesn't have width";
|
| 148 |
+
if(empty($item['length'])) return $product_name . " doesn't have length";
|
| 149 |
+
if(empty($item['height'])) return $product_name . " doesn't have height";
|
| 150 |
+
if(empty($item['quantity'])) return $product_name . " doesn't have quantity";
|
| 151 |
+
if(empty($item['packed'])) return $product_name . " doesn't have packed";
|
| 152 |
+
if(empty($item['id'])) return $product_name . " doesn't have product type id";
|
| 153 |
+
|
| 154 |
+
return null;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
public function discountPercentage($price) {
|
| 158 |
+
$discountPercentage = Mage::getStoreConfig('carriers/shiphawk_shipping/discount_percentage');
|
| 159 |
+
|
| 160 |
+
if(!empty($discountPercentage)) {
|
| 161 |
+
$price = $price + ($price * ($discountPercentage/100));
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
return $price;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
public function discountFixed($price) {
|
| 169 |
+
$discountFixed = Mage::getStoreConfig('carriers/shiphawk_shipping/discount_fixed');
|
| 170 |
+
if(!empty($discountFixed)) {
|
| 171 |
+
$price = $price + ($discountFixed);
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
return $price;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
public function getDiscountShippingPrice($price) {
|
| 178 |
+
$price = $this->discountPercentage($price);
|
| 179 |
+
$price = $this->discountFixed($price);
|
| 180 |
+
|
| 181 |
+
if($price <= 0) {
|
| 182 |
+
return 0;
|
| 183 |
+
}
|
| 184 |
+
return $price;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
public function getOriginalShipHawkShippingPrice($shipping_code, $shipping_method_value) {
|
| 188 |
+
$result = strpos($shipping_code, $shipping_method_value);
|
| 189 |
+
return $result;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
public function checkShipHawkOriginAttributes($product) {
|
| 193 |
+
|
| 194 |
+
$required_origins_attributes = array('shiphawk_origin_firstname', 'shiphawk_origin_lastname', 'shiphawk_origin_addressline1', 'shiphawk_origin_city', 'shiphawk_origin_state', 'shiphawk_origin_zipcode', 'shiphawk_origin_phonenum', 'shiphawk_origin_location');
|
| 195 |
+
|
| 196 |
+
foreach($required_origins_attributes as $attribute_code) {
|
| 197 |
+
$attribute_value = $product->getData($attribute_code);
|
| 198 |
+
if(empty($attribute_value)) {
|
| 199 |
+
return false;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
return true;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* @param $object Object of rate response
|
| 208 |
+
* @param null $opt_to_self_pack "Opt to Self Pack" from settings
|
| 209 |
+
* @param null $charge_customer_for_packing
|
| 210 |
+
* @param null $custom_packing_price "Custom Packing Prices?" from settings
|
| 211 |
+
* @param null $custom_packing_price_amount Sum of custom prices for product packaging
|
| 212 |
+
* @return mixed
|
| 213 |
+
*/
|
| 214 |
+
|
| 215 |
+
public function getSummaryPrice($object, $opt_to_self_pack = null, $charge_customer_for_packing = null, $custom_packing_price = null, $custom_packing_price_amount = null) {
|
| 216 |
+
|
| 217 |
+
if(!$opt_to_self_pack) {
|
| 218 |
+
return $object->shipping->price + $object->packing->price + $object->pickup->price + $object->delivery->price + $object->insurance->price;
|
| 219 |
+
}else{
|
| 220 |
+
if (( $opt_to_self_pack == 1) && ($custom_packing_price == 1)) {
|
| 221 |
+
|
| 222 |
+
if($this->ChargeCustomerForPacking($opt_to_self_pack, $charge_customer_for_packing) == false) {
|
| 223 |
+
return $object->shipping->price + $object->delivery->price + $object->insurance->price;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
return $object->shipping->price + $object->delivery->price + $object->insurance->price + $custom_packing_price_amount;
|
| 227 |
+
|
| 228 |
+
}else{
|
| 229 |
+
if($this->ChargeCustomerForPacking($opt_to_self_pack, $charge_customer_for_packing) == false) {
|
| 230 |
+
return $object->shipping->price + $object->delivery->price + $object->insurance->price;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
}
|
| 235 |
+
return $object->shipping->price + $object->packing->price + $object->pickup->price + $object->delivery->price + $object->insurance->price;
|
| 236 |
+
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
public function getShipHawkPrice($object, $opt_to_self_pack = null, $charge_customer_for_packing = null) {
|
| 242 |
+
|
| 243 |
+
if(!$opt_to_self_pack) {
|
| 244 |
+
return $object->shipping->price + $object->packing->price + $object->pickup->price + $object->delivery->price + $object->insurance->price;
|
| 245 |
+
}else{
|
| 246 |
+
|
| 247 |
+
return $object->shipping->price + $object->delivery->price + $object->insurance->price;
|
| 248 |
+
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
public function ChargeCustomerForPacking($opt_to_self_pack = null, $charge_customer_for_packing = null) {
|
| 254 |
+
|
| 255 |
+
$opt_to_self_pack = ($opt_to_self_pack === null) ? Mage::getStoreConfig('carriers/shiphawk_shipping/opt_to_self_pack') : $opt_to_self_pack;
|
| 256 |
+
|
| 257 |
+
$charge_customer_for_packing = ($charge_customer_for_packing === null) ? Mage::getStoreConfig('carriers/shiphawk_shipping/charge_customer_for_packing') : $charge_customer_for_packing;
|
| 258 |
+
|
| 259 |
+
if(($opt_to_self_pack == 1)) {
|
| 260 |
+
return $charge_customer_for_packing;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
return false;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
public function getCustomPackingPriceSumm($items) {
|
| 267 |
+
$packing_summ = 0;
|
| 268 |
+
foreach($items as $item) {
|
| 269 |
+
if(isset($item['shiphawk_custom_packing_price']))
|
| 270 |
+
$packing_summ += $item['shiphawk_custom_packing_price']*$item['quantity'];
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
return $packing_summ;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
public function getSelfPacked() {
|
| 277 |
+
$opt_to_self_pack = Mage::getStoreConfig('carriers/shiphawk_shipping/opt_to_self_pack');
|
| 278 |
+
$charge_customer_for_packing = Mage::getStoreConfig('carriers/shiphawk_shipping/charge_customer_for_packing');
|
| 279 |
+
|
| 280 |
+
/* if(($opt_to_self_pack == 1) && ($charge_customer_for_packing == 1)) {
|
| 281 |
+
return 0;
|
| 282 |
+
}*/
|
| 283 |
+
|
| 284 |
+
return $opt_to_self_pack;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
public function getBOLurl($shipment_id) {
|
| 288 |
+
|
| 289 |
+
$api_key = $this->getApiKey();
|
| 290 |
+
|
| 291 |
+
$bol_url = $this->getApiUrl() . 'shipments/' . $shipment_id . '/bol?api_key=' . $api_key;
|
| 292 |
+
|
| 293 |
+
$curl = curl_init();
|
| 294 |
+
|
| 295 |
+
curl_setopt($curl, CURLOPT_URL, $bol_url);
|
| 296 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
|
| 297 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 298 |
+
|
| 299 |
+
$resp = curl_exec($curl);
|
| 300 |
+
$arr_res = json_decode($resp);
|
| 301 |
+
|
| 302 |
+
return $arr_res;
|
| 303 |
+
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/**
|
| 307 |
+
* For get shipping price with personal product shipping discount
|
| 308 |
+
*
|
| 309 |
+
* @param $price
|
| 310 |
+
* @param $orderData
|
| 311 |
+
* @return int
|
| 312 |
+
*
|
| 313 |
+
* @version 20150706
|
| 314 |
+
*/
|
| 315 |
+
public function getTotalDiscountShippingPrice($price, $orderData) {
|
| 316 |
+
$items = $orderData['items'];
|
| 317 |
+
$result = 0;
|
| 318 |
+
|
| 319 |
+
if (empty($items)) {
|
| 320 |
+
return $result;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
$productModel = Mage::getModel('catalog/product');
|
| 324 |
+
|
| 325 |
+
// if one items in pack get discount from product, if it empty then for sys. config
|
| 326 |
+
if (count($items) == 1) {
|
| 327 |
+
$product = $productModel->load($items[0]['product_id']);
|
| 328 |
+
$shiphawkDiscountPercentage = $product->getShiphawkDiscountPercentage();
|
| 329 |
+
$shiphawkDiscountFixed = $product->getShiphawkDiscountFixed();
|
| 330 |
+
|
| 331 |
+
if (empty($shiphawkDiscountPercentage) && empty($shiphawkDiscountFixed)) {
|
| 332 |
+
return $this->getDiscountShippingPrice($price);
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
$result = $price + ($price * ($shiphawkDiscountPercentage/100));
|
| 336 |
+
$result = $result + ($shiphawkDiscountFixed);
|
| 337 |
+
|
| 338 |
+
if($result <= 0) {
|
| 339 |
+
return 0;
|
| 340 |
+
}
|
| 341 |
+
} else {
|
| 342 |
+
$discount_arr = array();
|
| 343 |
+
foreach($items as $item) {
|
| 344 |
+
$product = $productModel->load($item['product_id']);
|
| 345 |
+
$shiphawkDiscountPercentage = $product->getShiphawkDiscountPercentage();
|
| 346 |
+
$shiphawkDiscountFixed = $product->getShiphawkDiscountFixed();
|
| 347 |
+
|
| 348 |
+
if (empty($shiphawkDiscountFixed) && empty($shiphawkDiscountPercentage)) {
|
| 349 |
+
$discount_arr['empty_val'] = array('percentage' => 0, 'fixed' => 0);
|
| 350 |
+
} else {
|
| 351 |
+
$discount_arr[$shiphawkDiscountPercentage . '_' . $shiphawkDiscountFixed] = array(
|
| 352 |
+
'percentage' => $shiphawkDiscountPercentage,
|
| 353 |
+
'fixed' => $shiphawkDiscountFixed
|
| 354 |
+
);
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
if (count($discount_arr) == 1 && !empty($discount_arr['empty_val'])) {
|
| 359 |
+
return $this->getDiscountShippingPrice($price);
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
if (count($discount_arr) > 1) {
|
| 363 |
+
return $price;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
foreach($discount_arr as $discount) {
|
| 367 |
+
$result = $price + ($price * ($discount['percentage']/100));
|
| 368 |
+
$result = $result + ($discount['fixed']);
|
| 369 |
+
break;
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
return $result;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
public function getProductCarrierType($product) {
|
| 377 |
+
$carrier_types = explode(',', $product->getShiphawkCarrierType());
|
| 378 |
+
|
| 379 |
+
$attr = Mage::getModel('catalog/product')->getResource()->getAttribute('shiphawk_carrier_type');
|
| 380 |
+
$carrier_types_labels = array();
|
| 381 |
+
|
| 382 |
+
foreach($carrier_types as $carrier_type) {
|
| 383 |
+
if ($attr->usesSource()) {
|
| 384 |
+
$carrier_types_label = $attr->getSource()->getOptionText($carrier_type);
|
| 385 |
+
|
| 386 |
+
if(($carrier_types_label == 'All')||(!$carrier_types_label)) {
|
| 387 |
+
return '';
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
$carrier_types_labels[] = $carrier_types_label;
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
return implode(",", $carrier_types_labels);
|
| 395 |
+
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
public function getProductDiscountMarkupPrice($shipping_price, $shiphawk_discount_percentage, $shiphawk_discount_fixed) {
|
| 399 |
+
|
| 400 |
+
if(!empty($shiphawk_discount_percentage)) {
|
| 401 |
+
$shipping_price = $shipping_price + ($shipping_price * ($shiphawk_discount_percentage/100));
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
if(!empty($shiphawk_discount_fixed)) {
|
| 405 |
+
$shipping_price = $shipping_price + ($shiphawk_discount_fixed);
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
if($shipping_price <= 0) {
|
| 409 |
+
return 0;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
return $shipping_price;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
public function shlog($var, $file = 'shiphawk-error.log') {
|
| 416 |
+
$enable_log = Mage::getStoreConfig('carriers/shiphawk_shipping/enable_log');
|
| 417 |
+
|
| 418 |
+
if($enable_log == 1) {
|
| 419 |
+
Mage::log($var, null, $file);
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
public function sendErrorMessageToShipHawk($error_text) {
|
| 424 |
+
$enable_log = Mage::getStoreConfig('carriers/shiphawk_shipping/enable_log');
|
| 425 |
+
$enable_sending_message = Mage::getStoreConfig('carriers/shiphawk_shipping/email_error_to_shiphawk');
|
| 426 |
+
|
| 427 |
+
if(($enable_log == 1)&&($enable_sending_message == 1)) {
|
| 428 |
+
|
| 429 |
+
$this->sendMailToShiphawk($error_text);
|
| 430 |
+
|
| 431 |
+
}
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
public function sendMailToShiphawk($shiphawk_error_log) {
|
| 435 |
+
$template_id = 'shiphawk_error_email';
|
| 436 |
+
$shiphawk_api_key = $this->getApiKey();
|
| 437 |
+
|
| 438 |
+
$email_to = 'extensionslog@shiphawk.com';
|
| 439 |
+
|
| 440 |
+
$email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
|
| 441 |
+
|
| 442 |
+
$email_template_variables = array(
|
| 443 |
+
'shiphawk_error_log' => $shiphawk_error_log,
|
| 444 |
+
'shiphawk_api_key' => $shiphawk_api_key
|
| 445 |
+
);
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
$sender_name = 'store owner';
|
| 449 |
+
|
| 450 |
+
$sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
|
| 451 |
+
$email_template->setSenderName('Store Owner');
|
| 452 |
+
$email_template->setSenderEmail($sender_email);
|
| 453 |
+
|
| 454 |
+
$email_template->send($email_to, $sender_name, $email_template_variables);
|
| 455 |
+
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
public function getAccessoriesPrice($accessoriesPriceData) {
|
| 459 |
+
$accessoriesPrice = 0;
|
| 460 |
+
|
| 461 |
+
if(!empty($accessoriesPriceData)) {
|
| 462 |
+
foreach($accessoriesPriceData as $typeName => $type) {
|
| 463 |
+
foreach($type as $name => $values) {
|
| 464 |
+
foreach($values as $key => $value) {
|
| 465 |
+
|
| 466 |
+
$accessoriesPrice += (float)$value;
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
return $accessoriesPrice;
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
public function checkIsItCartPage() {
|
| 476 |
+
$request = Mage::app()->getFrontController()->getRequest();
|
| 477 |
+
$module = $request->getModuleName();
|
| 478 |
+
$controller = $request->getControllerName();
|
| 479 |
+
$action = $request->getActionName();
|
| 480 |
+
|
| 481 |
+
if($module == 'checkout' && $controller == 'cart' && $action == 'index')
|
| 482 |
+
{
|
| 483 |
+
return true;
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
return false;
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
}
|
app/code/community/Shiphawk/Shipping/Helper/Origin.php
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Shiphawk_Shipping_Helper_Origin extends
|
| 4 |
+
Mage_Core_Helper_Abstract
|
| 5 |
+
{
|
| 6 |
+
/**
|
| 7 |
+
* Contains current collection
|
| 8 |
+
* @var string
|
| 9 |
+
*/
|
| 10 |
+
protected $_list = null;
|
| 11 |
+
|
| 12 |
+
public function __construct()
|
| 13 |
+
{
|
| 14 |
+
$collection = Mage::getModel('shiphawk_shipping/origins')->getCollection()
|
| 15 |
+
;
|
| 16 |
+
|
| 17 |
+
$this->setList($collection);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Sets current collection
|
| 22 |
+
* @param $query
|
| 23 |
+
*/
|
| 24 |
+
public function setList($collection)
|
| 25 |
+
{
|
| 26 |
+
$this->_list = $collection;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Returns indexes of the fetched array as headers for CSV
|
| 31 |
+
* @param array $products
|
| 32 |
+
* @return array
|
| 33 |
+
*/
|
| 34 |
+
protected function _getCsvHeaders($questions)
|
| 35 |
+
{
|
| 36 |
+
$question = current($questions);
|
| 37 |
+
$headers = array_keys($question->getData());
|
| 38 |
+
|
| 39 |
+
return $headers;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Generates CSV file with items's list according to the collection in the $this->_list
|
| 44 |
+
* @return array
|
| 45 |
+
*/
|
| 46 |
+
public function generateQuestList()
|
| 47 |
+
{
|
| 48 |
+
if (!is_null($this->_list)) {
|
| 49 |
+
$items = $this->_list->getItems();
|
| 50 |
+
if (count($items) > 0) {
|
| 51 |
+
|
| 52 |
+
$io = new Varien_Io_File();
|
| 53 |
+
$path = Mage::getBaseDir('var') . DS . 'export' . DS;
|
| 54 |
+
$name = md5(microtime());
|
| 55 |
+
$file = $path . DS . $name . '.csv';
|
| 56 |
+
$io->setAllowCreateFolders(true);
|
| 57 |
+
$io->open(array('path' => $path));
|
| 58 |
+
$io->streamOpen($file, 'w+');
|
| 59 |
+
$io->streamLock(true);
|
| 60 |
+
|
| 61 |
+
$io->streamWriteCsv($this->_getCsvHeaders($items));
|
| 62 |
+
foreach ($items as $question) {
|
| 63 |
+
$io->streamWriteCsv($question->getData());
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return array(
|
| 67 |
+
'type' => 'filename',
|
| 68 |
+
'value' => $file,
|
| 69 |
+
'rm' => true // can delete file after use
|
| 70 |
+
);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Api.php
ADDED
|
@@ -0,0 +1,636 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Api extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function buildShiphawkRequest($from_zip, $to_zip, $items, $rate_filter, $carrier_type, $location_type, $shLocationType){
|
| 5 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 6 |
+
$api_key = $helper->getApiKey();
|
| 7 |
+
//$url_api_rates = $helper->getApiUrl() . 'rates/full?api_key=' . $api_key;
|
| 8 |
+
$url_api_rates = $helper->getApiUrl() . 'rates?api_key=' . $api_key;
|
| 9 |
+
|
| 10 |
+
$curl = curl_init();
|
| 11 |
+
|
| 12 |
+
if($carrier_type == '') {
|
| 13 |
+
$items_array = array(
|
| 14 |
+
'from_zip'=> $from_zip,
|
| 15 |
+
'to_zip'=> $to_zip,
|
| 16 |
+
'rate_filter' => $rate_filter,
|
| 17 |
+
'items' => $items,
|
| 18 |
+
'from_type' => $location_type,
|
| 19 |
+
'to_type' => $shLocationType,
|
| 20 |
+
);
|
| 21 |
+
}else{
|
| 22 |
+
$items_array = array(
|
| 23 |
+
'from_zip'=> $from_zip,
|
| 24 |
+
'to_zip'=> $to_zip,
|
| 25 |
+
'rate_filter' => $rate_filter,
|
| 26 |
+
'carrier_type' => $carrier_type,
|
| 27 |
+
'items' => $items,
|
| 28 |
+
'from_type' => $location_type,
|
| 29 |
+
'to_type' => $shLocationType,
|
| 30 |
+
);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
$items_array = json_encode($items_array);
|
| 34 |
+
|
| 35 |
+
curl_setopt($curl, CURLOPT_URL, $url_api_rates);
|
| 36 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
| 37 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
|
| 38 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 39 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
| 40 |
+
'Content-Type: application/json',
|
| 41 |
+
'Content-Length: ' . strlen($items_array)
|
| 42 |
+
)
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
return $curl;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function getShiphawkRate($from_zip, $to_zip, $items, $rate_filter, $carrier_type, $location_type, $shLocationType) {
|
| 49 |
+
|
| 50 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 51 |
+
$api_key = $helper->getApiKey();
|
| 52 |
+
//$url_api_rates = $helper->getApiUrl() . 'rates/full?api_key=' . $api_key;
|
| 53 |
+
$url_api_rates = $helper->getApiUrl() . 'rates?api_key=' . $api_key;
|
| 54 |
+
|
| 55 |
+
$curl = curl_init();
|
| 56 |
+
|
| 57 |
+
if($carrier_type == '') {
|
| 58 |
+
$items_array = array(
|
| 59 |
+
'from_zip'=> $from_zip,
|
| 60 |
+
'to_zip'=> $to_zip,
|
| 61 |
+
'rate_filter' => $rate_filter,
|
| 62 |
+
'items' => $items,
|
| 63 |
+
'from_type' => $location_type,
|
| 64 |
+
'to_type' => $shLocationType,
|
| 65 |
+
);
|
| 66 |
+
}else{
|
| 67 |
+
$items_array = array(
|
| 68 |
+
'from_zip'=> $from_zip,
|
| 69 |
+
'to_zip'=> $to_zip,
|
| 70 |
+
'rate_filter' => $rate_filter,
|
| 71 |
+
'carrier_type' => $carrier_type,
|
| 72 |
+
'items' => $items,
|
| 73 |
+
'from_type' => $location_type,
|
| 74 |
+
'to_type' => $shLocationType,
|
| 75 |
+
);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
$items_array = json_encode($items_array);
|
| 79 |
+
|
| 80 |
+
curl_setopt($curl, CURLOPT_URL, $url_api_rates);
|
| 81 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
| 82 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
|
| 83 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 84 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
| 85 |
+
'Content-Type: application/json',
|
| 86 |
+
'Content-Length: ' . strlen($items_array)
|
| 87 |
+
)
|
| 88 |
+
);
|
| 89 |
+
|
| 90 |
+
$resp = curl_exec($curl);
|
| 91 |
+
|
| 92 |
+
$arr_res = json_decode($resp);
|
| 93 |
+
|
| 94 |
+
curl_close($curl);
|
| 95 |
+
return $arr_res;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
public function toBook($order, $rate_id, $products_ids, $accessories = array(), $is_auto = false, $self_packed, $is_rerate = null)
|
| 99 |
+
{
|
| 100 |
+
$ship_addr = $order->getShippingAddress()->getData();
|
| 101 |
+
$bill_addr = $order->getBillingAddress()->getData();
|
| 102 |
+
$order_increment_id = $order->getIncrementId();
|
| 103 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 104 |
+
|
| 105 |
+
$api_key = Mage::helper('shiphawk_shipping')->getApiKey();
|
| 106 |
+
$api_url = Mage::helper('shiphawk_shipping')->getApiUrl();
|
| 107 |
+
$url_api = $api_url . 'shipments?api_key=' . $api_key;
|
| 108 |
+
|
| 109 |
+
$self_packed = $self_packed ? 'true' : 'false';
|
| 110 |
+
|
| 111 |
+
/* get shiphawk origin data from first product, because products are grouped by origin (or by zip code) and have same address */
|
| 112 |
+
$origin_product = Mage::getModel('catalog/product')->load($products_ids['product_ids'][0]);
|
| 113 |
+
$per_product = Mage::helper('shiphawk_shipping')->checkShipHawkOriginAttributes($origin_product);
|
| 114 |
+
$origin_address_product = $this->_getProductOriginData($products_ids['product_ids'][0], $per_product);
|
| 115 |
+
/* */
|
| 116 |
+
|
| 117 |
+
$curl = curl_init();
|
| 118 |
+
|
| 119 |
+
$default_origin_address = $this->_getDefaultOriginData();
|
| 120 |
+
|
| 121 |
+
$order_email = $ship_addr['email'];
|
| 122 |
+
|
| 123 |
+
if (Mage::getStoreConfig('carriers/shiphawk_shipping/order_received') == 1) {
|
| 124 |
+
$administrator_email = Mage::getStoreConfig('carriers/shiphawk_shipping/administrator_email');
|
| 125 |
+
$order_email = ($administrator_email) ? $administrator_email : $ship_addr['email'];
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
$origin_address = (empty($origin_address_product)) ? $default_origin_address : $origin_address_product;
|
| 129 |
+
|
| 130 |
+
/* For accessories */
|
| 131 |
+
$orderAccessories = $order->getShiphawkShippingAccessories();
|
| 132 |
+
|
| 133 |
+
if ($is_auto) {
|
| 134 |
+
$orderAccessories = json_decode($orderAccessories, true);
|
| 135 |
+
if($is_rerate) {
|
| 136 |
+
|
| 137 |
+
foreach($accessories as $orderAccessoriesType => $orderAccessor) {
|
| 138 |
+
foreach($orderAccessor as $key => $orderAccessorValues) {
|
| 139 |
+
$itemsAccessories[] = array('id' => str_replace("'", '', $key));
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}else{
|
| 143 |
+
foreach($orderAccessories as $orderAccessoriesType => $orderAccessor) {
|
| 144 |
+
foreach($orderAccessor as $key => $orderAccessorValues) {
|
| 145 |
+
$itemsAccessories[] = array('id' => str_replace("'", '', $key));
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
} else {
|
| 150 |
+
$itemsAccessories = $this->getAccessoriesForBook($accessories, $orderAccessories);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
$next_bussines_day = date('Y-m-d', strtotime('now +1 Weekday'));
|
| 154 |
+
$items_array = array(
|
| 155 |
+
'rate_id'=> $rate_id,
|
| 156 |
+
'order_email'=> $order_email,
|
| 157 |
+
'xid'=>$order_increment_id,
|
| 158 |
+
'self_packed'=>$self_packed,
|
| 159 |
+
'insurance'=>'true',
|
| 160 |
+
'origin_address' =>
|
| 161 |
+
$origin_address,
|
| 162 |
+
'destination_address' =>
|
| 163 |
+
array(
|
| 164 |
+
'first_name' => $ship_addr['firstname'],
|
| 165 |
+
'last_name' => $ship_addr['lastname'],
|
| 166 |
+
'street1' => $ship_addr['street'],
|
| 167 |
+
'phone_number' => $ship_addr['telephone'],
|
| 168 |
+
'city' => $ship_addr['city'],
|
| 169 |
+
'state' => $ship_addr['region'],
|
| 170 |
+
'zip' => $ship_addr['postcode'],
|
| 171 |
+
'email' => $ship_addr['email']
|
| 172 |
+
),
|
| 173 |
+
'billing_address' =>
|
| 174 |
+
array(
|
| 175 |
+
'first_name' => $bill_addr['firstname'],
|
| 176 |
+
'last_name' => $bill_addr['lastname'],
|
| 177 |
+
'street1' => $bill_addr['street'],
|
| 178 |
+
'phone_number' => $bill_addr['telephone'],
|
| 179 |
+
'city' => $bill_addr['city'],
|
| 180 |
+
'state' => $bill_addr['region'], //'NY',
|
| 181 |
+
'zip' => $bill_addr['postcode'],
|
| 182 |
+
'email' => $bill_addr['email']
|
| 183 |
+
),
|
| 184 |
+
'pickup' =>
|
| 185 |
+
array(
|
| 186 |
+
array(
|
| 187 |
+
'start_time' => $next_bussines_day.'T04:00:00.645-07:00',
|
| 188 |
+
'end_time' => $next_bussines_day.'T20:00:00.645-07:00',
|
| 189 |
+
),
|
| 190 |
+
array(
|
| 191 |
+
'start_time' => $next_bussines_day.'T04:00:00.645-07:00',
|
| 192 |
+
'end_time' => $next_bussines_day.'T20:00:00.646-07:00',
|
| 193 |
+
)
|
| 194 |
+
),
|
| 195 |
+
|
| 196 |
+
'accessorials' => $itemsAccessories
|
| 197 |
+
|
| 198 |
+
);
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
$helper->shlog($items_array, 'shiphawk-book.log');
|
| 202 |
+
|
| 203 |
+
$items_array = json_encode($items_array);
|
| 204 |
+
|
| 205 |
+
curl_setopt($curl, CURLOPT_URL, $url_api);
|
| 206 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
| 207 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
|
| 208 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 209 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
| 210 |
+
'Content-Type: application/json',
|
| 211 |
+
'Content-Length: ' . strlen($items_array)
|
| 212 |
+
)
|
| 213 |
+
);
|
| 214 |
+
|
| 215 |
+
$resp = curl_exec($curl);
|
| 216 |
+
$arr_res = json_decode($resp);
|
| 217 |
+
|
| 218 |
+
//$helper->shlog($arr_res, 'shiphawk-book.log');
|
| 219 |
+
|
| 220 |
+
curl_close($curl);
|
| 221 |
+
|
| 222 |
+
return $arr_res;
|
| 223 |
+
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
protected function _getDefaultOriginData() {
|
| 227 |
+
$origin_address = array();
|
| 228 |
+
|
| 229 |
+
$origin_address['first_name'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_first_name');
|
| 230 |
+
$origin_address['last_name'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_last_name');
|
| 231 |
+
$origin_address['street1'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_address');
|
| 232 |
+
$origin_address['street2'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_address2');
|
| 233 |
+
$origin_address['state'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_state');
|
| 234 |
+
$origin_address['city'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_city');
|
| 235 |
+
$origin_address['zip'] = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
|
| 236 |
+
$origin_address['phone_number'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_phone');
|
| 237 |
+
$origin_address['email'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_email');
|
| 238 |
+
|
| 239 |
+
return $origin_address;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
protected function _getProductOriginData($products_id, $per_product = false) {
|
| 243 |
+
$origin_address_product = array();
|
| 244 |
+
|
| 245 |
+
try
|
| 246 |
+
{
|
| 247 |
+
// get first product item
|
| 248 |
+
$origin_product = Mage::getModel('catalog/product')->load($products_id);
|
| 249 |
+
|
| 250 |
+
$shipping_origin_id = $origin_product->getData('shiphawk_shipping_origins');
|
| 251 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
/* if product origin id == default (origin id == '') and product have all per product origin attribute
|
| 255 |
+
than get origin address from first product in origin group */
|
| 256 |
+
if($per_product == true) {
|
| 257 |
+
|
| 258 |
+
$origin_address_product['first_name'] = $origin_product->getData('shiphawk_origin_firstname');
|
| 259 |
+
$origin_address_product['last_name'] = $origin_product->getData('shiphawk_origin_lastname');
|
| 260 |
+
$origin_address_product['street1'] = $origin_product->getData('shiphawk_origin_addressline1');
|
| 261 |
+
$origin_address_product['street2'] = $origin_product->getData('shiphawk_origin_addressline2');
|
| 262 |
+
$origin_address_product['state'] = $origin_product->getData('shiphawk_origin_state');
|
| 263 |
+
$origin_address_product['city'] = $origin_product->getData('shiphawk_origin_city');
|
| 264 |
+
$origin_address_product['zip'] = $origin_product->getData('shiphawk_origin_zipcode');
|
| 265 |
+
$origin_address_product['phone_number'] = $origin_product->getData('shiphawk_origin_phonenum');
|
| 266 |
+
$origin_address_product['email'] = $origin_product->getData('shiphawk_origin_email');
|
| 267 |
+
}else{
|
| 268 |
+
if($shipping_origin_id) {
|
| 269 |
+
/* if product have origin id, then get origin address from origin model */
|
| 270 |
+
$shipping_origin = Mage::getModel('shiphawk_shipping/origins')->load($shipping_origin_id);
|
| 271 |
+
|
| 272 |
+
$origin_address_product['first_name'] = $shipping_origin->getData('shiphawk_origin_firstname');
|
| 273 |
+
$origin_address_product['last_name'] = $shipping_origin->getData('shiphawk_origin_lastname');
|
| 274 |
+
$origin_address_product['street1'] = $shipping_origin->getData('shiphawk_origin_addressline1');
|
| 275 |
+
$origin_address_product['street2'] = $shipping_origin->getData('shiphawk_origin_addressline2');
|
| 276 |
+
$origin_address_product['state'] = $shipping_origin->getData('shiphawk_origin_state');
|
| 277 |
+
$origin_address_product['city'] = $shipping_origin->getData('shiphawk_origin_city');
|
| 278 |
+
$origin_address_product['zip'] = $shipping_origin->getData('shiphawk_origin_zipcode');
|
| 279 |
+
$origin_address_product['phone_number'] = $shipping_origin->getData('shiphawk_origin_phonenum');
|
| 280 |
+
$origin_address_product['email'] = $shipping_origin->getData('shiphawk_origin_email');
|
| 281 |
+
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
}
|
| 286 |
+
catch(Exception $e)
|
| 287 |
+
{
|
| 288 |
+
Mage::log($e->getMessage());
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
return $origin_address_product;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
protected function getOriginAddress($origin_address_product, $default_origin_address) {
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
foreach($origin_address_product as $key=>$value) {
|
| 298 |
+
|
| 299 |
+
if($key != 'origin_address2') {
|
| 300 |
+
if(empty($value)) {
|
| 301 |
+
return $default_origin_address;
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
return $origin_address_product;
|
| 307 |
+
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* Auto booking. Save shipment in sales_order_place_after event, if manual booking set to No
|
| 313 |
+
* We can save only new shipment. Existing shipments are not editable
|
| 314 |
+
*
|
| 315 |
+
*
|
| 316 |
+
*/
|
| 317 |
+
public function saveshipment($orderId)
|
| 318 |
+
{
|
| 319 |
+
try {
|
| 320 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 321 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 322 |
+
|
| 323 |
+
$shiphawk_rate_data = unserialize($order->getData('shiphawk_book_id')); //rate id
|
| 324 |
+
|
| 325 |
+
foreach($shiphawk_rate_data as $rate_id=>$products_ids) {
|
| 326 |
+
$shipment = $this->_initShipHawkShipment($order,$products_ids);
|
| 327 |
+
|
| 328 |
+
$shipment->register();
|
| 329 |
+
|
| 330 |
+
$this->_saveShiphawkShipment($shipment, $products_ids['name'], $products_ids['price']);
|
| 331 |
+
|
| 332 |
+
$self_pack = $products_ids['self_pack'];
|
| 333 |
+
|
| 334 |
+
// add book, auto booking - true
|
| 335 |
+
$track_data = $this->toBook($order, $rate_id, $products_ids, array(), true, $self_pack);
|
| 336 |
+
|
| 337 |
+
$helper->shlog($track_data, 'shiphawk-book-response.log');
|
| 338 |
+
|
| 339 |
+
if (property_exists($track_data, 'error')) {
|
| 340 |
+
Mage::getSingleton('core/session')->addError("The booking was not successful, please try again later.");
|
| 341 |
+
//Mage::getSingleton('core/session')->addError($track_data->error);
|
| 342 |
+
$helper->shlog('ShipHawk response: '.$track_data->error);
|
| 343 |
+
return;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
// add track
|
| 347 |
+
if($track_number = $track_data->details->id) {
|
| 348 |
+
$this->addTrackNumber($shipment, $track_number);
|
| 349 |
+
// subscribe automaticaly after book
|
| 350 |
+
$this->subscribeToTrackingInfo($shipment->getId());
|
| 351 |
+
}
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
} catch (Mage_Core_Exception $e) {
|
| 355 |
+
|
| 356 |
+
Mage::logException($e);
|
| 357 |
+
|
| 358 |
+
} catch (Exception $e) {
|
| 359 |
+
Mage::logException($e);
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
/**
|
| 364 |
+
* Initialize shipment model instance
|
| 365 |
+
*
|
| 366 |
+
* @return Mage_Sales_Model_Order_Shipment|bool
|
| 367 |
+
*/
|
| 368 |
+
public function _initShipHawkShipment($order, $products_ids)
|
| 369 |
+
{
|
| 370 |
+
$shipment = false;
|
| 371 |
+
if(is_object($order)) {
|
| 372 |
+
|
| 373 |
+
$savedQtys = $this->_getItems($order, $products_ids);
|
| 374 |
+
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
return $shipment;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
public function _getItems($order, $products_ids) {
|
| 381 |
+
$qty = array();
|
| 382 |
+
if(is_object($order)) {
|
| 383 |
+
foreach($order->getAllItems() as $eachOrderItem){
|
| 384 |
+
|
| 385 |
+
if(in_array($eachOrderItem->getProductId(),$products_ids['product_ids'])) {
|
| 386 |
+
$Itemqty = 0;
|
| 387 |
+
$Itemqty = $eachOrderItem->getQtyOrdered()
|
| 388 |
+
- $eachOrderItem->getQtyShipped()
|
| 389 |
+
- $eachOrderItem->getQtyRefunded()
|
| 390 |
+
- $eachOrderItem->getQtyCanceled();
|
| 391 |
+
$qty[$eachOrderItem->getId()] = $Itemqty;
|
| 392 |
+
}else{
|
| 393 |
+
$qty[$eachOrderItem->getId()] = 0;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
}
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
return $qty;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
* Save shipment and order in one transaction
|
| 404 |
+
*
|
| 405 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
| 406 |
+
* @return Mage_Adminhtml_Sales_Order_ShipmentController
|
| 407 |
+
*/
|
| 408 |
+
public function _saveShiphawkShipment($shipment, $shiphawk_shipment_title = null, $shiphawk_shipment_price = null)
|
| 409 |
+
{
|
| 410 |
+
$shipment->getOrder()->setIsInProcess(true);
|
| 411 |
+
$shipment->setShiphawkShippingMethodTitle($shiphawk_shipment_title);
|
| 412 |
+
$shipment->setShiphawkShippingPrice($shiphawk_shipment_price);
|
| 413 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
| 414 |
+
->addObject($shipment)
|
| 415 |
+
->addObject($shipment->getOrder())
|
| 416 |
+
->save();
|
| 417 |
+
|
| 418 |
+
return $this;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
/**
|
| 422 |
+
* Add new tracking number action
|
| 423 |
+
*/
|
| 424 |
+
public function addTrackNumber($shipment, $number)
|
| 425 |
+
{
|
| 426 |
+
try {
|
| 427 |
+
$carrier = 'shiphawk_shipping';
|
| 428 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 429 |
+
$title = 'ShipHawk Shipping';
|
| 430 |
+
if (empty($carrier)) {
|
| 431 |
+
Mage::throwException($this->__('The carrier needs to be specified.'));
|
| 432 |
+
}
|
| 433 |
+
if (empty($number)) {
|
| 434 |
+
Mage::throwException($this->__('Tracking number cannot be empty.'));
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
if ($shipment) {
|
| 438 |
+
$track = Mage::getModel('sales/order_shipment_track')
|
| 439 |
+
->setNumber($number)
|
| 440 |
+
->setCarrierCode($carrier)
|
| 441 |
+
->setTitle($title);
|
| 442 |
+
$shipment->addTrack($track)
|
| 443 |
+
->save();
|
| 444 |
+
|
| 445 |
+
} else {
|
| 446 |
+
$helper->shlog('Cannot initialize shipment for adding tracking number.', 'shiphawk-tracking.log');
|
| 447 |
+
}
|
| 448 |
+
} catch (Mage_Core_Exception $e) {
|
| 449 |
+
Mage::log($e->getMessage());
|
| 450 |
+
} catch (Exception $e) {
|
| 451 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 452 |
+
$helper->shlog('Cannot add tracking number.', 'shiphawk-tracking.log');
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
public function subscribeToTrackingInfo($shipment_id) {
|
| 458 |
+
|
| 459 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 460 |
+
$api_key = $helper->getApiKey();
|
| 461 |
+
|
| 462 |
+
if($shipment_id) {
|
| 463 |
+
try{
|
| 464 |
+
$shipment = Mage::getModel('sales/order_shipment')->load($shipment_id);
|
| 465 |
+
|
| 466 |
+
$shipment_id_track = $this->_getTrackNumber($shipment);
|
| 467 |
+
|
| 468 |
+
//PUT /api/v3/shipments/{id}/tracking
|
| 469 |
+
$subscribe_url = $helper->getApiUrl() . 'shipments/' . $shipment_id_track . '/tracking?api_key=' . $api_key;
|
| 470 |
+
$callback_url = $helper->getCallbackUrl($api_key);
|
| 471 |
+
|
| 472 |
+
$items_array = array(
|
| 473 |
+
'callback_url'=> $callback_url
|
| 474 |
+
);
|
| 475 |
+
|
| 476 |
+
$curl = curl_init();
|
| 477 |
+
$items_array = json_encode($items_array);
|
| 478 |
+
|
| 479 |
+
curl_setopt($curl, CURLOPT_URL, $subscribe_url);
|
| 480 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
| 481 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
|
| 482 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 483 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
| 484 |
+
'Content-Type: application/json',
|
| 485 |
+
'Content-Length: ' . strlen($items_array)
|
| 486 |
+
)
|
| 487 |
+
);
|
| 488 |
+
|
| 489 |
+
$resp = curl_exec($curl);
|
| 490 |
+
$arr_res = json_decode($resp);
|
| 491 |
+
|
| 492 |
+
$helper->shlog($arr_res, 'shiphawk-tracking.log');
|
| 493 |
+
|
| 494 |
+
if (!empty($arr_res)) {
|
| 495 |
+
$comment = '';
|
| 496 |
+
$event_list = '';
|
| 497 |
+
|
| 498 |
+
if (count($arr_res->events)) {
|
| 499 |
+
|
| 500 |
+
foreach ($arr_res->events as $event) {
|
| 501 |
+
$event_list .= $event . '<br>';
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
try {
|
| 506 |
+
|
| 507 |
+
$crated_time = $this->convertDateTome($arr_res->created_at);
|
| 508 |
+
|
| 509 |
+
$comment = $arr_res->resource_name . ': ' . $arr_res->id . '<br>' . 'Created: ' . $crated_time['date'] . ' at ' . $crated_time['time'] . '<br>' . $event_list;
|
| 510 |
+
$shipment->addComment($comment);
|
| 511 |
+
$shipment->sendEmail(true,$comment);
|
| 512 |
+
|
| 513 |
+
}catch (Mage_Core_Exception $e) {
|
| 514 |
+
Mage::logException($e);
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
$shipment->save();
|
| 520 |
+
|
| 521 |
+
curl_close($curl);
|
| 522 |
+
|
| 523 |
+
}catch (Mage_Core_Exception $e) {
|
| 524 |
+
$this->_getSession()->addError($e->getMessage());
|
| 525 |
+
Mage::logException($e);
|
| 526 |
+
|
| 527 |
+
} catch (Exception $e) {
|
| 528 |
+
Mage::logException($e);
|
| 529 |
+
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
}else{
|
| 533 |
+
|
| 534 |
+
Mage::logException($this->__('No ShipHawk tracking number'));
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
public function convertDateTome ($date_time) {
|
| 540 |
+
$result = array();
|
| 541 |
+
$t = explode('T', $date_time);
|
| 542 |
+
$result['date'] = date("m/d/y", strtotime($t[0]));
|
| 543 |
+
|
| 544 |
+
$result['time'] = date("g:i a", strtotime(substr($t[1], 0, -1)));
|
| 545 |
+
|
| 546 |
+
return $result;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
protected function _getTrackNumber($shipment) {
|
| 550 |
+
|
| 551 |
+
foreach($shipment->getAllTracks() as $tracknum)
|
| 552 |
+
{
|
| 553 |
+
//ShipHawk track number only one
|
| 554 |
+
if($tracknum->getCarrierCode() == 'shiphawk_shipping') {
|
| 555 |
+
return $tracknum->getNumber();
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
return null;
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
public function getShipmentStatus($shipment_id_track) {
|
| 562 |
+
|
| 563 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 564 |
+
$api_key = $helper->getApiKey();
|
| 565 |
+
|
| 566 |
+
$subscribe_url = $helper->getApiUrl() . 'shipments/' . $shipment_id_track . '/tracking?api_key=' . $api_key;
|
| 567 |
+
|
| 568 |
+
$curl = curl_init();
|
| 569 |
+
|
| 570 |
+
curl_setopt($curl, CURLOPT_URL, $subscribe_url);
|
| 571 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
|
| 572 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
| 573 |
+
|
| 574 |
+
$resp = curl_exec($curl);
|
| 575 |
+
$arr_res = json_decode($resp);
|
| 576 |
+
|
| 577 |
+
return $arr_res;
|
| 578 |
+
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
/**
|
| 582 |
+
* For book shipping with accessories
|
| 583 |
+
*
|
| 584 |
+
* @param $accessories
|
| 585 |
+
* @param $orderAccessories
|
| 586 |
+
* @return array
|
| 587 |
+
*
|
| 588 |
+
* @version 20150624, WhideGroup
|
| 589 |
+
*/
|
| 590 |
+
public function getAccessoriesForBook($accessories, $orderAccessories) {
|
| 591 |
+
|
| 592 |
+
if (empty($accessories) || empty($orderAccessories)) {
|
| 593 |
+
return array();
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 597 |
+
|
| 598 |
+
$orderAccessories = json_decode($orderAccessories, true);
|
| 599 |
+
$itemsAccessories = array();
|
| 600 |
+
|
| 601 |
+
foreach ($accessories as $accessoriesType => $accessor) {
|
| 602 |
+
foreach($accessor as $accessorRow) {
|
| 603 |
+
foreach($orderAccessories as $orderAccessoriesType => $orderAccessor) {
|
| 604 |
+
foreach($orderAccessor as $orderAccessorValues) {
|
| 605 |
+
$orderAccessorValuesName = str_replace("'", '', $orderAccessorValues['name']);
|
| 606 |
+
$orderAccessorValuesName = trim($orderAccessorValuesName);
|
| 607 |
+
|
| 608 |
+
$accessorName = (string)$accessorRow->accessorial_type . ' (' . (string)$accessorRow->accessorial_options . ')';
|
| 609 |
+
$accessorName = trim($accessorName);
|
| 610 |
+
|
| 611 |
+
if (str_replace("'", '', $orderAccessoriesType) == $accessoriesType && $accessorName == $orderAccessorValuesName) {
|
| 612 |
+
$itemsAccessories[] = array('id' => $accessorRow->id);
|
| 613 |
+
}
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
}
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
if (empty($itemsAccessories)) {
|
| 620 |
+
|
| 621 |
+
$helper->shlog('Empty accessories!', 'shiphawk-book.log');
|
| 622 |
+
|
| 623 |
+
$helper->shlog($accessories, 'shiphawk-book.log');
|
| 624 |
+
|
| 625 |
+
$helper->shlog($orderAccessories, 'shiphawk-book.log');
|
| 626 |
+
} else {
|
| 627 |
+
|
| 628 |
+
$helper->shlog('Accessories!', 'shiphawk-book.log');
|
| 629 |
+
|
| 630 |
+
$helper->shlog($itemsAccessories, 'shiphawk-book.log');
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
return $itemsAccessories;
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Carrier.php
ADDED
|
@@ -0,0 +1,996 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Shiphawk_Shipping_Model_Carrier
|
| 4 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
| 5 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Carrier's code, as defined in parent class
|
| 9 |
+
*
|
| 10 |
+
* @var string
|
| 11 |
+
*/
|
| 12 |
+
protected $_code = 'shiphawk_shipping';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Returns available shipping rates for Shiphawk Shipping carrier
|
| 16 |
+
*
|
| 17 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
| 18 |
+
* @return Mage_Shipping_Model_Rate_Result
|
| 19 |
+
*/
|
| 20 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
| 21 |
+
{
|
| 22 |
+
/** @var Mage_Shipping_Model_Rate_Result $result */
|
| 23 |
+
|
| 24 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 25 |
+
$api = Mage::getModel('shiphawk_shipping/api');
|
| 26 |
+
|
| 27 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 28 |
+
|
| 29 |
+
$default_origin_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
|
| 30 |
+
$hide_on_frontend = Mage::getStoreConfig('carriers/shiphawk_shipping/hide_on_frontend');
|
| 31 |
+
$custom_packing_price_setting = Mage::getStoreConfig('carriers/shiphawk_shipping/shiphawk_custom_packing_price');
|
| 32 |
+
$charge_customer_for_packing = Mage::getStoreConfig('carriers/shiphawk_shipping/charge_customer_for_packing');
|
| 33 |
+
$from_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin'); //default origin zip code from config settings
|
| 34 |
+
$free_shipping_setting = Mage::getStoreConfig('carriers/shiphawk_shipping/free_method');
|
| 35 |
+
|
| 36 |
+
/*Check to see if Shiphawk rates should be displayed on frontend*/
|
| 37 |
+
// hide ShipHawk method on frontend , allow only in admin area
|
| 38 |
+
$is_admin = $helper->checkIsAdmin();
|
| 39 |
+
if (($hide_on_frontend == 1) && (!$is_admin)) {
|
| 40 |
+
return $result;
|
| 41 |
+
}
|
| 42 |
+
/*END*/
|
| 43 |
+
|
| 44 |
+
/* Parameters */
|
| 45 |
+
$to_zip = $this->getShippingZip();
|
| 46 |
+
$items = $this->getShiphawkItems($request);
|
| 47 |
+
|
| 48 |
+
$shLocationType = 'residential'; //default value
|
| 49 |
+
$toOrder= array();
|
| 50 |
+
$api_error = false;
|
| 51 |
+
$is_multi_zip = false;
|
| 52 |
+
$is_multi_carrier = false;
|
| 53 |
+
$api_calls_params = array();
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
$rate_filter = $helper->getRateFilter($is_admin);
|
| 57 |
+
$self_pack = $helper->getSelfPacked();
|
| 58 |
+
|
| 59 |
+
$grouped_items_by_zip = $this->getGroupedItemsByZip($items);
|
| 60 |
+
$grouped_items_by_carrier_type = $this->getGroupedItemsByCarrierType($items);
|
| 61 |
+
/*END*/
|
| 62 |
+
|
| 63 |
+
/* For location type */
|
| 64 |
+
if ($is_admin) {
|
| 65 |
+
// if is admin this means that we have already set the value in setlocationtypeAction
|
| 66 |
+
$shLocationType = Mage::getSingleton('checkout/session')->getData('shiphawk_location_type_shipping');
|
| 67 |
+
} else {
|
| 68 |
+
$shippingRequest = Mage::app()->getRequest()->getPost();
|
| 69 |
+
|
| 70 |
+
if (!empty($shippingRequest['billing'])) {
|
| 71 |
+
$shLocationType = $shippingRequest['billing']['shiphawk_location_type'];
|
| 72 |
+
$shLocationType = $shLocationType != 'commercial' && $shLocationType != 'residential' ? 'residential' : $shLocationType;
|
| 73 |
+
Mage::getSingleton('checkout/session')->setData('shiphawk_location_type_billing', $shLocationType);
|
| 74 |
+
|
| 75 |
+
if ($shippingRequest['billing']['use_for_shipping']) {
|
| 76 |
+
Mage::getSingleton('checkout/session')->setData('shiphawk_location_type_shipping', $shLocationType);
|
| 77 |
+
}
|
| 78 |
+
} else if (!empty($shippingRequest['shipping'])) {
|
| 79 |
+
$shLocationType = $shippingRequest['shipping']['shiphawk_location_type'];
|
| 80 |
+
$shLocationType = $shLocationType != 'commercial' && $shLocationType != 'residential' ? 'residential' : $shLocationType;
|
| 81 |
+
Mage::getSingleton('checkout/session')->setData('shiphawk_location_type_shipping', $shLocationType);
|
| 82 |
+
} else {
|
| 83 |
+
$shLocationType = Mage::getSingleton('checkout/session')->getData('shiphawk_location_type_shipping');
|
| 84 |
+
$shLocationType = $shLocationType != 'commercial' && $shLocationType != 'residential' ? 'residential' : $shLocationType;
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
/*END*/
|
| 88 |
+
|
| 89 |
+
if(count($grouped_items_by_zip) > 1) {
|
| 90 |
+
//multi-zip
|
| 91 |
+
$is_multi_zip = true;
|
| 92 |
+
$rate_filter = 'best';
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
if(count($grouped_items_by_carrier_type) > 1) {
|
| 96 |
+
//multi-carrier
|
| 97 |
+
$is_multi_carrier = true;
|
| 98 |
+
$is_multi_zip = true;
|
| 99 |
+
$rate_filter = 'best';
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
//building api calls
|
| 103 |
+
try {
|
| 104 |
+
/* items has various carrier type */
|
| 105 |
+
if($is_multi_carrier) {
|
| 106 |
+
foreach($grouped_items_by_carrier_type as $carrier_type=>$items_) {
|
| 107 |
+
|
| 108 |
+
if($carrier_type) {
|
| 109 |
+
$carrier_type = explode(',', $carrier_type);
|
| 110 |
+
}else{
|
| 111 |
+
$carrier_type = '';
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
$grouped_items_by_origin = $this->getGroupedItemsByZip($items_);
|
| 116 |
+
foreach($grouped_items_by_origin as $origin_id=>$items__) {
|
| 117 |
+
|
| 118 |
+
if($origin_id != 'origin_per_product') { // product has origin id or primary origin
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
if($origin_id) {
|
| 122 |
+
$shipHawkOrigin = Mage::getModel('shiphawk_shipping/origins')->load($origin_id);
|
| 123 |
+
$from_zip = $shipHawkOrigin->getShiphawkOriginZipcode();
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items__, $rate_filter);
|
| 127 |
+
|
| 128 |
+
if(empty($checkattributes)) {
|
| 129 |
+
|
| 130 |
+
$grouped_items_by_discount_or_markup = $this->getGroupedItemsByDiscountOrMarkup($items__);
|
| 131 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 132 |
+
|
| 133 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 134 |
+
|
| 135 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 136 |
+
$from_zip = $items__[0]['zip'];
|
| 137 |
+
$location_type = $items__[0]['location_type'];
|
| 138 |
+
$custom_products_packing_price = 0;
|
| 139 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 140 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 141 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 142 |
+
|
| 143 |
+
if($custom_packing_price_setting) {
|
| 144 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
// 1. multi carrier, multi origin, not origin per product
|
| 148 |
+
Mage::Log('getting rates the paramters: 1,1,1');
|
| 149 |
+
|
| 150 |
+
$tempArray = array(
|
| 151 |
+
'api_call' => $api->buildShiphawkRequest($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType),
|
| 152 |
+
'discount_items' => $discount_items,
|
| 153 |
+
'self_pack' => $self_pack,
|
| 154 |
+
'charge_customer_for_packing' => $charge_customer_for_packing,
|
| 155 |
+
'from_zip' => $from_zip,
|
| 156 |
+
'to_zip' => $to_zip,
|
| 157 |
+
'carrier_type' => $carrier_type,
|
| 158 |
+
'self_pack' => $self_pack,
|
| 159 |
+
'custom_products_packing_price' => $custom_products_packing_price,
|
| 160 |
+
'flat_markup_discount' => $flat_markup_discount,
|
| 161 |
+
'percentage_markup_discount' => $percentage_markup_discount,
|
| 162 |
+
'custom_products_packing_price' => $custom_products_packing_price
|
| 163 |
+
);
|
| 164 |
+
$api_calls_params[] = $tempArray;
|
| 165 |
+
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
}else{
|
| 169 |
+
$api_error = true;
|
| 170 |
+
foreach($checkattributes as $rate_error) {
|
| 171 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 172 |
+
$helper->sendErrorMessageToShipHawk($rate_error);
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
else{ // product items has all required shipping origin fields
|
| 177 |
+
|
| 178 |
+
$grouped_items_per_product_by_zip = $this->getGroupedItemsByZipPerProduct($items__);
|
| 179 |
+
foreach ($grouped_items_per_product_by_zip as $from_zip=>$items_per_product) {
|
| 180 |
+
|
| 181 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_per_product, $rate_filter);
|
| 182 |
+
|
| 183 |
+
if(empty($checkattributes)) {
|
| 184 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 185 |
+
$from_zip = $items_[0]['zip'];
|
| 186 |
+
$location_type = $items_[0]['location_type'];
|
| 187 |
+
|
| 188 |
+
$grouped_items_by_discount_or_markup = $this->getGroupedItemsByDiscountOrMarkup($items_per_product);
|
| 189 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 190 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 191 |
+
|
| 192 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 193 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 194 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 195 |
+
$custom_products_packing_price = 0;
|
| 196 |
+
|
| 197 |
+
if($custom_packing_price_setting) {
|
| 198 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// 2. multi carrier, multi origin, origin per product
|
| 202 |
+
Mage::Log('getting rates the paramters: 1,1,2');
|
| 203 |
+
|
| 204 |
+
$tempArray = array(
|
| 205 |
+
'api_call' => $api->buildShiphawkRequest($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType),
|
| 206 |
+
'discount_items' => $discount_items,
|
| 207 |
+
'self_pack' => $self_pack,
|
| 208 |
+
'charge_customer_for_packing' => $charge_customer_for_packing,
|
| 209 |
+
'from_zip' => $from_zip,
|
| 210 |
+
'to_zip' => $to_zip,
|
| 211 |
+
'carrier_type' => $carrier_type,
|
| 212 |
+
'self_pack' => $self_pack,
|
| 213 |
+
'custom_products_packing_price' => $custom_products_packing_price,
|
| 214 |
+
'flat_markup_discount' => $flat_markup_discount,
|
| 215 |
+
'percentage_markup_discount' => $percentage_markup_discount,
|
| 216 |
+
'custom_products_packing_price' => $custom_products_packing_price
|
| 217 |
+
);
|
| 218 |
+
$api_calls_params[] = $tempArray;
|
| 219 |
+
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
}else{
|
| 223 |
+
$api_error = true;
|
| 224 |
+
foreach($checkattributes as $rate_error) {
|
| 225 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 226 |
+
$helper->sendErrorMessageToShipHawk($rate_error);
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
}else{
|
| 237 |
+
|
| 238 |
+
/* all product items has one carrier type or carrier type is null in all items */
|
| 239 |
+
foreach($grouped_items_by_zip as $origin_id=>$items_) {
|
| 240 |
+
|
| 241 |
+
/* get carrier type from first item because items grouped by carrier type and not multi carrier */
|
| 242 |
+
/* if carrier type is null, get default carrier type from settings */
|
| 243 |
+
if($items_[0]['shiphawk_carrier_type']) {
|
| 244 |
+
$carrier_type = (explode(',', $items_[0]['shiphawk_carrier_type'])) ? (explode(',', $items_[0]['shiphawk_carrier_type'])) : Mage::getStoreConfig('carriers/shiphawk_shipping/carrier_type');
|
| 245 |
+
}else{
|
| 246 |
+
$carrier_type = '';
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
if ($origin_id != 'origin_per_product') {
|
| 250 |
+
|
| 251 |
+
if($origin_id) {
|
| 252 |
+
$shipHawkOrigin = Mage::getModel('shiphawk_shipping/origins')->load($origin_id);
|
| 253 |
+
$from_zip = $shipHawkOrigin->getShiphawkOriginZipcode();
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_, $rate_filter);
|
| 257 |
+
|
| 258 |
+
if(empty($checkattributes)) {
|
| 259 |
+
|
| 260 |
+
$grouped_items_by_discount_or_markup = $this->getGroupedItemsByDiscountOrMarkup($items_);
|
| 261 |
+
|
| 262 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 263 |
+
|
| 264 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 265 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 266 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 267 |
+
|
| 268 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 269 |
+
$from_zip = $discount_items[0]['zip'];
|
| 270 |
+
$location_type = $discount_items[0]['location_type'];
|
| 271 |
+
$custom_products_packing_price = 0;
|
| 272 |
+
|
| 273 |
+
if($custom_packing_price_setting) {
|
| 274 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
// 3. one carrier, multi origin, not origin per product
|
| 278 |
+
Mage::Log('getting rates the paramters: 2,1,1');
|
| 279 |
+
|
| 280 |
+
$tempArray = array(
|
| 281 |
+
'api_call' => $api->buildShiphawkRequest($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType),
|
| 282 |
+
'discount_items' => $discount_items,
|
| 283 |
+
'self_pack' => $self_pack,
|
| 284 |
+
'charge_customer_for_packing' => $charge_customer_for_packing,
|
| 285 |
+
'from_zip' => $from_zip,
|
| 286 |
+
'to_zip' => $to_zip,
|
| 287 |
+
'carrier_type' => $carrier_type,
|
| 288 |
+
'self_pack' => $self_pack,
|
| 289 |
+
'custom_products_packing_price' => $custom_products_packing_price,
|
| 290 |
+
'flat_markup_discount' => $flat_markup_discount,
|
| 291 |
+
'percentage_markup_discount' => $percentage_markup_discount,
|
| 292 |
+
'custom_products_packing_price' => $custom_products_packing_price
|
| 293 |
+
);
|
| 294 |
+
$api_calls_params[]= $tempArray;
|
| 295 |
+
|
| 296 |
+
}
|
| 297 |
+
}else{
|
| 298 |
+
$api_error = true;
|
| 299 |
+
foreach($checkattributes as $rate_error) {
|
| 300 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 301 |
+
$helper->sendErrorMessageToShipHawk($rate_error);
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
else{
|
| 306 |
+
|
| 307 |
+
/* product items has per product origin, grouped by zip code */
|
| 308 |
+
$grouped_items_per_product_by_zip = $this->getGroupedItemsByZipPerProduct($items_);
|
| 309 |
+
foreach ($grouped_items_per_product_by_zip as $from_zip=>$items_per_product) {
|
| 310 |
+
|
| 311 |
+
$checkattributes = $helper->checkShipHawkAttributes($from_zip, $to_zip, $items_per_product, $rate_filter);
|
| 312 |
+
|
| 313 |
+
if(empty($checkattributes)) {
|
| 314 |
+
|
| 315 |
+
$grouped_items_by_discount_or_markup = $this->getGroupedItemsByDiscountOrMarkup($items_per_product);
|
| 316 |
+
foreach($grouped_items_by_discount_or_markup as $mark_up_discount=>$discount_items) {
|
| 317 |
+
$helper->shlog($discount_items, 'shiphawk-items-request.log');
|
| 318 |
+
|
| 319 |
+
//get percentage and flat markup-discount from first item, because all item in group has identical markup-discount
|
| 320 |
+
$flat_markup_discount = $discount_items[0]['shiphawk_discount_fixed'];
|
| 321 |
+
$percentage_markup_discount = $discount_items[0]['shiphawk_discount_percentage'];
|
| 322 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 323 |
+
$from_zip = $discount_items[0]['zip'];
|
| 324 |
+
$location_type = $discount_items[0]['location_type'];
|
| 325 |
+
$custom_products_packing_price = 0;
|
| 326 |
+
|
| 327 |
+
if($custom_packing_price_setting) {
|
| 328 |
+
$custom_products_packing_price = $helper->getCustomPackingPriceSumm($discount_items);
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// 4. one carrier, multi origin, origin per product
|
| 332 |
+
Mage::Log('getting rates the paramters: 2,1,2');
|
| 333 |
+
|
| 334 |
+
$tempArray = array(
|
| 335 |
+
'api_call' => $api->buildShiphawkRequest($from_zip, $to_zip, $discount_items, $rate_filter, $carrier_type, $location_type, $shLocationType),
|
| 336 |
+
'discount_items' => $discount_items,
|
| 337 |
+
'self_pack' => $self_pack,
|
| 338 |
+
'charge_customer_for_packing' => $charge_customer_for_packing,
|
| 339 |
+
'from_zip' => $from_zip,
|
| 340 |
+
'to_zip' => $to_zip,
|
| 341 |
+
'carrier_type' => $carrier_type,
|
| 342 |
+
'self_pack' => $self_pack,
|
| 343 |
+
'custom_products_packing_price' => $custom_products_packing_price,
|
| 344 |
+
'flat_markup_discount' => $flat_markup_discount,
|
| 345 |
+
'percentage_markup_discount' => $percentage_markup_discount,
|
| 346 |
+
'custom_products_packing_price' => $custom_products_packing_price
|
| 347 |
+
);
|
| 348 |
+
$api_calls_params[] = $tempArray;
|
| 349 |
+
|
| 350 |
+
}
|
| 351 |
+
}
|
| 352 |
+
else{
|
| 353 |
+
$api_error = true;
|
| 354 |
+
foreach($checkattributes as $rate_error) {
|
| 355 |
+
$helper->shlog('ShipHawk error: '.$rate_error);
|
| 356 |
+
$helper->sendErrorMessageToShipHawk($rate_error);
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
//exectue all API calls - multi curl
|
| 367 |
+
$mh = curl_multi_init();
|
| 368 |
+
foreach ($api_calls_params as $api_data){
|
| 369 |
+
curl_multi_add_handle($mh, $api_data['api_call']);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
$active = null;
|
| 373 |
+
do {
|
| 374 |
+
$mrc = curl_multi_exec($mh, $active);
|
| 375 |
+
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
|
| 376 |
+
|
| 377 |
+
while ($active && $mrc == CURLM_OK){
|
| 378 |
+
if (curl_multi_select($mh) == -1){
|
| 379 |
+
continue;
|
| 380 |
+
}
|
| 381 |
+
do{
|
| 382 |
+
$mrc = curl_multi_exec($mh, $active);
|
| 383 |
+
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
foreach ($api_calls_params as $api_data){
|
| 387 |
+
curl_multi_remove_handle($mh, $api_data['api_call']);
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
curl_multi_close($mh);
|
| 391 |
+
$api_responses = array();
|
| 392 |
+
foreach ($api_calls_params as $api_data){
|
| 393 |
+
$api_responses[] = json_decode(curl_multi_getcontent($api_data['api_call']));
|
| 394 |
+
}
|
| 395 |
+
//end multi curl
|
| 396 |
+
|
| 397 |
+
//proccess responses into old data objects
|
| 398 |
+
for($i = 0; $i < count($api_responses); $i++) {
|
| 399 |
+
|
| 400 |
+
if(is_object($api_responses[$i])) {
|
| 401 |
+
$api_error = true;
|
| 402 |
+
$shiphawk_error = (string) $api_responses[$i]->error;
|
| 403 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 404 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 405 |
+
}else{
|
| 406 |
+
// if $rate_filter = 'best' then it is only one rate
|
| 407 |
+
if($rate_filter == 'best') {
|
| 408 |
+
|
| 409 |
+
$toOrder[$api_responses[$i][0]->id]['product_ids'] = $this->getProductIds($api_calls_params[$i]['discount_items']);
|
| 410 |
+
//$toOrder[$responceObject[0]->id]['price'] = $helper->getSummaryPrice($responceObject[0], $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 411 |
+
$toOrder[$api_responses[$i][0]->id]['price'] = $helper->getShipHawkPrice($api_responses[$i][0], $self_pack, $charge_customer_for_packing);
|
| 412 |
+
$toOrder[$api_responses[$i][0]->id]['name'] = $api_responses[$i][0]->shipping->service;//
|
| 413 |
+
$toOrder[$api_responses[$i][0]->id]['items'] = $api_calls_params[$i]['discount_items'];
|
| 414 |
+
$toOrder[$api_responses[$i][0]->id]['from_zip'] = $api_calls_params[$i]['from_zip'];
|
| 415 |
+
$toOrder[$api_responses[$i][0]->id]['to_zip'] = $api_calls_params[$i]['to_zip'];
|
| 416 |
+
$toOrder[$api_responses[$i][0]->id]['carrier'] = $this->getCarrierName($api_responses[$i][0]);
|
| 417 |
+
$toOrder[$api_responses[$i][0]->id]['packing_info'] = $this->getPackeges($api_responses[$i][0]);
|
| 418 |
+
$toOrder[$api_responses[$i][0]->id]['carrier_type'] = $api_calls_params[$i]['carrier_type'];
|
| 419 |
+
$toOrder[$api_responses[$i][0]->id]['shiphawk_discount_fixed'] = $api_calls_params[$i]['flat_markup_discount'];
|
| 420 |
+
$toOrder[$api_responses[$i][0]->id]['shiphawk_discount_percentage'] = $api_calls_params[$i]['percentage_markup_discount'];
|
| 421 |
+
$toOrder[$api_responses[$i][0]->id]['self_pack'] = $api_calls_params[$i]['self_pack'];
|
| 422 |
+
$toOrder[$api_responses[$i][0]->id]['custom_products_packing_price'] = $api_calls_params[$i]['custom_products_packing_price'];
|
| 423 |
+
}else{
|
| 424 |
+
Mage::getSingleton('core/session')->setMultiZipCode(false);
|
| 425 |
+
foreach ($api_responses[$i] as $responseItem) {
|
| 426 |
+
|
| 427 |
+
$toOrder[$responseItem->id]['product_ids'] = $this->getProductIds($api_calls_params[$i]['discount_items']);
|
| 428 |
+
//$toOrder[$responce->id]['price'] = $helper->getSummaryPrice($responce, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 429 |
+
$toOrder[$responseItem->id]['price'] = $helper->getShipHawkPrice($responseItem, $self_pack, $charge_customer_for_packing);
|
| 430 |
+
$toOrder[$responseItem->id]['name'] = $responseItem->shipping->service;//
|
| 431 |
+
$toOrder[$responseItem->id]['items'] = $api_calls_params[$i]['discount_items'];
|
| 432 |
+
$toOrder[$responseItem->id]['from_zip'] = $api_calls_params[$i]['from_zip'];
|
| 433 |
+
$toOrder[$responseItem->id]['to_zip'] = $api_calls_params[$i]['to_zip'];
|
| 434 |
+
$toOrder[$responseItem->id]['carrier'] = $this->getCarrierName($responseItem);
|
| 435 |
+
$toOrder[$responseItem->id]['packing_info'] = $this->getPackeges($responseItem);
|
| 436 |
+
$toOrder[$responseItem->id]['carrier_type'] = $api_calls_params[$i]['carrier_type'];
|
| 437 |
+
$toOrder[$responseItem->id]['shiphawk_discount_fixed'] = $api_calls_params[$i]['flat_markup_discount'];
|
| 438 |
+
$toOrder[$responseItem->id]['shiphawk_discount_percentage'] = $api_calls_params[$i]['percentage_markup_discount'];
|
| 439 |
+
$toOrder[$responseItem->id]['self_pack'] = $api_calls_params[$i]['self_pack'];
|
| 440 |
+
$toOrder[$responseItem->id]['custom_products_packing_price'] = $api_calls_params[$i]['custom_products_packing_price'];
|
| 441 |
+
}
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
if($is_multi_zip) {
|
| 445 |
+
Mage::getSingleton('core/session')->setMultiZipCode(true);
|
| 446 |
+
}
|
| 447 |
+
}
|
| 448 |
+
}
|
| 449 |
+
//end process responses into old data objects
|
| 450 |
+
|
| 451 |
+
if(!$api_error) {
|
| 452 |
+
$services = $this->getServices($api_responses, $toOrder, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting);
|
| 453 |
+
$name_service = '';
|
| 454 |
+
$summ_price = 0;
|
| 455 |
+
$package_info = '';
|
| 456 |
+
$multi_shipping_price = 0;
|
| 457 |
+
|
| 458 |
+
$chipiest_rate_id = $this->_getChipiestRateId($services);
|
| 459 |
+
|
| 460 |
+
foreach ($services as $id_service=>$service) {
|
| 461 |
+
if (!$is_multi_zip) {
|
| 462 |
+
//add ShipHawk shipping
|
| 463 |
+
//$shipping_price = $helper->getTotalDiscountShippingPrice($service['price'], $toOrder[$id_service]);
|
| 464 |
+
$shipping_price = $service['price'];
|
| 465 |
+
if((empty($service['shiphawk_discount_fixed']))&&(empty($service['shiphawk_discount_percentage']))) {
|
| 466 |
+
$shipping_price = $helper->getDiscountShippingPrice($service['price']);
|
| 467 |
+
}else{
|
| 468 |
+
$shipping_price = $helper->getProductDiscountMarkupPrice($service['price'], $service['shiphawk_discount_percentage'], $service['shiphawk_discount_fixed']);
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
if($free_shipping_setting != 'none') {
|
| 472 |
+
if ($request->getFreeShipping()) {
|
| 473 |
+
|
| 474 |
+
// get chipiest rate id
|
| 475 |
+
if($chipiest_rate_id == $id_service){
|
| 476 |
+
$shipping_price = 0;
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
if ($free_shipping_setting == 'all') {
|
| 480 |
+
$shipping_price = 0;
|
| 481 |
+
}
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
if($is_admin == false) {
|
| 486 |
+
$result->append($this->_getShiphawkRateObject($service['name'], $shipping_price, $service['shiphawk_price'], $service['accessorial']));
|
| 487 |
+
}else{
|
| 488 |
+
$result->append($this->_getShiphawkRateObject($service['name'] . ' - ' . $service['carrier'], $shipping_price, $service['shiphawk_price'], $service['accessorial']));
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
}else{
|
| 492 |
+
$name_service .= $service['name'] . ', ';
|
| 493 |
+
$summ_price += $service['price'];
|
| 494 |
+
|
| 495 |
+
$shipping_price = $service['price'];
|
| 496 |
+
if((empty($service['shiphawk_discount_fixed']))&&(empty($service['shiphawk_discount_percentage']))) {
|
| 497 |
+
$shipping_price = $helper->getDiscountShippingPrice($service['price']);
|
| 498 |
+
}else{
|
| 499 |
+
$shipping_price = $helper->getProductDiscountMarkupPrice($service['price'], $service['shiphawk_discount_percentage'], $service['shiphawk_discount_fixed']);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
$multi_shipping_price += $shipping_price;
|
| 503 |
+
if ($request->getFreeShipping()) {
|
| 504 |
+
/**
|
| 505 |
+
* If the request has the free shipping flag,
|
| 506 |
+
* append a free shipping rate to the result.
|
| 507 |
+
*/
|
| 508 |
+
if($free_shipping_setting != 'none') {
|
| 509 |
+
$multi_shipping_price = 0;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
}
|
| 513 |
+
//$multi_shipping_price += $helper->getTotalDiscountShippingPrice($service['price'], $toOrder[$id_service]);
|
| 514 |
+
}
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
//save rate_id info for Book
|
| 518 |
+
Mage::getSingleton('core/session')->setShiphawkBookId($toOrder);
|
| 519 |
+
|
| 520 |
+
$helper->shlog($toOrder, 'shiphawk-toOrder.log');
|
| 521 |
+
|
| 522 |
+
//save rate filter to order
|
| 523 |
+
Mage::getSingleton('core/session')->setShiphawkRateFilter($rate_filter);
|
| 524 |
+
|
| 525 |
+
if($is_multi_zip) {
|
| 526 |
+
//add ShipHawk shipping
|
| 527 |
+
$name_service = 'Shipping from multiple locations';
|
| 528 |
+
$shipping_price = $multi_shipping_price;
|
| 529 |
+
Mage::getSingleton('core/session')->setSummPrice($summ_price);
|
| 530 |
+
|
| 531 |
+
foreach($toOrder as $rateid=>$rate_data) {
|
| 532 |
+
$package_info .= $rate_data['name']. ' - ' . $rate_data['carrier'] . ' - ' .$rate_data['packing_info'];
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
Mage::getSingleton('core/session')->setPackageInfo($package_info);
|
| 536 |
+
$result->append($this->_getShiphawkRateObject($name_service, $shipping_price, $summ_price, null));
|
| 537 |
+
}
|
| 538 |
+
}else{
|
| 539 |
+
$error_text_from_config = Mage::getStoreConfig('carriers/shiphawk_shipping/shiphawk_error_message');
|
| 540 |
+
Mage::getSingleton('core/session')->setShiphawkErrorRate($error_text_from_config);
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
}catch (Mage_Core_Exception $e) {
|
| 544 |
+
Mage::logException($e);
|
| 545 |
+
} catch (Exception $e) {
|
| 546 |
+
Mage::logException($e);
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
return $result;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
protected function _getFreeShippingRate()
|
| 553 |
+
{
|
| 554 |
+
$rate = Mage::getModel('shipping/rate_result_method');
|
| 555 |
+
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
| 556 |
+
$rate->setCarrier($this->_code);
|
| 557 |
+
$rate->setCarrierTitle($this->getConfigData('title'));
|
| 558 |
+
$rate->setMethod('free_shipping');
|
| 559 |
+
$rate->setMethodTitle('Free Shipping');
|
| 560 |
+
$rate->setPrice(0);
|
| 561 |
+
$rate->setCost(0);
|
| 562 |
+
return $rate;
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
/**
|
| 567 |
+
* Returns Allowed shipping methods
|
| 568 |
+
*
|
| 569 |
+
* @return array
|
| 570 |
+
*/
|
| 571 |
+
public function getAllowedMethods()
|
| 572 |
+
{
|
| 573 |
+
return array(
|
| 574 |
+
'ground' => 'Ground delivery'
|
| 575 |
+
);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
public function getProductIds($_items) {
|
| 579 |
+
$products_ids = array();
|
| 580 |
+
foreach($_items as $_item) {
|
| 581 |
+
$products_ids[] = $_item['product_id'];
|
| 582 |
+
}
|
| 583 |
+
return $products_ids;
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
/**
|
| 587 |
+
* Get Standard rate object
|
| 588 |
+
*
|
| 589 |
+
* @return Mage_Shipping_Model_Rate_Result_Method
|
| 590 |
+
*/
|
| 591 |
+
protected function _getShiphawkRateObject($method_title, $price, $true_price, $accessorial)
|
| 592 |
+
{
|
| 593 |
+
/** @var Mage_Shipping_Model_Rate_Result_Method $rate */
|
| 594 |
+
$rate = Mage::getModel('shipping/rate_result_method');
|
| 595 |
+
|
| 596 |
+
$ship_rate_id = str_replace('-', '_', str_replace(',', '', str_replace(' ', '_', $method_title.$true_price)));
|
| 597 |
+
|
| 598 |
+
$rate->setCarrier($this->_code);
|
| 599 |
+
$rate->setCarrierTitle('ShipHawk');
|
| 600 |
+
$rate->setMethodTitle($method_title);
|
| 601 |
+
$rate->setMethod($ship_rate_id);
|
| 602 |
+
$rate->setPrice($price);
|
| 603 |
+
$rate->setCost($price);
|
| 604 |
+
if(!empty($accessorial)) {
|
| 605 |
+
$rate->setMethodDescription(serialize($accessorial));
|
| 606 |
+
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
return $rate;
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
public function getShiphawkItems($request) {
|
| 613 |
+
$items = array();
|
| 614 |
+
$productModel = Mage::getModel('catalog/product');
|
| 615 |
+
|
| 616 |
+
$custom_packing_price_setting = Mage::getStoreConfig('carriers/shiphawk_shipping/shiphawk_custom_packing_price');
|
| 617 |
+
|
| 618 |
+
foreach ($request->getAllItems() as $item) {
|
| 619 |
+
$product_id = $item->getProductId();
|
| 620 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
| 621 |
+
|
| 622 |
+
$freightClass = $product->getShiphawkFreightClass();
|
| 623 |
+
$freightClassValue = '';
|
| 624 |
+
|
| 625 |
+
if (!empty($freightClass)) {
|
| 626 |
+
$attr = $productModel->getResource()->getAttribute('shiphawk_freight_class');
|
| 627 |
+
$freightClassValue = $attr->getSource()->getOptionText($freightClass);
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
$type_id = $product->getTypeId();
|
| 631 |
+
$parent_item = $item->getParentItem();
|
| 632 |
+
if(($type_id == 'simple')&&(empty($parent_item))) {
|
| 633 |
+
$product_qty = (($product->getShiphawkQuantity() > 0)) ? $product->getShiphawkQuantity() : 1;
|
| 634 |
+
|
| 635 |
+
/** @var $helper Shiphawk_Shipping_Helper_Data */
|
| 636 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 637 |
+
$carrier_type = $helper->getProductCarrierType($product);
|
| 638 |
+
|
| 639 |
+
//hack for admin shipment in popup
|
| 640 |
+
$qty_ordered = ($item->getQty() > 0 ) ? $item->getQty() : $item->getData('qty_ordered');
|
| 641 |
+
|
| 642 |
+
$items[] = array(
|
| 643 |
+
'width' => $product->getShiphawkWidth(),
|
| 644 |
+
'length' => $product->getShiphawkLength(),
|
| 645 |
+
'height' => $product->getShiphawkHeight(),
|
| 646 |
+
'weight' => ($product->getWeight()) ? ($product->getWeight()) : 0,
|
| 647 |
+
'value' => $this->getShipHawkItemValue($product),
|
| 648 |
+
'quantity' => $product_qty*$qty_ordered,
|
| 649 |
+
'packed' => $this->getIsPacked($product),
|
| 650 |
+
'id' => $product->getShiphawkTypeOfProductValue(),
|
| 651 |
+
'zip'=> $this->getOriginZip($product),
|
| 652 |
+
'product_id'=> $product_id,
|
| 653 |
+
'xid'=> $product_id,
|
| 654 |
+
'origin'=> $this->getShiphawkShippingOrigin($product),
|
| 655 |
+
'location_type'=> $this->getOriginLocation($product),
|
| 656 |
+
'require_crating'=> false,
|
| 657 |
+
'nmfc'=> '',
|
| 658 |
+
'freight_class'=> $freightClassValue,
|
| 659 |
+
'shiphawk_carrier_type'=> $carrier_type,
|
| 660 |
+
'shiphawk_discount_fixed'=> $product->getShiphawkDiscountFixed(),
|
| 661 |
+
'shiphawk_discount_percentage'=> $product->getShiphawkDiscountPercentage(),
|
| 662 |
+
'shiphawk_custom_packing_price'=> (($this->getIsPacked($product) == 'true')&&($custom_packing_price_setting)) ? null : $product->getShiphawkCustomPackingPrice(),
|
| 663 |
+
);
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
// single product in Bundle Product
|
| 667 |
+
if(($type_id == 'simple')&&(is_object($parent_item))) {
|
| 668 |
+
$product_qty = (($product->getShiphawkQuantity() > 0)) ? $product->getShiphawkQuantity() : 1;
|
| 669 |
+
|
| 670 |
+
$qty_bundle_product = $parent_item->getQty();
|
| 671 |
+
|
| 672 |
+
if($qty_bundle_product > 0) {
|
| 673 |
+
$product_qty = $qty_bundle_product * $product_qty;
|
| 674 |
+
}
|
| 675 |
+
|
| 676 |
+
/** @var $helper Shiphawk_Shipping_Helper_Data */
|
| 677 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 678 |
+
$carrier_type = $helper->getProductCarrierType($product);
|
| 679 |
+
|
| 680 |
+
//hack for admin shipment in popup
|
| 681 |
+
$qty_ordered = ($item->getQty() > 0 ) ? $item->getQty() : $item->getData('qty_ordered');
|
| 682 |
+
|
| 683 |
+
$items[] = array(
|
| 684 |
+
'width' => $product->getShiphawkWidth(),
|
| 685 |
+
'length' => $product->getShiphawkLength(),
|
| 686 |
+
'height' => $product->getShiphawkHeight(),
|
| 687 |
+
'weight' => ($product->getWeight()) ? ($product->getWeight()) : 0,
|
| 688 |
+
'value' => $this->getShipHawkItemValue($product),
|
| 689 |
+
'quantity' => $product_qty*$qty_ordered,
|
| 690 |
+
'packed' => $this->getIsPacked($product),
|
| 691 |
+
'id' => $product->getShiphawkTypeOfProductValue(),
|
| 692 |
+
'zip'=> $this->getOriginZip($product),
|
| 693 |
+
'product_id'=> $product_id,
|
| 694 |
+
'xid'=> $product_id,
|
| 695 |
+
'origin'=> $this->getShiphawkShippingOrigin($product),
|
| 696 |
+
'location_type'=> $this->getOriginLocation($product),
|
| 697 |
+
'require_crating'=> false,
|
| 698 |
+
'nmfc'=> '',
|
| 699 |
+
'freight_class'=> $freightClassValue,
|
| 700 |
+
'shiphawk_carrier_type'=> $carrier_type,
|
| 701 |
+
'shiphawk_discount_fixed'=> $product->getShiphawkDiscountFixed(),
|
| 702 |
+
'shiphawk_discount_percentage'=> $product->getShiphawkDiscountPercentage(),
|
| 703 |
+
'shiphawk_custom_packing_price'=> (($this->getIsPacked($product) == 'true')&&($custom_packing_price_setting)) ? null : $product->getShiphawkCustomPackingPrice(),
|
| 704 |
+
);
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
return $items;
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
public function getShiphawkShippingOrigin($product) {
|
| 712 |
+
|
| 713 |
+
/** @var $helper Shiphawk_Shipping_Helper_Data */
|
| 714 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 715 |
+
|
| 716 |
+
if($helper->checkShipHawkOriginAttributes($product)) {
|
| 717 |
+
return 'origin_per_product';
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
$product_origin_id = $product->getShiphawkShippingOrigins();
|
| 721 |
+
|
| 722 |
+
if ($product_origin_id) {
|
| 723 |
+
return $product_origin_id;
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
return null;
|
| 727 |
+
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
public function getShippingZip() {
|
| 731 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
| 732 |
+
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
| 733 |
+
}else{
|
| 734 |
+
/** @var $cart Mage_Checkout_Model_Cart */
|
| 735 |
+
$cart = Mage::getSingleton('checkout/cart');
|
| 736 |
+
$quote = $cart->getQuote();
|
| 737 |
+
}
|
| 738 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 739 |
+
$zip_code = $shippingAddress->getPostcode();
|
| 740 |
+
return $zip_code;
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
public function getShipHawkItemValue($product) {
|
| 744 |
+
if($product->getShiphawkQuantity() > 0) {
|
| 745 |
+
$product_price = $product->getPrice()/$product->getShiphawkQuantity();
|
| 746 |
+
}else{
|
| 747 |
+
$product_price = $product->getPrice();
|
| 748 |
+
}
|
| 749 |
+
$item_value = ($product->getShiphawkItemValue() > 0) ? $product->getShiphawkItemValue() : $product_price;
|
| 750 |
+
return $item_value;
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
public function getOriginZip($product) {
|
| 754 |
+
$default_origin_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
|
| 755 |
+
|
| 756 |
+
$shipping_origin_id = $product->getData('shiphawk_shipping_origins');
|
| 757 |
+
|
| 758 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 759 |
+
/* check if all origin attributes are set */
|
| 760 |
+
$per_product = $helper->checkShipHawkOriginAttributes($product);
|
| 761 |
+
|
| 762 |
+
if($per_product == true) {
|
| 763 |
+
return $product->getData('shiphawk_origin_zipcode');
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
if($shipping_origin_id) {
|
| 767 |
+
// get zip code from Shiping Origin
|
| 768 |
+
$shipping_origin = Mage::getModel('shiphawk_shipping/origins')->load($shipping_origin_id);
|
| 769 |
+
$product_origin_zip_code = $shipping_origin->getData('shiphawk_origin_zipcode');
|
| 770 |
+
return $product_origin_zip_code;
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
return $default_origin_zip;
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
public function getOriginLocation($product) {
|
| 777 |
+
$default_origin_location = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_location_type');
|
| 778 |
+
|
| 779 |
+
$shipping_origin_id = $product->getData('shiphawk_shipping_origins');
|
| 780 |
+
|
| 781 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 782 |
+
/* check if all origin attributes are set */
|
| 783 |
+
$per_product = $helper->checkShipHawkOriginAttributes($product);
|
| 784 |
+
|
| 785 |
+
if($per_product == true) {
|
| 786 |
+
return $product->getAttributeText('shiphawk_origin_location');
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
if($shipping_origin_id) {
|
| 790 |
+
// get zip code from Shiping Origin
|
| 791 |
+
$shipping_origin = Mage::getModel('shiphawk_shipping/origins')->load($shipping_origin_id);
|
| 792 |
+
$product_origin_zip_code = $shipping_origin->getData('shiphawk_origin_location');
|
| 793 |
+
return $product_origin_zip_code;
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
return $default_origin_location;
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
public function getIsPacked($product) {
|
| 800 |
+
$default_is_packed = Mage::getStoreConfig('carriers/shiphawk_shipping/item_is_packed');
|
| 801 |
+
$product_is_packed = $product->getShiphawkItemIsPacked();
|
| 802 |
+
$product_is_packed = ($product_is_packed == 2) ? $default_is_packed : $product_is_packed;
|
| 803 |
+
|
| 804 |
+
return ($product_is_packed ? 'true' : 'false');
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
/* sort items by origin id */
|
| 808 |
+
public function getGroupedItemsByZip($items) {
|
| 809 |
+
$tmp = array();
|
| 810 |
+
foreach($items as $item) {
|
| 811 |
+
$tmp[$item['origin']][] = $item;
|
| 812 |
+
}
|
| 813 |
+
return $tmp;
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
/* sort items by origin zip code */
|
| 817 |
+
public function getGroupedItemsByZipPerProduct($items) {
|
| 818 |
+
$tmp = array();
|
| 819 |
+
foreach($items as $item) {
|
| 820 |
+
$tmp[$item['zip']][] = $item;
|
| 821 |
+
}
|
| 822 |
+
return $tmp;
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
/* sort items by carrier type */
|
| 826 |
+
public function getGroupedItemsByCarrierType($items) {
|
| 827 |
+
$tmp = array();
|
| 828 |
+
foreach($items as $item) {
|
| 829 |
+
$tmp[$item['shiphawk_carrier_type']][] = $item;
|
| 830 |
+
}
|
| 831 |
+
return $tmp;
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
/* sort items by discount or markup */
|
| 835 |
+
public function getGroupedItemsByDiscountOrMarkup($items) {
|
| 836 |
+
$tmp = array();
|
| 837 |
+
foreach($items as $item) {
|
| 838 |
+
$tmp[$item['shiphawk_discount_percentage']. '-' .$item['shiphawk_discount_fixed']][] = $item;
|
| 839 |
+
}
|
| 840 |
+
return $tmp;
|
| 841 |
+
}
|
| 842 |
+
|
| 843 |
+
/* sort items by shiphawk_custom_packing_price */
|
| 844 |
+
public function getGroupedItemsByCustomPackingPrice($items) {
|
| 845 |
+
$tmp = array();
|
| 846 |
+
foreach($items as $item) {
|
| 847 |
+
$tmp[$item['shiphawk_custom_packing_price']][] = $item;
|
| 848 |
+
}
|
| 849 |
+
return $tmp;
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
protected function _getChipiestRateId($services) {
|
| 853 |
+
|
| 854 |
+
$t = array();
|
| 855 |
+
foreach ($services as $id_service=>$service) {
|
| 856 |
+
$t[$id_service] = $service['price'];
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
asort($t);
|
| 860 |
+
|
| 861 |
+
$rate_id = key($t);
|
| 862 |
+
|
| 863 |
+
return $rate_id;
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
public function getServices($ship_responces, $toOrder, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting) {
|
| 867 |
+
|
| 868 |
+
$services = array();
|
| 869 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 870 |
+
foreach($ship_responces as $ship_responce) {
|
| 871 |
+
if(is_array($ship_responce)) {
|
| 872 |
+
$custom_products_packing_price = 0;
|
| 873 |
+
foreach($ship_responce as $object) {
|
| 874 |
+
$services[$object->id]['name'] = $this->_getServiceName($object);
|
| 875 |
+
|
| 876 |
+
foreach($toOrder as $rate_id=>$rate_data) {
|
| 877 |
+
if($rate_id == $object->id){
|
| 878 |
+
$services[$object->id]['custom_products_packing_price'] = $rate_data['custom_products_packing_price'];
|
| 879 |
+
$custom_products_packing_price = $rate_data['custom_products_packing_price'];
|
| 880 |
+
break;
|
| 881 |
+
}
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
$services[$object->id]['price'] = $helper->getSummaryPrice($object, $self_pack, $charge_customer_for_packing, $custom_packing_price_setting, $custom_products_packing_price);
|
| 885 |
+
$services[$object->id]['carrier'] = $this->getCarrierName($object);
|
| 886 |
+
$services[$object->id]['shiphawk_price'] = $helper->getShipHawkPrice($object, $self_pack, $charge_customer_for_packing);
|
| 887 |
+
|
| 888 |
+
/* packing info */
|
| 889 |
+
$services[$object->id]['packing']['price'] = $object->packing->price;
|
| 890 |
+
$services[$object->id]['packing']['info'] = $this->getPackeges($object);
|
| 891 |
+
$services[$object->id]['delivery'] = ''; //todo delivery
|
| 892 |
+
$services[$object->id]['carrier_type'] = ''; //todo carrier type
|
| 893 |
+
|
| 894 |
+
/* accesorial info */
|
| 895 |
+
$services[$object->id]['accessorial'] = $object->shipping->carrier_accessorial;
|
| 896 |
+
|
| 897 |
+
/* discount-markup by product or by sys. conf. */
|
| 898 |
+
|
| 899 |
+
foreach($toOrder as $rate_id=>$rate_data) {
|
| 900 |
+
if($rate_id == $object->id){
|
| 901 |
+
$services[$object->id]['shiphawk_discount_fixed'] = $rate_data['shiphawk_discount_fixed'];
|
| 902 |
+
$services[$object->id]['shiphawk_discount_percentage'] = $rate_data['shiphawk_discount_percentage'];
|
| 903 |
+
break;
|
| 904 |
+
}
|
| 905 |
+
}
|
| 906 |
+
}
|
| 907 |
+
}
|
| 908 |
+
}
|
| 909 |
+
|
| 910 |
+
return $services;
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
public function getPackeges($object) {
|
| 914 |
+
$result = array();
|
| 915 |
+
$i=0;
|
| 916 |
+
$package_info = '';
|
| 917 |
+
foreach ($object->packing->packages as $package_object) {
|
| 918 |
+
$result[$i]['tracking_number'] = $package_object->tracking_number;
|
| 919 |
+
$result[$i]['tracking_url'] = $package_object->tracking_url;
|
| 920 |
+
$result[$i]['packing_type'] = $package_object->packing_type;
|
| 921 |
+
$result[$i]['dimensions']['length'] = $package_object->dimensions->length;
|
| 922 |
+
$result[$i]['dimensions']['width'] = $package_object->dimensions->width;
|
| 923 |
+
$result[$i]['dimensions']['height'] = $package_object->dimensions->height;
|
| 924 |
+
$result[$i]['dimensions']['weight'] = $package_object->dimensions->weight;
|
| 925 |
+
$result[$i]['dimensions']['volume'] = $package_object->dimensions->volume;
|
| 926 |
+
//$result[$i]['dimensions']['density'] = $package_object->dimensions->density;
|
| 927 |
+
|
| 928 |
+
$package_info .= $package_object->dimensions->length .
|
| 929 |
+
'x' . $package_object->dimensions->width .
|
| 930 |
+
'x' . $package_object->dimensions->height .
|
| 931 |
+
', ' . $package_object->dimensions->weight . ' lbs. ';
|
| 932 |
+
|
| 933 |
+
$i++;
|
| 934 |
+
}
|
| 935 |
+
|
| 936 |
+
return $package_info;
|
| 937 |
+
}
|
| 938 |
+
|
| 939 |
+
protected function _getServiceName($object) {
|
| 940 |
+
|
| 941 |
+
if ( $object->shipping->carrier_type == "Small Parcel" ) {
|
| 942 |
+
return $object->shipping->service;
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
if ( $object->shipping->carrier_type == "Blanket Wrap" ) {
|
| 946 |
+
return "Standard White Glove Delivery (3-6 weeks)";
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
if ( ( ( $object->shipping->carrier_type == "LTL" ) || ( $object->shipping->carrier_type == "3PL" ) || ( $object->shipping->carrier_type == "Intermodal" ) ) && ($object->delivery->price == 0) ) {
|
| 950 |
+
return "Curbside Delivery (1-2 weeks)";
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
if ( ( ( $object->shipping->carrier_type == "LTL" ) || ( $object->shipping->carrier_type == "3PL" ) || ( $object->shipping->carrier_type == "Intermodal" ) ) && ($object->delivery->price > 0) ) {
|
| 954 |
+
return "Expedited White Glove Delivery (2-3 weeks)";
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
if ( $object->shipping->carrier_type == "Home Delivery" ) {
|
| 958 |
+
return "Home Delivery - " . $object->shipping->service . " (1-2 weeks)";
|
| 959 |
+
}
|
| 960 |
+
|
| 961 |
+
return $object->shipping->service;
|
| 962 |
+
|
| 963 |
+
}
|
| 964 |
+
|
| 965 |
+
public function getCarrierName($object) {
|
| 966 |
+
return $object->shipping->carrier_friendly_name;
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
/*
|
| 970 |
+
1. If carrier_type = "Small Parcel" display name should be what's included in field [Service] (example: Ground)
|
| 971 |
+
|
| 972 |
+
2. If carrier_type = "Blanket Wrap" display name should be:
|
| 973 |
+
"Standard White Glove Delivery (3-6 weeks)"
|
| 974 |
+
|
| 975 |
+
3. If carrier_type = "LTL","3PL","Intermodal" AND delivery field inside [details][price]=$0.00 display name should be:
|
| 976 |
+
"Curbside delivery (1-2 weeks)"
|
| 977 |
+
|
| 978 |
+
4. If carrier_type = "LTL","3PL" "Intermodal" AND delivery field inside [details][price] > $0.00 display name should be:
|
| 979 |
+
"Expedited White Glove Delivery (2-3 weeks)"
|
| 980 |
+
|
| 981 |
+
Additional rule for naming (both frontend and backend):
|
| 982 |
+
|
| 983 |
+
If carrier_type = "Home Delivery" display name should be:
|
| 984 |
+
"Home Delivery - {{
|
| 985 |
+
{Service name from received rate}
|
| 986 |
+
}} (1-2 weeks)"
|
| 987 |
+
==> example: Home Delivery - One Man (1-2 weeks)
|
| 988 |
+
|
| 989 |
+
*/
|
| 990 |
+
|
| 991 |
+
public function isTrackingAvailable()
|
| 992 |
+
{
|
| 993 |
+
return true;
|
| 994 |
+
}
|
| 995 |
+
|
| 996 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Observer.php
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Observer extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _setAttributeRequired($attributeCode, $is_active) {
|
| 5 |
+
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode( 'catalog_product', $attributeCode);
|
| 6 |
+
$attributeModel->setIsRequired($is_active);
|
| 7 |
+
$attributeModel->save();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function salesOrderPlaceAfter($observer) {
|
| 11 |
+
$event = $observer->getEvent();
|
| 12 |
+
$order = $event->getOrder();
|
| 13 |
+
$orderId = $order->getId();
|
| 14 |
+
|
| 15 |
+
/* For accessories */
|
| 16 |
+
$accessories = Mage::app()->getRequest()->getPost('accessories', array());
|
| 17 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 18 |
+
|
| 19 |
+
$manual_shipping = Mage::getStoreConfig('carriers/shiphawk_shipping/book_shipment');
|
| 20 |
+
$shipping_code = $order->getShippingMethod();
|
| 21 |
+
$shipping_description = $order->getShippingDescription();
|
| 22 |
+
$check_shiphawk = Mage::helper('shiphawk_shipping')->isShipHawkShipping($shipping_code);
|
| 23 |
+
if($check_shiphawk !== false) {
|
| 24 |
+
|
| 25 |
+
/* For location type */
|
| 26 |
+
$shLocationType = Mage::getSingleton('checkout/session')->getData('shiphawk_location_type_shipping');
|
| 27 |
+
|
| 28 |
+
if (!empty($shLocationType)) $order->setShiphawkLocationType($shLocationType);
|
| 29 |
+
|
| 30 |
+
// set ShipHawk rate todo ship to multiply shiping address, only one shipping order save to session
|
| 31 |
+
$shiphawk_book_id = Mage::getSingleton('core/session')->getShiphawkBookId();
|
| 32 |
+
|
| 33 |
+
$multi_zip_code = Mage::getSingleton('core/session')->getMultiZipCode();
|
| 34 |
+
|
| 35 |
+
// set ShipHawk rate filter
|
| 36 |
+
$shiphawkRateFilter = Mage::getSingleton('core/session')->getShiphawkRateFilter();
|
| 37 |
+
$order->setShiphawkRateFilter($shiphawkRateFilter);
|
| 38 |
+
|
| 39 |
+
//shiphawk_shipping_amount
|
| 40 |
+
if($multi_zip_code == false) {
|
| 41 |
+
|
| 42 |
+
$shiphawk_book_id = $helper->getShipHawkCode($shiphawk_book_id, $shipping_code);
|
| 43 |
+
foreach ($shiphawk_book_id as $rate_id=>$method_data) {
|
| 44 |
+
//$order->setShiphawkShippingAmount($method_data['price']);
|
| 45 |
+
$shiphawk_shipping_amount = $method_data['price'];
|
| 46 |
+
$order->setShiphawkShippingPackageInfo($method_data['packing_info']);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
}else{
|
| 50 |
+
//if multi origin shipping
|
| 51 |
+
$shiphawk_shipping_amount = Mage::getSingleton('core/session')->getSummPrice();
|
| 52 |
+
$shiphawk_shipping_package_info = Mage::getSingleton('core/session')->getPackageInfo();
|
| 53 |
+
//$order->setShiphawkShippingAmount($shiphawk_shipping_amount);
|
| 54 |
+
$order->setShiphawkShippingPackageInfo($shiphawk_shipping_package_info);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
$order->setShiphawkBookId(serialize($shiphawk_book_id));
|
| 58 |
+
|
| 59 |
+
// it's for admin order
|
| 60 |
+
if (!empty($accessories)) {
|
| 61 |
+
/* For accessories */
|
| 62 |
+
$accessoriesPrice = 0;
|
| 63 |
+
$accessoriesData = array();
|
| 64 |
+
foreach($accessories as $typeName => $type) {
|
| 65 |
+
foreach($type as $name => $values) {
|
| 66 |
+
foreach($values as $key => $value) {
|
| 67 |
+
$accessoriesData[$typeName][$key]['name'] = $name;
|
| 68 |
+
$accessoriesData[$typeName][$key]['value'] = (float)$value;
|
| 69 |
+
|
| 70 |
+
$accessoriesPrice += (float)$value;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
$newAccessoriesPrice = $order->getShippingAmount() + $accessoriesPrice;
|
| 75 |
+
$newGtandTotal = $order->getGrandTotal() + $accessoriesPrice;
|
| 76 |
+
|
| 77 |
+
$order->setShiphawkShippingAccessories(json_encode($accessoriesData));
|
| 78 |
+
$order->setShippingAmount($newAccessoriesPrice);
|
| 79 |
+
$order->setBaseShippingAmount($newAccessoriesPrice);
|
| 80 |
+
$order->setGrandTotal($newGtandTotal);
|
| 81 |
+
$order->setBaseGrandTotal($newGtandTotal);
|
| 82 |
+
|
| 83 |
+
$order->setShiphawkShippingAmount($shiphawk_shipping_amount + $accessoriesPrice);
|
| 84 |
+
}else{
|
| 85 |
+
|
| 86 |
+
// it is for frontend order - accessories saved in checkout_type_onepage_save_order event
|
| 87 |
+
$accessoriesPriceData = json_decode($order->getData('shiphawk_shipping_accessories'));
|
| 88 |
+
$accessoriesPrice = $helper->getAccessoriesPrice($accessoriesPriceData);
|
| 89 |
+
|
| 90 |
+
$order->setShiphawkShippingAmount($shiphawk_shipping_amount + $accessoriesPrice);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
$order->save();
|
| 94 |
+
if(!$manual_shipping) {
|
| 95 |
+
if ($order->canShip()) {
|
| 96 |
+
$api = Mage::getModel('shiphawk_shipping/api');
|
| 97 |
+
$api->saveshipment($orderId);
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
Mage::getSingleton('core/session')->unsShiphawkBookId();
|
| 103 |
+
Mage::getSingleton('core/session')->unsMultiZipCode();
|
| 104 |
+
Mage::getSingleton('core/session')->unsSummPrice();
|
| 105 |
+
Mage::getSingleton('core/session')->unsPackageInfo();
|
| 106 |
+
|
| 107 |
+
Mage::getSingleton('core/session')->unsetData('admin_accessories_price');
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* For rewrite address collectTotals
|
| 112 |
+
*
|
| 113 |
+
* @param $observer
|
| 114 |
+
*
|
| 115 |
+
* @version 20150617
|
| 116 |
+
*/
|
| 117 |
+
public function recalculationTotals($observer) {
|
| 118 |
+
$event = $observer->getEvent();
|
| 119 |
+
$address = $event->getQuoteAddress();
|
| 120 |
+
|
| 121 |
+
$session = Mage::getSingleton('checkout/session');
|
| 122 |
+
$accessories = $session->getData('shipment_accessories');
|
| 123 |
+
$method = $address->getShippingMethod();
|
| 124 |
+
|
| 125 |
+
// we have no accessories on cart page
|
| 126 |
+
$is_it_cart_page = Mage::helper('shiphawk_shipping')->checkIsItCartPage();
|
| 127 |
+
|
| 128 |
+
if (empty($accessories['accessories_price']) || !$method || $is_it_cart_page) {
|
| 129 |
+
return;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
|
| 133 |
+
//Mage::log($totals);
|
| 134 |
+
$discount = 0;
|
| 135 |
+
if(isset($totals['discount'])&&$totals['discount']->getValue()) {
|
| 136 |
+
$discount = round($totals['discount']->getValue(), 2); //Discount value if applied
|
| 137 |
+
}
|
| 138 |
+
$tax = 0;
|
| 139 |
+
if(isset($totals['tax']) && $totals['tax']->getValue()) {
|
| 140 |
+
$tax = round($totals['tax']->getValue(), 2); //Discount value if applied
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
$accessoriesPrice = (float)$accessories['accessories_price'];
|
| 144 |
+
$grandTotal = (float)$accessories['grand_total'];
|
| 145 |
+
$baseGrandTotal = (float)$accessories['base_grand_total'];
|
| 146 |
+
$shippingAmount = (float)$accessories['shipping_amount'];
|
| 147 |
+
$baseShippingAmount = (float)$accessories['base_shipping_amount'];
|
| 148 |
+
|
| 149 |
+
//$shippingAmount = empty($shippingAmount) ? $address->getShippingAmount() : $shippingAmount;
|
| 150 |
+
$shippingAmount = $address->getShippingAmount();
|
| 151 |
+
//$baseShippingAmount = empty($baseShippingAmount) ? $address->getBaseShippingAmount() : $baseShippingAmount;
|
| 152 |
+
$baseShippingAmount = $address->getBaseShippingAmount();
|
| 153 |
+
|
| 154 |
+
$newShippingPrice = $shippingAmount + $accessoriesPrice;
|
| 155 |
+
$newShippingBasePrice = $baseShippingAmount + $accessoriesPrice;
|
| 156 |
+
|
| 157 |
+
$address->setShippingAmount($newShippingPrice);
|
| 158 |
+
$address->setBaseShippingAmount($baseShippingAmount + $accessoriesPrice);
|
| 159 |
+
$address->setGrandTotal($grandTotal + $newShippingPrice + ($discount) + ($tax));
|
| 160 |
+
$address->setBaseGrandTotal($baseGrandTotal + $newShippingBasePrice);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* For save accessories in checkout session
|
| 165 |
+
*
|
| 166 |
+
* @param $observer
|
| 167 |
+
*
|
| 168 |
+
* @version 20150617
|
| 169 |
+
*/
|
| 170 |
+
public function setAccessories($observer) {
|
| 171 |
+
$event = $observer->getEvent();
|
| 172 |
+
$accessories = $event->getRequest()->getPost('accessories', array());
|
| 173 |
+
$address = $event->getQuote()->getShippingAddress();
|
| 174 |
+
$grandTotal = $address->getSubtotal();
|
| 175 |
+
$baseGrandTotal = $address->getBaseSubtotal();
|
| 176 |
+
$shippingAmount = $address->getShippingInclTax();
|
| 177 |
+
$baseShippingAmount = $address->getBaseShippingInclTax();
|
| 178 |
+
$session = Mage::getSingleton('checkout/session');
|
| 179 |
+
|
| 180 |
+
if (empty($accessories)) {
|
| 181 |
+
$session->setData("shipment_accessories", array());
|
| 182 |
+
return;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
$accessoriesPrice = 0;
|
| 186 |
+
$accessoriesData = array();
|
| 187 |
+
foreach($accessories as $typeName => $type) {
|
| 188 |
+
foreach($type as $name => $values) {
|
| 189 |
+
foreach($values as $key => $value) {
|
| 190 |
+
$accessoriesData[$typeName][$key]['name'] = $name;
|
| 191 |
+
$accessoriesData[$typeName][$key]['value'] = (float)$value;
|
| 192 |
+
|
| 193 |
+
$accessoriesPrice += (float)$value;
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
$params['data'] = $accessoriesData;
|
| 199 |
+
$params['grand_total'] = $grandTotal;
|
| 200 |
+
$params['base_grand_total'] = $baseGrandTotal;
|
| 201 |
+
$params['accessories_price'] = $accessoriesPrice;
|
| 202 |
+
$params['shipping_amount'] = $shippingAmount;
|
| 203 |
+
$params['base_shipping_amount'] = $baseShippingAmount;
|
| 204 |
+
|
| 205 |
+
$session->setData("shipment_accessories", $params);
|
| 206 |
+
$session->setAccessoriesprice($accessoriesPrice);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
* For save accessories in order
|
| 211 |
+
*
|
| 212 |
+
* @param $observer
|
| 213 |
+
*
|
| 214 |
+
* @version 20150618
|
| 215 |
+
*/
|
| 216 |
+
public function saveAccessoriesInOrder($observer) {
|
| 217 |
+
$event = $observer->getEvent();
|
| 218 |
+
$order = $event->getOrder();
|
| 219 |
+
|
| 220 |
+
$session = Mage::getSingleton('checkout/session');
|
| 221 |
+
$accessories = $session->getData("shipment_accessories");
|
| 222 |
+
|
| 223 |
+
//clear session data
|
| 224 |
+
$session->unsetData('shipment_accessories');
|
| 225 |
+
|
| 226 |
+
if (empty($accessories['accessories_price'])) {
|
| 227 |
+
return;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
$order->setShiphawkShippingAccessories(json_encode($accessories['data']));
|
| 231 |
+
$order->save();
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/**
|
| 235 |
+
* For rewrite shipping/method/form.phtml template
|
| 236 |
+
*
|
| 237 |
+
* @param $observer
|
| 238 |
+
*
|
| 239 |
+
* @version 20150622
|
| 240 |
+
*/
|
| 241 |
+
public function changeSippingMethodTemplate($observer) {
|
| 242 |
+
if ($observer->getBlock() instanceof Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form) {
|
| 243 |
+
$observer->getBlock()->setTemplate('shiphawk/shipping/method/form.phtml')->renderView();
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* For override shipping cost by admin, when he create order
|
| 249 |
+
*
|
| 250 |
+
* @param $observer
|
| 251 |
+
*
|
| 252 |
+
* @version 20150626
|
| 253 |
+
*/
|
| 254 |
+
public function overrideShippingCost($observer) {
|
| 255 |
+
$event = $observer->getEvent();
|
| 256 |
+
$order = $event->getOrder();
|
| 257 |
+
$subTotal = $order->getSubtotal();
|
| 258 |
+
|
| 259 |
+
$overrideCost = Mage::app()->getRequest()->getPost('sh_override_shipping_cost', 0);
|
| 260 |
+
|
| 261 |
+
if ((floatval($overrideCost) < 0)||($overrideCost === null)||( $overrideCost === "")) {
|
| 262 |
+
return;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
$totals = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getTotals();
|
| 266 |
+
$discount = 0;
|
| 267 |
+
if(isset($totals['discount']) && $totals['discount']->getValue()) {
|
| 268 |
+
$discount = round($totals['discount']->getValue(), 2); //Discount value if applied
|
| 269 |
+
}
|
| 270 |
+
$tax = 0;
|
| 271 |
+
if(isset($totals['tax']) && $totals['tax']->getValue()) {
|
| 272 |
+
$tax = round($totals['tax']->getValue(), 2); //Discount value if applied
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
$overrideCost = floatval($overrideCost);
|
| 276 |
+
|
| 277 |
+
$grandTotal = $subTotal + $overrideCost + $discount + $tax;
|
| 278 |
+
|
| 279 |
+
$order->setShippingAmount($overrideCost);
|
| 280 |
+
$order->setBaseShippingAmount($overrideCost);
|
| 281 |
+
$order->setGrandTotal($grandTotal);
|
| 282 |
+
$order->setBaseGrandTotal($grandTotal);
|
| 283 |
+
|
| 284 |
+
$order->save();
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* @param $observer
|
| 289 |
+
*/
|
| 290 |
+
public function showShiphawkRateError($observer) {
|
| 291 |
+
|
| 292 |
+
$err_text = Mage::getSingleton('core/session')->getShiphawkErrorRate();
|
| 293 |
+
if($err_text) {
|
| 294 |
+
Mage::getSingleton('core/session')->getMessages(true); // The true is for clearing them after loading them
|
| 295 |
+
Mage::getSingleton('core/session')->addError($err_text);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
Mage::getSingleton('core/session')->unsShiphawkErrorRate();
|
| 299 |
+
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
/**
|
| 303 |
+
* Update accessories & shipping price in admin order view
|
| 304 |
+
* @param $observer
|
| 305 |
+
*/
|
| 306 |
+
public function addAccessoriesToTotals($observer) {
|
| 307 |
+
|
| 308 |
+
if(!Mage::helper('shiphawk_shipping')->checkIsAdmin()) {
|
| 309 |
+
return;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
$event = $observer->getEvent();
|
| 313 |
+
$address = $event->getQuoteAddress();
|
| 314 |
+
|
| 315 |
+
$accessories_price_admin = Mage::getSingleton('core/session')->getData('admin_accessories_price');
|
| 316 |
+
|
| 317 |
+
$shiphawk_override_cost = Mage::getSingleton('core/session')->getData('shiphawk_override_cost');
|
| 318 |
+
|
| 319 |
+
$shippingAmount = $address->getShippingAmount();
|
| 320 |
+
|
| 321 |
+
if(empty($shippingAmount)) {
|
| 322 |
+
return;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
$baseShippingAmount = $address->getBaseShippingAmount();
|
| 326 |
+
|
| 327 |
+
$grandTotal = $address->getSubtotal();
|
| 328 |
+
$baseGrandTotal = $address->getBaseSubtotal();
|
| 329 |
+
|
| 330 |
+
$newShippingPrice = $shippingAmount + $accessories_price_admin;
|
| 331 |
+
$newShippingBasePrice = $baseShippingAmount + $accessories_price_admin;
|
| 332 |
+
|
| 333 |
+
$totals = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getTotals();
|
| 334 |
+
$discount = 0;
|
| 335 |
+
if(isset($totals['discount']) && $totals['discount']->getValue()) {
|
| 336 |
+
$discount = round($totals['discount']->getValue(), 2); //Discount value if applied
|
| 337 |
+
}
|
| 338 |
+
$tax = 0;
|
| 339 |
+
if(isset($totals['tax']) && $totals['tax']->getValue()) {
|
| 340 |
+
$tax = round($totals['tax']->getValue(), 2); //Discount value if applied
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
$address->setShippingAmount($newShippingPrice);
|
| 344 |
+
$address->setBaseShippingAmount($baseShippingAmount + $accessories_price_admin);
|
| 345 |
+
$address->setGrandTotal($grandTotal + $newShippingPrice + ($discount) + ($tax));
|
| 346 |
+
//$address->setGrandTotal(1234);
|
| 347 |
+
$address->setBaseGrandTotal($baseGrandTotal + $newShippingBasePrice);
|
| 348 |
+
|
| 349 |
+
Mage::getSingleton('core/session')->unsetData('admin_accessories_price');
|
| 350 |
+
|
| 351 |
+
if ((floatval($shiphawk_override_cost) < 0)||($shiphawk_override_cost === null)||( $shiphawk_override_cost === "")) {
|
| 352 |
+
return;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
$overrideCost = floatval($shiphawk_override_cost);
|
| 357 |
+
|
| 358 |
+
$subTotal = $address->getSubtotal();
|
| 359 |
+
$grandTotal = $subTotal + $overrideCost + $discount + $tax;
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
$address->setShippingAmount($overrideCost);
|
| 363 |
+
$address->setBaseShippingAmount($overrideCost);
|
| 364 |
+
$address->setGrandTotal($grandTotal);
|
| 365 |
+
$address->setBaseGrandTotal($grandTotal);
|
| 366 |
+
|
| 367 |
+
Mage::getSingleton('core/session')->unsetData('shiphawk_override_cost');
|
| 368 |
+
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Origins.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Origins extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_init('shiphawk_shipping/origins');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Product/Attribute/Source/Location.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Product_Attribute_Source_Location
|
| 3 |
+
extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Retrieve all attribute options
|
| 7 |
+
*
|
| 8 |
+
* @return array
|
| 9 |
+
*/
|
| 10 |
+
public function getAllOptions()
|
| 11 |
+
{
|
| 12 |
+
$this->_options = array(
|
| 13 |
+
array(
|
| 14 |
+
'label' => Mage::helper('catalog')->__('commercial'),
|
| 15 |
+
'value' => Mage::helper('catalog')->__('commercial')
|
| 16 |
+
),
|
| 17 |
+
array(
|
| 18 |
+
'label' => Mage::helper('catalog')->__('residential'),
|
| 19 |
+
'value' => Mage::helper('catalog')->__('residential')
|
| 20 |
+
)
|
| 21 |
+
);
|
| 22 |
+
|
| 23 |
+
return $this->_options;
|
| 24 |
+
}
|
| 25 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Resource/Origins.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Resource_Origins extends Mage_Core_Model_Mysql4_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_init('shiphawk_shipping/origins', 'id');
|
| 7 |
+
}
|
| 8 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Resource/Origins/Collection.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Resource_Origins_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_init('shiphawk_shipping/origins');
|
| 7 |
+
}
|
| 8 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Adminratefilter.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Adminratefilter
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'consumer', 'label'=>Mage::helper('adminhtml')->__('consumer')),
|
| 8 |
+
array('value'=>'top_10', 'label'=>Mage::helper('adminhtml')->__('top 10')),
|
| 9 |
+
);
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Carriertype.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Carriertype
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('All')),
|
| 8 |
+
array('value'=>'ltl', 'label'=>Mage::helper('adminhtml')->__('ltl')),
|
| 9 |
+
array('value'=>'blanket wrap', 'label'=>Mage::helper('adminhtml')->__('blanket wrap')),
|
| 10 |
+
array('value'=>'small parcel', 'label'=>Mage::helper('adminhtml')->__('small parcel')),
|
| 11 |
+
array('value'=>'vehicle', 'label'=>Mage::helper('adminhtml')->__('vehicle')),
|
| 12 |
+
array('value'=>'intermodal', 'label'=>Mage::helper('adminhtml')->__('intermodal')),
|
| 13 |
+
);
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Freeshipping.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Freeshipping
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'none', 'label'=>Mage::helper('adminhtml')->__('None')),
|
| 8 |
+
array('value'=>'cheapest', 'label'=>Mage::helper('adminhtml')->__('Cheapest')),
|
| 9 |
+
array('value'=>'all', 'label'=>Mage::helper('adminhtml')->__('All'))
|
| 10 |
+
);
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Gateway.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Gateway
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'https://shiphawk.com/api/v3/', 'label'=>Mage::helper('adminhtml')->__('Live')),
|
| 8 |
+
array('value'=>'https://sandbox.shiphawk.com/api/v3/', 'label'=>Mage::helper('adminhtml')->__('Sandbox')),
|
| 9 |
+
);
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Location.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Location
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'commercial', 'label'=>Mage::helper('adminhtml')->__('commercial')),
|
| 8 |
+
array('value'=>'residential', 'label'=>Mage::helper('adminhtml')->__('residential')),
|
| 9 |
+
);
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Ratefilter.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Ratefilter
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>'consumer', 'label'=>Mage::helper('adminhtml')->__('consumer')),
|
| 8 |
+
array('value'=>'best', 'label'=>Mage::helper('adminhtml')->__('best')),
|
| 9 |
+
/*array('value'=>'min_rate', 'label'=>Mage::helper('adminhtml')->__('min_rate')),
|
| 10 |
+
array('value'=>'fastest', 'label'=>Mage::helper('adminhtml')->__('fastest')),
|
| 11 |
+
array('value'=>'asc', 'label'=>Mage::helper('adminhtml')->__('asc')),
|
| 12 |
+
array('value'=>'desc', 'label'=>Mage::helper('adminhtml')->__('desc')),*/
|
| 13 |
+
);
|
| 14 |
+
}
|
| 15 |
+
}
|
app/code/community/Shiphawk/Shipping/Model/Source/Received.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Model_Source_Received
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
array('value'=>0, 'label'=>Mage::helper('adminhtml')->__('customer')),
|
| 8 |
+
array('value'=>1, 'label'=>Mage::helper('adminhtml')->__('administrator')),
|
| 9 |
+
);
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ImportController.php
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
public function importAction() {
|
| 6 |
+
|
| 7 |
+
$fileimport = Mage::getStoreConfig('carriers/shiphawk_shipping/file_import');
|
| 8 |
+
|
| 9 |
+
$urlpath = Mage::getBaseDir('var') . DS . 'shiphawk' . DS.'import' . DS . $fileimport;
|
| 10 |
+
|
| 11 |
+
$row = 1;
|
| 12 |
+
if (($handle = fopen($urlpath, "r")) !== FALSE) {
|
| 13 |
+
|
| 14 |
+
while (($data = fgetcsv($handle, 1000, ",", '"')) !== FALSE) {
|
| 15 |
+
if($row == 1){ $row++; continue; }
|
| 16 |
+
|
| 17 |
+
$row++;
|
| 18 |
+
try {
|
| 19 |
+
list($id, $shiphawk_origin_firstname, $shiphawk_origin_lastname, $shiphawk_origin_addressline1, $shiphawk_origin_addressline2, $shiphawk_origin_city, $shiphawk_origin_state,
|
| 20 |
+
$shiphawk_origin_zipcode, $shiphawk_origin_phonenum, $shiphawk_origin_location, $shiphawk_origin_email, $shiphawk_origin_title) = $data;
|
| 21 |
+
$answer = Mage::getModel('shiphawk_shipping/origins');
|
| 22 |
+
$answer->setShiphawkOriginFirstname($shiphawk_origin_firstname)
|
| 23 |
+
->setShiphawkOriginLastname($shiphawk_origin_lastname)
|
| 24 |
+
->setShiphawkOriginAddressline1($shiphawk_origin_addressline1)
|
| 25 |
+
->setShiphawkOriginAddressline2($shiphawk_origin_addressline2)
|
| 26 |
+
->setShiphawkOriginCity($shiphawk_origin_city)
|
| 27 |
+
->setShiphawkOriginState($shiphawk_origin_state)
|
| 28 |
+
->setShiphawkOriginZipcode($shiphawk_origin_zipcode)
|
| 29 |
+
->setShiphawkOriginPhonenum($shiphawk_origin_phonenum)
|
| 30 |
+
->setShiphawkOriginLocation($shiphawk_origin_location)
|
| 31 |
+
->setShiphawkOriginEmail($shiphawk_origin_email)
|
| 32 |
+
->setShiphawkOriginTitle($shiphawk_origin_title)
|
| 33 |
+
->save();
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
Mage::app()->getResponse()->setBody('Import successful');
|
| 37 |
+
|
| 38 |
+
} catch (Mage_Core_Exception $e) {
|
| 39 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 40 |
+
Mage::app()->getResponse()->setBody($e->getMessage());
|
| 41 |
+
} catch (Exception $e) {
|
| 42 |
+
Mage::logException($e);
|
| 43 |
+
|
| 44 |
+
Mage::app()->getResponse()->setBody($e->getMessage());
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
fclose($handle);
|
| 48 |
+
|
| 49 |
+
}else{
|
| 50 |
+
Mage::app()->getResponse()->setBody('Please upload file');
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
protected function _uploadImportFile() {
|
| 57 |
+
if ($data = $this->getRequest()->getPost()) {
|
| 58 |
+
|
| 59 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
| 60 |
+
try {
|
| 61 |
+
/* Starting upload */
|
| 62 |
+
$uploader = new Varien_File_Uploader('filename');
|
| 63 |
+
|
| 64 |
+
// Any extention would work
|
| 65 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
| 66 |
+
$uploader->setAllowRenameFiles(false);
|
| 67 |
+
|
| 68 |
+
// Set the file upload mode
|
| 69 |
+
// false -> get the file directly in the specified folder
|
| 70 |
+
// true -> get the file in the product like folders
|
| 71 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
| 72 |
+
$uploader->setFilesDispersion(false);
|
| 73 |
+
|
| 74 |
+
// We set media as the upload dir
|
| 75 |
+
$path = Mage::getBaseDir('media') . DS ;
|
| 76 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
| 77 |
+
|
| 78 |
+
} catch (Exception $e) {
|
| 79 |
+
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
//this way the name is saved in DB
|
| 83 |
+
$data['filename'] = $_FILES['filename']['name'];
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
app/code/community/Shiphawk/Shipping/controllers/Adminhtml/OriginsController.php
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Adminhtml_OriginsController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->_title($this->__('Shipping Origins'));
|
| 7 |
+
|
| 8 |
+
$this->loadLayout();
|
| 9 |
+
$this->_setActiveMenu('shiphawk_shipping');
|
| 10 |
+
$this->_addBreadcrumb(Mage::helper('shiphawk_shipping')->__('Shipping Origins'), Mage::helper('shiphawk_shipping')->__('Shipping Origins'));
|
| 11 |
+
$this->renderLayout();
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function newAction()
|
| 15 |
+
{
|
| 16 |
+
$this->_title($this->__('Add new Origins'));
|
| 17 |
+
$this->loadLayout();
|
| 18 |
+
$this->_setActiveMenu('shiphawk_shipping');
|
| 19 |
+
$this->_addBreadcrumb(Mage::helper('shiphawk_shipping')->__('Add new Origins'), Mage::helper('shiphawk_shipping')->__('Add new Origins'));
|
| 20 |
+
$this->renderLayout();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public function editAction()
|
| 24 |
+
{
|
| 25 |
+
$this->_title($this->__('Edit Origins'));
|
| 26 |
+
|
| 27 |
+
$this->loadLayout();
|
| 28 |
+
$this->_setActiveMenu('shiphawk_shipping');
|
| 29 |
+
$this->_addBreadcrumb(Mage::helper('shiphawk_shipping')->__('Edit Origins'), Mage::helper('shiphawk_shipping')->__('Edit Origins'));
|
| 30 |
+
$this->renderLayout();
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function deleteAction()
|
| 34 |
+
{
|
| 35 |
+
$tipId = $this->getRequest()->getParam('id', false);
|
| 36 |
+
|
| 37 |
+
try {
|
| 38 |
+
Mage::getModel('shiphawk_shipping/origins')->setId($tipId)->delete();
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
Mage::dispatchEvent('origins_delete_after', array('id'=>$tipId));
|
| 42 |
+
|
| 43 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('shiphawk_shipping')->__('origins successfully deleted'));
|
| 44 |
+
|
| 45 |
+
return $this->_redirect('*/*/');
|
| 46 |
+
} catch (Mage_Core_Exception $e){
|
| 47 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 48 |
+
} catch (Exception $e) {
|
| 49 |
+
Mage::logException($e);
|
| 50 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Somethings went wrong'));
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$this->_redirectReferer();
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
public function saveAction()
|
| 57 |
+
{
|
| 58 |
+
$data = $this->getRequest()->getPost();
|
| 59 |
+
|
| 60 |
+
foreach ($data as $key => $value)
|
| 61 |
+
{
|
| 62 |
+
if (is_array($value))
|
| 63 |
+
{
|
| 64 |
+
$data[$key] = implode(',',$this->getRequest()->getParam($key));
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
if (!empty($data)) {
|
| 69 |
+
try {
|
| 70 |
+
$origins = Mage::getModel('shiphawk_shipping/origins')
|
| 71 |
+
->setData($data)
|
| 72 |
+
->save();
|
| 73 |
+
|
| 74 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('shiphawk_shipping')->__('origins successfully saved'));
|
| 75 |
+
} catch (Mage_Core_Exception $e) {
|
| 76 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 77 |
+
} catch (Exception $e) {
|
| 78 |
+
Mage::logException($e);
|
| 79 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Somethings went wrong'));
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
return $this->_redirect('*/*/');
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
public function gridAction()
|
| 86 |
+
{
|
| 87 |
+
$this->loadLayout();
|
| 88 |
+
$this->getResponse()->setBody(
|
| 89 |
+
$this->getLayout()->createBlock('shiphawk_shipping/adminhtml_origins_grid')->toHtml()
|
| 90 |
+
);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
public function massDeleteAction()
|
| 94 |
+
{
|
| 95 |
+
$answersIds = $this->getRequest()->getParam('origins');
|
| 96 |
+
if(!is_array($answersIds)) {
|
| 97 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select origin(s).'));
|
| 98 |
+
} else {
|
| 99 |
+
try {
|
| 100 |
+
$answer = Mage::getModel('shiphawk_shipping/origins');
|
| 101 |
+
foreach ($answersIds as $answerId) {
|
| 102 |
+
$answer
|
| 103 |
+
->load($answerId)
|
| 104 |
+
->delete();
|
| 105 |
+
|
| 106 |
+
Mage::dispatchEvent('origins_delete_after', array('id'=>$answerId));
|
| 107 |
+
}
|
| 108 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 109 |
+
Mage::helper('adminhtml')->__('Total of %d record(s) were deleted.', count($answersIds))
|
| 110 |
+
);
|
| 111 |
+
} catch (Exception $e) {
|
| 112 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
$this->_redirect('*/*/index');
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
public function exportAction() {
|
| 120 |
+
/**
|
| 121 |
+
* Returns generated CSV file
|
| 122 |
+
*/
|
| 123 |
+
|
| 124 |
+
$filename = 'origins.csv';
|
| 125 |
+
$content = Mage::helper('shiphawk_shipping/origin')->generateQuestList();
|
| 126 |
+
|
| 127 |
+
$this->_prepareDownloadResponse($filename, $content);
|
| 128 |
+
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
}
|
app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ShipmentController.php
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Get rate and book shipments order, Manual booking
|
| 6 |
+
*
|
| 7 |
+
*
|
| 8 |
+
* @return null
|
| 9 |
+
*/
|
| 10 |
+
public function saveshipmentAction()
|
| 11 |
+
{
|
| 12 |
+
$orderId= $this->getRequest()->getParam('order_id');
|
| 13 |
+
$sUrl = $this->getRequest()->getParam('sUrl');
|
| 14 |
+
$response = array();
|
| 15 |
+
$response['error_text'] = null;
|
| 16 |
+
$response['order_id'] = null;
|
| 17 |
+
$response['sUrl'] = null;
|
| 18 |
+
|
| 19 |
+
try {
|
| 20 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 21 |
+
|
| 22 |
+
$shLocationType = $order->getShiphawkLocationType();
|
| 23 |
+
|
| 24 |
+
$shiphawk_rate_data = unserialize($order->getData('shiphawk_book_id')); //rate id
|
| 25 |
+
|
| 26 |
+
$api = Mage::getModel('shiphawk_shipping/api');
|
| 27 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 28 |
+
|
| 29 |
+
$items = Mage::getModel('shiphawk_shipping/carrier')->getShiphawkItems($order);
|
| 30 |
+
|
| 31 |
+
$grouped_items_by_zip = Mage::getModel('shiphawk_shipping/carrier')->getGroupedItemsByZip($items);
|
| 32 |
+
|
| 33 |
+
$shipping_description = $order->getShippingDescription();
|
| 34 |
+
|
| 35 |
+
$is_multi_zip = (count($grouped_items_by_zip) > 1) ? true : false;
|
| 36 |
+
$is_admin = $helper->checkIsAdmin();
|
| 37 |
+
|
| 38 |
+
$rate_filter = Mage::helper('shiphawk_shipping')->getRateFilter($is_admin, $order);
|
| 39 |
+
|
| 40 |
+
//$carrier_type = Mage::getStoreConfig('carriers/shiphawk_shipping/carrier_type');
|
| 41 |
+
|
| 42 |
+
if($is_multi_zip) {
|
| 43 |
+
$rate_filter = 'best';
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
$accessories = array();
|
| 47 |
+
|
| 48 |
+
foreach($shiphawk_rate_data as $rate_id=>$products_ids) {
|
| 49 |
+
$is_rate = false;
|
| 50 |
+
|
| 51 |
+
if(($is_multi_zip)||($rate_filter == 'best')) {
|
| 52 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 53 |
+
$from_zip = $products_ids['items'][0]['zip'];
|
| 54 |
+
$location_type = $products_ids['items'][0]['location_type'];
|
| 55 |
+
|
| 56 |
+
$carrier_type = $products_ids['carrier_type'];
|
| 57 |
+
$self_pack = $products_ids['self_pack'];
|
| 58 |
+
|
| 59 |
+
$responceObject = $api->getShiphawkRate($from_zip, $products_ids['to_zip'], $products_ids['items'], $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 60 |
+
// get only one method for each group of product
|
| 61 |
+
if(property_exists($responceObject, 'error')) {
|
| 62 |
+
if($responceObject->error) {
|
| 63 |
+
$shiphawk_error = $responceObject->error;
|
| 64 |
+
$helper->shlog('ShipHawk response: '. $shiphawk_error);
|
| 65 |
+
$helper->sendErrorMessageToShipHawk($shiphawk_error);
|
| 66 |
+
$is_rate = false;
|
| 67 |
+
}
|
| 68 |
+
}else{
|
| 69 |
+
$rate_id = $responceObject->id;
|
| 70 |
+
$accessories = $responceObject->shipping->carrier_accessorial;
|
| 71 |
+
$is_rate = true;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
}else{
|
| 75 |
+
/* get zipcode and location type from first item in grouped by origin (zipcode) products */
|
| 76 |
+
$from_zip = $products_ids['items'][0]['zip'];
|
| 77 |
+
$location_type = $products_ids['items'][0]['location_type'];
|
| 78 |
+
|
| 79 |
+
$carrier_type = $products_ids['carrier_type'];
|
| 80 |
+
|
| 81 |
+
$self_pack = $products_ids['self_pack'];
|
| 82 |
+
|
| 83 |
+
$responceObject = $api->getShiphawkRate($from_zip, $products_ids['to_zip'], $products_ids['items'], $rate_filter, $carrier_type, $location_type, $shLocationType);
|
| 84 |
+
|
| 85 |
+
$accessoriesPriceData = json_decode($order->getData('shiphawk_shipping_accessories'));
|
| 86 |
+
$accessoriesPrice = Mage::helper('shiphawk_shipping')->getAccessoriesPrice($accessoriesPriceData);
|
| 87 |
+
// ShipHawk Shipping Amount includes accessories price
|
| 88 |
+
$original_shipping_price = floatval($order->getShiphawkShippingAmount() - $accessoriesPrice);
|
| 89 |
+
foreach ($responceObject as $responce) {
|
| 90 |
+
|
| 91 |
+
// shipping rate price from new response
|
| 92 |
+
$shipping_price = $helper->getShipHawkPrice($responce, $self_pack);
|
| 93 |
+
if(round($original_shipping_price,3) == round($shipping_price,3)) {
|
| 94 |
+
$rate_id = $responce->id;
|
| 95 |
+
$accessories = $responce->shipping->carrier_accessorial;
|
| 96 |
+
$is_rate = true;
|
| 97 |
+
break;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if($is_rate == true) {
|
| 103 |
+
// add book
|
| 104 |
+
$track_data = $api->toBook($order, $rate_id, $products_ids, $accessories, false, $self_pack);
|
| 105 |
+
|
| 106 |
+
if (property_exists($track_data, 'error')) {
|
| 107 |
+
Mage::getSingleton('core/session')->addError("The booking was not successful, please try again later.");
|
| 108 |
+
$helper->shlog('ShipHawk response: '.$track_data->error);
|
| 109 |
+
$helper->sendErrorMessageToShipHawk($track_data->error);
|
| 110 |
+
continue;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
$shipment = $api->_initShipHawkShipment($order,$products_ids);
|
| 114 |
+
$shipment->register();
|
| 115 |
+
$api->_saveShiphawkShipment($shipment, $products_ids['name'], $products_ids['price']);
|
| 116 |
+
|
| 117 |
+
// add track
|
| 118 |
+
if($track_data->details->id) {
|
| 119 |
+
$api->addTrackNumber($shipment, $track_data->details->id);
|
| 120 |
+
|
| 121 |
+
$api->subscribeToTrackingInfo($shipment->getId());
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
$shipmentCreatedMessage = $this->__('The shipment has been created.');
|
| 125 |
+
$this->_getSession()->addSuccess($shipmentCreatedMessage);
|
| 126 |
+
}else{
|
| 127 |
+
//Mage::getSingleton('core/session')->addError("Unfortunately the method that was chosen by a customer during checkout is currently unavailable. Please contact ShipHawk's customer service to manually book this shipment.");
|
| 128 |
+
Mage::getSingleton('core/session')->setErrorPriceText("Sorry, we can't find the rate identical to the one that this order has. Please select another rate:");
|
| 129 |
+
|
| 130 |
+
$response['error_text'] = "Sorry, we can't find the rate identical to the one that this order has. Please select another rate:";
|
| 131 |
+
$response['order_id'] = $orderId;
|
| 132 |
+
$response['sUrl'] = $sUrl;
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
} catch (Mage_Core_Exception $e) {
|
| 137 |
+
$this->_getSession()->addError($e->getMessage());
|
| 138 |
+
//$this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
| 139 |
+
} catch (Exception $e) {
|
| 140 |
+
Mage::logException($e);
|
| 141 |
+
$this->_getSession()->addError($this->__('Cannot save shipment.'));
|
| 142 |
+
// $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
//$this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
| 146 |
+
$this->getResponse()->setBody(json_encode($response));
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/* Show PopUp for new ShipHawk Shipment */
|
| 150 |
+
public function newshipmentAction()
|
| 151 |
+
{
|
| 152 |
+
$orderId= $this->getRequest()->getParam('order_id');
|
| 153 |
+
|
| 154 |
+
try {
|
| 155 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 156 |
+
|
| 157 |
+
$this->loadLayout();
|
| 158 |
+
|
| 159 |
+
$this->getLayout()->getBlock('content')->append($this->getLayout()->createBlock('shiphawk_shipping/adminhtml_shipment')->setTemplate('shiphawk/shipment.phtml')->setOrder($order));
|
| 160 |
+
|
| 161 |
+
$this->renderLayout();
|
| 162 |
+
|
| 163 |
+
} catch (Mage_Core_Exception $e) {
|
| 164 |
+
$this->_getSession()->addError($e->getMessage());
|
| 165 |
+
|
| 166 |
+
} catch (Exception $e) {
|
| 167 |
+
Mage::logException($e);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Shipment booking in admin for order with no Shiphawk method or for missing rate shipments
|
| 174 |
+
*/
|
| 175 |
+
public function newbookAction() {
|
| 176 |
+
|
| 177 |
+
$params = $this->getRequest()->getParams();
|
| 178 |
+
|
| 179 |
+
$orderId = $params['order_id'];
|
| 180 |
+
$shiphawk_rate_id = $params['shipping_method'];
|
| 181 |
+
$is_multi = $params['is_multi'];
|
| 182 |
+
if(array_key_exists('multi_price', $params) ) {
|
| 183 |
+
$multi_price = $params['multi_price'];
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
$shipmentCreatedMessage = $this->__('Something went wrong');
|
| 187 |
+
|
| 188 |
+
try {
|
| 189 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 190 |
+
$shiphawk_rate_data = Mage::getSingleton('core/session')->getData('new_shiphawk_book_id', true);
|
| 191 |
+
$api = Mage::getModel('shiphawk_shipping/api');
|
| 192 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 193 |
+
|
| 194 |
+
foreach($shiphawk_rate_data as $rate_id=>$products_ids) {
|
| 195 |
+
|
| 196 |
+
// add book
|
| 197 |
+
if($is_multi == 0) {
|
| 198 |
+
if($shiphawk_rate_id == $rate_id) {
|
| 199 |
+
$self_pack = $products_ids['self_pack'];
|
| 200 |
+
$accessories = array();
|
| 201 |
+
/* For accessories */
|
| 202 |
+
$accessoriesPrice = 0;
|
| 203 |
+
$accessoriesData = array();
|
| 204 |
+
if(array_key_exists('accessories', $params)) {
|
| 205 |
+
$accessories = $params['accessories'];
|
| 206 |
+
if(!empty($accessories)) {
|
| 207 |
+
foreach($accessories as $typeName => $type) {
|
| 208 |
+
foreach($type as $name => $values) {
|
| 209 |
+
foreach($values as $key => $value) {
|
| 210 |
+
$accessoriesData[$typeName][$key]['name'] = $name;
|
| 211 |
+
$accessoriesData[$typeName][$key]['value'] = (float)$value;
|
| 212 |
+
|
| 213 |
+
$accessoriesPrice += (float)$value;
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
$track_data = $api->toBook($order,$rate_id,$products_ids, $accessoriesData, true, $self_pack, true);
|
| 221 |
+
|
| 222 |
+
if (property_exists($track_data, 'error')) {
|
| 223 |
+
Mage::getSingleton('core/session')->addError("The booking was not successful, please try again later.");
|
| 224 |
+
$helper->shlog('ShipHawk response: '.$track_data->error);
|
| 225 |
+
continue;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
$order->setShiphawkShippingAmount($products_ids['price'] + $accessoriesPrice); //resave shipping price
|
| 229 |
+
$order->setShiphawkShippingAccessories(json_encode($accessoriesData)); // resave accessories
|
| 230 |
+
$order->save();
|
| 231 |
+
|
| 232 |
+
$shipment = $api->_initShipHawkShipment($order,$products_ids);
|
| 233 |
+
$shipment->register();
|
| 234 |
+
$api->_saveShiphawkShipment($shipment, $products_ids['name'], $products_ids['price']);
|
| 235 |
+
|
| 236 |
+
// add track
|
| 237 |
+
$track_number = $track_data->details->id;
|
| 238 |
+
|
| 239 |
+
$api->addTrackNumber($shipment, $track_number);
|
| 240 |
+
$api->subscribeToTrackingInfo($shipment->getId());
|
| 241 |
+
|
| 242 |
+
$shipmentCreatedMessage = $this->__('The shipment has been created.');
|
| 243 |
+
$this->_getSession()->addSuccess($shipmentCreatedMessage);
|
| 244 |
+
}
|
| 245 |
+
}else{
|
| 246 |
+
$self_pack = $products_ids['self_pack'];
|
| 247 |
+
$accessories = array();
|
| 248 |
+
if(array_key_exists('accessories', $params)) {
|
| 249 |
+
$accessories = $params['accessories'];
|
| 250 |
+
}
|
| 251 |
+
$track_data = $api->toBook($order,$rate_id,$products_ids, $accessories, false, $self_pack);
|
| 252 |
+
|
| 253 |
+
if (property_exists($track_data, 'error')) {
|
| 254 |
+
Mage::getSingleton('core/session')->addError("The booking was not successful, please try again later.");
|
| 255 |
+
$helper->shlog('ShipHawk response: '.$track_data->error);
|
| 256 |
+
continue;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
$order->setShiphawkShippingAmount($multi_price);
|
| 260 |
+
$order->save();
|
| 261 |
+
|
| 262 |
+
$shipment = $api->_initShipHawkShipment($order,$products_ids);
|
| 263 |
+
$shipment->register();
|
| 264 |
+
$api->_saveShiphawkShipment($shipment, $products_ids['name'], $products_ids['price']);
|
| 265 |
+
|
| 266 |
+
// add track
|
| 267 |
+
$track_number = $track_data->details->id;
|
| 268 |
+
|
| 269 |
+
$api->addTrackNumber($shipment, $track_number);
|
| 270 |
+
$api->subscribeToTrackingInfo($shipment->getId());
|
| 271 |
+
|
| 272 |
+
$shipmentCreatedMessage = $this->__("The multi-origin shipment's has been created.");
|
| 273 |
+
$this->_getSession()->addSuccess($shipmentCreatedMessage);
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
} catch (Mage_Core_Exception $e) {
|
| 278 |
+
$this->_getSession()->addError($e->getMessage());
|
| 279 |
+
|
| 280 |
+
} catch (Exception $e) {
|
| 281 |
+
Mage::logException($e);
|
| 282 |
+
$this->_getSession()->addError($this->__('Cannot save shipment.'));
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
$this->getResponse()->setBody( json_encode($shipmentCreatedMessage) );
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* For set Shiphawk location type value to session
|
| 290 |
+
*
|
| 291 |
+
* @version 20150701
|
| 292 |
+
*/
|
| 293 |
+
public function setlocationtypeAction() {
|
| 294 |
+
$locationType = $this->getRequest()->getPost('location_type');
|
| 295 |
+
|
| 296 |
+
if (empty($locationType)) {
|
| 297 |
+
$this->getResponse()->setBody('Result: location type is empty.');
|
| 298 |
+
return;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
$locationType = $locationType != 'residential' && $locationType != 'commercial' ? 'residential' : $locationType;
|
| 302 |
+
|
| 303 |
+
Mage::getSingleton('checkout/session')->setData('shiphawk_location_type_shipping', $locationType);
|
| 304 |
+
|
| 305 |
+
$this->getResponse()->setBody('Result: ok.');
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
/**
|
| 309 |
+
* Set accessories price for Update Totals button in admin (New order view)
|
| 310 |
+
*
|
| 311 |
+
* @version 20150701
|
| 312 |
+
*/
|
| 313 |
+
public function setaccessoriespriceAction() {
|
| 314 |
+
$params = $this->getRequest()->getParams();
|
| 315 |
+
$accessories_price = $params['accessories_price'];
|
| 316 |
+
$shiphawk_override_cost = $params['shiphawk_override_cost'];
|
| 317 |
+
|
| 318 |
+
/*if (empty($accessories_price)) {
|
| 319 |
+
$this->getResponse()->setBody('accessories price is empty.');
|
| 320 |
+
return;
|
| 321 |
+
}*/
|
| 322 |
+
|
| 323 |
+
Mage::getSingleton('core/session')->unsetData('admin_accessories_price');
|
| 324 |
+
Mage::getSingleton('core/session')->unsetData('shiphawk_override_cost');
|
| 325 |
+
|
| 326 |
+
Mage::getSingleton('core/session')->setData('admin_accessories_price', $accessories_price);
|
| 327 |
+
Mage::getSingleton('core/session')->setData('shiphawk_override_cost', $shiphawk_override_cost);
|
| 328 |
+
|
| 329 |
+
//$this->getResponse()->setBody('Result: ok.');
|
| 330 |
+
}
|
| 331 |
+
}
|
app/code/community/Shiphawk/Shipping/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Shiphawk_Shipping_IndexController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function trackingAction() {
|
| 5 |
+
|
| 6 |
+
$api_key_from_url = $this->getRequest()->getParam('api_key');
|
| 7 |
+
$data_from_shiphawk = json_decode(file_get_contents('php://input'));
|
| 8 |
+
$api_key = Mage::helper('shiphawk_shipping')->getApiKey();
|
| 9 |
+
|
| 10 |
+
//curl -X POST -H Content-Type:application/json -d '{"event":"shipment.status_update","status":"in_transit","updated_at":"2015-01-14T10:43:16.702-08:00","shipment_id":1010226}' http://shiphawk.devigor.wdgtest.com/index.php/shiphawk/index/tracking?api_key=3331b35952ec7d99338a1cc5c496b55c
|
| 11 |
+
//curl -X POST -H Content-Type:application/json -d '{"event":"shipment.status_update","status":"in_transit","updated_at":"2015-01-14T10:43:16.702-08:00","shipment_id":1015967}' http://shiphawk.devigor.wdgtest.com/index.php/shiphawk/index/tracking?api_key=e1919f54fb93f63866f06049d6d45751
|
| 12 |
+
|
| 13 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 14 |
+
if($api_key_from_url == $api_key) {
|
| 15 |
+
try {
|
| 16 |
+
$data_from_shiphawk = (array) $data_from_shiphawk;
|
| 17 |
+
$track_number = $data_from_shiphawk['shipment_id'];
|
| 18 |
+
$shipment_track = Mage::getResourceModel('sales/order_shipment_track_collection')->addAttributeToFilter('track_number', $track_number)->getFirstItem();
|
| 19 |
+
|
| 20 |
+
$shipment = Mage::getModel('sales/order_shipment')->load($shipment_track->getParentId());
|
| 21 |
+
|
| 22 |
+
$helper->shlog($data_from_shiphawk, 'shiphawk-tracking.log');
|
| 23 |
+
|
| 24 |
+
$shipment_status_updates = Mage::getStoreConfig('carriers/shiphawk_shipping/shipment_status_updates');
|
| 25 |
+
$updates_tracking_url = Mage::getStoreConfig('carriers/shiphawk_shipping/updates_tracking_url');
|
| 26 |
+
$comment = '';
|
| 27 |
+
|
| 28 |
+
$crated_time = $this->convertDateTome($data_from_shiphawk['updated_at']);
|
| 29 |
+
|
| 30 |
+
if($data_from_shiphawk['event'] == 'shipment.status_update') {
|
| 31 |
+
switch ($data_from_shiphawk['status']) {
|
| 32 |
+
case 'in_transit':
|
| 33 |
+
$comment = "Shipment status changed to In Transit (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment is with the carrier and is in transit.";
|
| 34 |
+
break;
|
| 35 |
+
case 'confirmed':
|
| 36 |
+
$comment = "Shipment status changed to Confirmed (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment has been successfully confirmed.";
|
| 37 |
+
break;
|
| 38 |
+
case 'scheduled_for_pickup':
|
| 39 |
+
$comment = "Shipment status changed to Scheduled (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment has been scheduled for pickup.";
|
| 40 |
+
break;
|
| 41 |
+
case 'agent_prep':
|
| 42 |
+
$comment = "Shipment status changed to Agent Prep (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment is now being professionally prepared for carrier pickup.";
|
| 43 |
+
break;
|
| 44 |
+
case 'delivered':
|
| 45 |
+
$comment = "Shipment status changed to Delivered (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment has been delivered!";
|
| 46 |
+
break;
|
| 47 |
+
case 'cancelled':
|
| 48 |
+
$comment = "Shipment status changed to Cancelled (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment has been cancelled successfully.";
|
| 49 |
+
break;
|
| 50 |
+
case 'ready_for_carrier_pickup':
|
| 51 |
+
$comment = "Shipment status changed to Ready for Carrier Pickup (" . $crated_time['date'] . " at " . $crated_time['time'] . "). Your shipment has been successfully dispatched to the carrier.";
|
| 52 |
+
break;
|
| 53 |
+
default:
|
| 54 |
+
$comment = "Shipment status is ".$comment = "Shipment status is ";
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
$shipment->addComment($comment);
|
| 58 |
+
if($shipment_status_updates) {
|
| 59 |
+
$shipment->sendUpdateEmail(true, $comment);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
if($data_from_shiphawk['event'] == 'shipment.tracking_update') {
|
| 64 |
+
$comment = $data_from_shiphawk['updated_at'] . 'There is a tracking number available for your shipment - ' . $data_from_shiphawk['tracking_number'];
|
| 65 |
+
if ($data_from_shiphawk['tracking_url']) {
|
| 66 |
+
$comment .= ' <a href="' . $data_from_shiphawk['tracking_url'] . '" target="_blank">Click here to track.</a>';
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
$shipment->addComment($comment);
|
| 71 |
+
if($updates_tracking_url) {
|
| 72 |
+
$shipment->sendUpdateEmail(true, $comment);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
$shipment->save();
|
| 78 |
+
}catch (Mage_Core_Exception $e) {
|
| 79 |
+
Mage::logException($e);
|
| 80 |
+
} catch (Exception $e) {
|
| 81 |
+
Mage::logException($e);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
public function convertDateTome ($date_time) {
|
| 88 |
+
///2015-04-01T15:57:42Z
|
| 89 |
+
$result = array();
|
| 90 |
+
$t = explode('T', $date_time);
|
| 91 |
+
$result['date'] = date("m/d/y", strtotime($t[0]));
|
| 92 |
+
|
| 93 |
+
$result['time'] = date("g:i a", strtotime(substr($t[1], 0, -1)));
|
| 94 |
+
|
| 95 |
+
return $result;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/* suggest items type in product page */
|
| 99 |
+
public function searchAction() {
|
| 100 |
+
|
| 101 |
+
$search_tag = trim(strip_tags($this->getRequest()->getPost('search_tag')));
|
| 102 |
+
|
| 103 |
+
$api_key = Mage::helper('shiphawk_shipping')->getApiKey();
|
| 104 |
+
$api_url = Mage::helper('shiphawk_shipping')->getApiUrl();
|
| 105 |
+
|
| 106 |
+
$url_api = $api_url . 'items/search?q='.$search_tag.'&api_key='.$api_key;
|
| 107 |
+
|
| 108 |
+
$curl = curl_init();
|
| 109 |
+
|
| 110 |
+
curl_setopt_array($curl, array(
|
| 111 |
+
CURLOPT_RETURNTRANSFER => true,
|
| 112 |
+
CURLOPT_URL => $url_api,
|
| 113 |
+
CURLOPT_POST => false
|
| 114 |
+
));
|
| 115 |
+
|
| 116 |
+
$resp = curl_exec($curl);
|
| 117 |
+
$arr_res = json_decode($resp);
|
| 118 |
+
|
| 119 |
+
$responce_array = array();
|
| 120 |
+
$responce = array();
|
| 121 |
+
|
| 122 |
+
$helper = Mage::helper('shiphawk_shipping');
|
| 123 |
+
|
| 124 |
+
if(is_object($arr_res)) {
|
| 125 |
+
if(($arr_res->error)) {
|
| 126 |
+
$helper->shlog($arr_res->error);
|
| 127 |
+
$responce_html = '';
|
| 128 |
+
$responce['shiphawk_error'] = $arr_res->error;
|
| 129 |
+
}
|
| 130 |
+
}else{
|
| 131 |
+
foreach ((array) $arr_res as $el) {
|
| 132 |
+
$responce_array[$el->id] = $el->name.' ('.$el->category_name. ' - ' . $el->subcategory->name . ')';
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
$responce_html="<ul>";
|
| 136 |
+
|
| 137 |
+
foreach($responce_array as $key=>$value) {
|
| 138 |
+
$responce_html .='<li class="type_link" id='.$key.' onclick="setItemid(this)" >'.$value.'</li>';
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
$responce_html .="</ul>";
|
| 142 |
+
}
|
| 143 |
+
$responce['responce_html'] = $responce_html;
|
| 144 |
+
curl_close($curl);
|
| 145 |
+
|
| 146 |
+
$this->getResponse()->setBody( json_encode($responce) );
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
public function originsAction() {
|
| 150 |
+
$origin_id = trim(strip_tags($this->getRequest()->getPost('origin_id')));
|
| 151 |
+
|
| 152 |
+
$is_mass_action = $this->getRequest()->getPost('is_mass_action');
|
| 153 |
+
|
| 154 |
+
$origins_collection = $collection = Mage::getModel('shiphawk_shipping/origins')->getCollection();
|
| 155 |
+
|
| 156 |
+
$responce = '<select name="product[shiphawk_shipping_origins]" id="shiphawk_shipping_origins">';
|
| 157 |
+
|
| 158 |
+
if($is_mass_action == 1) {
|
| 159 |
+
$responce = '<select name="attributes[shiphawk_shipping_origins]" id="shiphawk_shipping_origins" disabled>';
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
$responce .= '<option value="">Primary origin</option>';
|
| 163 |
+
|
| 164 |
+
foreach($origins_collection as $origin) {
|
| 165 |
+
if ($origin_id != $origin->getId()) {
|
| 166 |
+
$responce .= '<option value="'.$origin->getId().'">'.$origin->getShiphawkOriginTitle(). '</option>';
|
| 167 |
+
}else{
|
| 168 |
+
$responce .= '<option selected value="'.$origin->getId().'">'.$origin->getShiphawkOriginTitle(). '</option>';
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
$responce .='</select>';
|
| 173 |
+
|
| 174 |
+
$this->getResponse()->setBody( json_encode($responce) );
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
public function getbolAction() {
|
| 178 |
+
|
| 179 |
+
$shipments_id = $this->getRequest()->getPost('shipments_id');
|
| 180 |
+
|
| 181 |
+
$responce_BOL = Mage::helper('shiphawk_shipping')->getBOLurl($shipments_id);
|
| 182 |
+
|
| 183 |
+
$responce = array();
|
| 184 |
+
|
| 185 |
+
if (property_exists($responce_BOL, 'url')) {
|
| 186 |
+
|
| 187 |
+
$path_to_save_bol_pdf = Mage::getBaseDir('media'). DS .'shiphawk'. DS .'bol';
|
| 188 |
+
$BOLpdf = $path_to_save_bol_pdf . DS . $shipments_id . '.pdf';
|
| 189 |
+
|
| 190 |
+
if (file_get_contents($BOLpdf)) {
|
| 191 |
+
$responce['bol_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'media' . DS . 'shiphawk'. DS .'bol' . DS . $shipments_id . '.pdf';
|
| 192 |
+
$this->getResponse()->setBody( json_encode($responce) );
|
| 193 |
+
}else{
|
| 194 |
+
|
| 195 |
+
file_put_contents($BOLpdf, file_get_contents($responce_BOL->url));
|
| 196 |
+
|
| 197 |
+
$responce['bol_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'media' . DS . 'shiphawk'. DS .'bol' . DS . $shipments_id . '.pdf';
|
| 198 |
+
|
| 199 |
+
$this->getResponse()->setBody( json_encode($responce) );
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
}else{
|
| 203 |
+
if (property_exists($responce_BOL, 'error')){
|
| 204 |
+
$responce['shiphawk_error'] = $responce_BOL->error;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
$this->getResponse()->setBody( json_encode($responce) );
|
| 208 |
+
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
}
|
| 212 |
+
}
|
app/code/community/Shiphawk/Shipping/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<menu>
|
| 4 |
+
<shiphawk_shipping translate="title" module="shiphawk_shipping">
|
| 5 |
+
<title>Shiphawk Shipping Origins</title>
|
| 6 |
+
<sort_order>55</sort_order>
|
| 7 |
+
<children>
|
| 8 |
+
<origins module="shiphawk_shipping">
|
| 9 |
+
<title>Manage Shipping Origins</title>
|
| 10 |
+
<sort_order>30</sort_order>
|
| 11 |
+
<action>adminhtml/origins</action>
|
| 12 |
+
</origins>
|
| 13 |
+
</children>
|
| 14 |
+
</shiphawk_shipping>
|
| 15 |
+
</menu>
|
| 16 |
+
</config>
|
app/code/community/Shiphawk/Shipping/etc/config.xml
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Shiphawk_Shipping>
|
| 5 |
+
<version>1.1.12</version>
|
| 6 |
+
</Shiphawk_Shipping>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<checkout>
|
| 11 |
+
<rewrite>
|
| 12 |
+
<cart>Shiphawk_Checkout_Model_Cart</cart>
|
| 13 |
+
</rewrite>
|
| 14 |
+
</checkout>
|
| 15 |
+
<shiphawk_shipping>
|
| 16 |
+
<class>Shiphawk_Shipping_Model</class>
|
| 17 |
+
<resourceModel>shiphawk_resource</resourceModel>
|
| 18 |
+
</shiphawk_shipping>
|
| 19 |
+
<shiphawk_resource>
|
| 20 |
+
<class>Shiphawk_Shipping_Model_Resource</class>
|
| 21 |
+
<entities>
|
| 22 |
+
<origins>
|
| 23 |
+
<table>shiphawk_origins</table>
|
| 24 |
+
</origins>
|
| 25 |
+
</entities>
|
| 26 |
+
</shiphawk_resource>
|
| 27 |
+
</models>
|
| 28 |
+
<blocks>
|
| 29 |
+
<shiphawk_shipping>
|
| 30 |
+
<class>Shiphawk_Shipping_Block</class>
|
| 31 |
+
</shiphawk_shipping>
|
| 32 |
+
<adminhtml>
|
| 33 |
+
<rewrite>
|
| 34 |
+
<sales_order_view>Shiphawk_Shipping_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
| 35 |
+
<sales_order_shipment_view>Shiphawk_Shipping_Block_Adminhtml_Sales_Order_Shipment_View</sales_order_shipment_view>
|
| 36 |
+
</rewrite>
|
| 37 |
+
</adminhtml>
|
| 38 |
+
<shipping>
|
| 39 |
+
<rewrite>
|
| 40 |
+
<tracking_popup>Shiphawk_Shipping_Block_Shipping_Tracking_Popup</tracking_popup>
|
| 41 |
+
</rewrite>
|
| 42 |
+
</shipping>
|
| 43 |
+
</blocks>
|
| 44 |
+
<resources>
|
| 45 |
+
<shiphawk_setup>
|
| 46 |
+
<setup>
|
| 47 |
+
<module>Shiphawk_Shipping</module>
|
| 48 |
+
</setup>
|
| 49 |
+
<connection>
|
| 50 |
+
<use>core_setup</use>
|
| 51 |
+
</connection>
|
| 52 |
+
</shiphawk_setup>
|
| 53 |
+
</resources>
|
| 54 |
+
<helpers>
|
| 55 |
+
<shiphawk_shipping>
|
| 56 |
+
<class>Shiphawk_Shipping_Helper</class>
|
| 57 |
+
</shiphawk_shipping>
|
| 58 |
+
</helpers>
|
| 59 |
+
<events>
|
| 60 |
+
<sales_order_place_after>
|
| 61 |
+
<observers>
|
| 62 |
+
<shiphawk_shipping_order_place>
|
| 63 |
+
<type>singleton</type>
|
| 64 |
+
<class>shiphawk_shipping/observer</class>
|
| 65 |
+
<method>salesOrderPlaceAfter</method>
|
| 66 |
+
</shiphawk_shipping_order_place>
|
| 67 |
+
</observers>
|
| 68 |
+
</sales_order_place_after>
|
| 69 |
+
<sales_quote_address_collect_totals_after>
|
| 70 |
+
<observers>
|
| 71 |
+
<shiphawk_recalculation_totals>
|
| 72 |
+
<type>singleton</type>
|
| 73 |
+
<class>shiphawk_shipping/observer</class>
|
| 74 |
+
<method>recalculationTotals</method>
|
| 75 |
+
</shiphawk_recalculation_totals>
|
| 76 |
+
</observers>
|
| 77 |
+
</sales_quote_address_collect_totals_after>
|
| 78 |
+
<checkout_controller_onepage_save_shipping_method>
|
| 79 |
+
<observers>
|
| 80 |
+
<shiphawk_onepage_save_shipping_method>
|
| 81 |
+
<type>singleton</type>
|
| 82 |
+
<class>shiphawk_shipping/observer</class>
|
| 83 |
+
<method>setAccessories</method>
|
| 84 |
+
</shiphawk_onepage_save_shipping_method>
|
| 85 |
+
</observers>
|
| 86 |
+
</checkout_controller_onepage_save_shipping_method>
|
| 87 |
+
<checkout_type_onepage_save_order>
|
| 88 |
+
<observers>
|
| 89 |
+
<shiphawk_recalculation_totals>
|
| 90 |
+
<type>singleton</type>
|
| 91 |
+
<class>shiphawk_shipping/observer</class>
|
| 92 |
+
<method>saveAccessoriesInOrder</method>
|
| 93 |
+
</shiphawk_recalculation_totals>
|
| 94 |
+
</observers>
|
| 95 |
+
</checkout_type_onepage_save_order>
|
| 96 |
+
<sales_quote_collect_totals_after>
|
| 97 |
+
<observers>
|
| 98 |
+
<show_shiphawk_rate_error>
|
| 99 |
+
<type>singleton</type>
|
| 100 |
+
<class>shiphawk_shipping/observer</class>
|
| 101 |
+
<method>showShiphawkRateError</method>
|
| 102 |
+
</show_shiphawk_rate_error>
|
| 103 |
+
</observers>
|
| 104 |
+
</sales_quote_collect_totals_after>
|
| 105 |
+
<checkout_controller_onepage_save_shipping_method>
|
| 106 |
+
<observers>
|
| 107 |
+
<show_shiphawk_rate_error_controller>
|
| 108 |
+
<type>singleton</type>
|
| 109 |
+
<class>shiphawk_shipping/observer</class>
|
| 110 |
+
<method>showShiphawkRateError</method>
|
| 111 |
+
</show_shiphawk_rate_error_controller>
|
| 112 |
+
</observers>
|
| 113 |
+
</checkout_controller_onepage_save_shipping_method>
|
| 114 |
+
<sales_quote_address_collect_totals_after>
|
| 115 |
+
<observers>
|
| 116 |
+
<shiphawk_addaccessries_totals>
|
| 117 |
+
<type>singleton</type>
|
| 118 |
+
<class>shiphawk_shipping/observer</class>
|
| 119 |
+
<method>addAccessoriesToTotals</method>
|
| 120 |
+
</shiphawk_addaccessries_totals>
|
| 121 |
+
</observers>
|
| 122 |
+
</sales_quote_address_collect_totals_after>
|
| 123 |
+
</events>
|
| 124 |
+
<fieldsets>
|
| 125 |
+
<sales_convert_quote>
|
| 126 |
+
<shiphawk_api_id>
|
| 127 |
+
<to_order>*</to_order>
|
| 128 |
+
</shiphawk_api_id>
|
| 129 |
+
<shiphawk_shipping_accessories>
|
| 130 |
+
<to_order>*</to_order>
|
| 131 |
+
</shiphawk_shipping_accessories>
|
| 132 |
+
</sales_convert_quote>
|
| 133 |
+
<sales_convert_order>
|
| 134 |
+
<shiphawk_shipping_accessories>
|
| 135 |
+
<to_order>*</to_order>
|
| 136 |
+
</shiphawk_shipping_accessories>
|
| 137 |
+
</sales_convert_order>
|
| 138 |
+
<sales_convert_quote_item>
|
| 139 |
+
<shiphawk_api_id>
|
| 140 |
+
<to_order_item>*</to_order_item>
|
| 141 |
+
</shiphawk_api_id>
|
| 142 |
+
</sales_convert_quote_item>
|
| 143 |
+
</fieldsets>
|
| 144 |
+
<template>
|
| 145 |
+
<email>
|
| 146 |
+
<shiphawk_error_email module="shiphawk_shipping">
|
| 147 |
+
<label>ShipHawk email template</label>
|
| 148 |
+
<file>shiphawk_error_email.html</file>
|
| 149 |
+
<type>html</type>
|
| 150 |
+
</shiphawk_error_email>
|
| 151 |
+
</email>
|
| 152 |
+
</template>
|
| 153 |
+
</global>
|
| 154 |
+
<frontend>
|
| 155 |
+
<routers>
|
| 156 |
+
<Shiphawk_Shipping>
|
| 157 |
+
<use>standard</use>
|
| 158 |
+
<args>
|
| 159 |
+
<module>Shiphawk_Shipping</module>
|
| 160 |
+
<frontName>shiphawk</frontName>
|
| 161 |
+
</args>
|
| 162 |
+
</Shiphawk_Shipping>
|
| 163 |
+
</routers>
|
| 164 |
+
<layout>
|
| 165 |
+
<updates>
|
| 166 |
+
<shiphawk_shipping>
|
| 167 |
+
<file>shiphawk.xml</file>
|
| 168 |
+
</shiphawk_shipping>
|
| 169 |
+
</updates>
|
| 170 |
+
</layout>
|
| 171 |
+
</frontend>
|
| 172 |
+
<adminhtml>
|
| 173 |
+
<layout>
|
| 174 |
+
<updates>
|
| 175 |
+
<shiphawk_shipping>
|
| 176 |
+
<file>shiphawk.xml</file>
|
| 177 |
+
</shiphawk_shipping>
|
| 178 |
+
</updates>
|
| 179 |
+
</layout>
|
| 180 |
+
<events>
|
| 181 |
+
<core_block_abstract_to_html_before>
|
| 182 |
+
<observers>
|
| 183 |
+
<shiphawk_change_create_order_sipping_method_template>
|
| 184 |
+
<type>singleton</type>
|
| 185 |
+
<class>shiphawk_shipping/observer</class>
|
| 186 |
+
<method>changeSippingMethodTemplate</method>
|
| 187 |
+
</shiphawk_change_create_order_sipping_method_template>
|
| 188 |
+
</observers>
|
| 189 |
+
</core_block_abstract_to_html_before>
|
| 190 |
+
<sales_order_place_after>
|
| 191 |
+
<observers>
|
| 192 |
+
<shiphawk_override_shipping_cost>
|
| 193 |
+
<type>singleton</type>
|
| 194 |
+
<class>shiphawk_shipping/observer</class>
|
| 195 |
+
<method>overrideShippingCost</method>
|
| 196 |
+
</shiphawk_override_shipping_cost>
|
| 197 |
+
</observers>
|
| 198 |
+
</sales_order_place_after>
|
| 199 |
+
</events>
|
| 200 |
+
</adminhtml>
|
| 201 |
+
<admin>
|
| 202 |
+
<routers>
|
| 203 |
+
<adminhtml>
|
| 204 |
+
<args>
|
| 205 |
+
<modules>
|
| 206 |
+
<shiphawk_shipping before="Mage_Adminhtml">Shiphawk_Shipping_Adminhtml</shiphawk_shipping>
|
| 207 |
+
</modules>
|
| 208 |
+
</args>
|
| 209 |
+
</adminhtml>
|
| 210 |
+
</routers>
|
| 211 |
+
</admin>
|
| 212 |
+
<admin>
|
| 213 |
+
<routers>
|
| 214 |
+
<shiphawk_shipping>
|
| 215 |
+
<use>admin</use>
|
| 216 |
+
<args>
|
| 217 |
+
<module>Shiphawk_Shipping</module>
|
| 218 |
+
<frontName>adminshiphawk</frontName>
|
| 219 |
+
</args>
|
| 220 |
+
</shiphawk_shipping>
|
| 221 |
+
</routers>
|
| 222 |
+
</admin>
|
| 223 |
+
<default>
|
| 224 |
+
<carriers>
|
| 225 |
+
<shiphawk_shipping>
|
| 226 |
+
<active>1</active>
|
| 227 |
+
<hide_on_frontend>0</hide_on_frontend>
|
| 228 |
+
<updates_tracking_url>0</updates_tracking_url>
|
| 229 |
+
<shipment_status_updates>0</shipment_status_updates>
|
| 230 |
+
<calc_rate_on_cart_change>1</calc_rate_on_cart_change>
|
| 231 |
+
<enable_log>1</enable_log>
|
| 232 |
+
<sort_order>10</sort_order>
|
| 233 |
+
<model>shiphawk_shipping/carrier</model>
|
| 234 |
+
<item_is_packed>1</item_is_packed>
|
| 235 |
+
<sort_order>10</sort_order>
|
| 236 |
+
<sallowspecific>1</sallowspecific>
|
| 237 |
+
<gateway_url>https://shiphawk.com/api/v1/</gateway_url>
|
| 238 |
+
<charge_customer_for_packing>1</charge_customer_for_packing>
|
| 239 |
+
<opt_to_self_pack>0</opt_to_self_pack>
|
| 240 |
+
</shiphawk_shipping>
|
| 241 |
+
</carriers>
|
| 242 |
+
</default>
|
| 243 |
+
</config>
|
app/code/community/Shiphawk/Shipping/etc/system.xml
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<carriers>
|
| 5 |
+
<groups>
|
| 6 |
+
<shiphawk_shipping translate="label">
|
| 7 |
+
<label>ShipHawk</label>
|
| 8 |
+
<sort_order>2</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>0</show_in_website>
|
| 11 |
+
<show_in_store>0</show_in_store>
|
| 12 |
+
<fields>
|
| 13 |
+
<extensions translate="label">
|
| 14 |
+
<label>Installed aheadWorks Extensions</label>
|
| 15 |
+
<frontend_type>text</frontend_type>
|
| 16 |
+
<frontend_model>shiphawk_shipping/version</frontend_model>
|
| 17 |
+
<sort_order>10</sort_order>
|
| 18 |
+
<show_in_default>1</show_in_default>
|
| 19 |
+
<show_in_website>1</show_in_website>
|
| 20 |
+
<show_in_store>1</show_in_store>
|
| 21 |
+
</extensions>
|
| 22 |
+
<active translate="label">
|
| 23 |
+
<label>Enabled</label>
|
| 24 |
+
<frontend_type>select</frontend_type>
|
| 25 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 26 |
+
<sort_order>10</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
</active>
|
| 31 |
+
<hide_on_frontend translate="label">
|
| 32 |
+
<label>Hide on frontend?</label>
|
| 33 |
+
<frontend_type>select</frontend_type>
|
| 34 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 35 |
+
<sort_order>11</sort_order>
|
| 36 |
+
<show_in_default>1</show_in_default>
|
| 37 |
+
<show_in_website>1</show_in_website>
|
| 38 |
+
<show_in_store>1</show_in_store>
|
| 39 |
+
</hide_on_frontend>
|
| 40 |
+
<hide_accessories_on_frontend translate="label">
|
| 41 |
+
<label>Accessorials: Hide on frontend?</label>
|
| 42 |
+
<frontend_type>select</frontend_type>
|
| 43 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 44 |
+
<sort_order>12</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 |
+
</hide_accessories_on_frontend>
|
| 49 |
+
<enable_log translate="label">
|
| 50 |
+
<label>Debug Logging?</label>
|
| 51 |
+
<frontend_type>select</frontend_type>
|
| 52 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 53 |
+
<sort_order>13</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</enable_log>
|
| 58 |
+
<email_error_to_shiphawk translate="label">
|
| 59 |
+
<label>Email errors to ShipHawk?</label>
|
| 60 |
+
<frontend_type>select</frontend_type>
|
| 61 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 62 |
+
<sort_order>14</sort_order>
|
| 63 |
+
<show_in_default>1</show_in_default>
|
| 64 |
+
<show_in_website>1</show_in_website>
|
| 65 |
+
<show_in_store>1</show_in_store>
|
| 66 |
+
<depends><enable_log>1</enable_log></depends>
|
| 67 |
+
</email_error_to_shiphawk>
|
| 68 |
+
<shiphawk_error_message translate="label">
|
| 69 |
+
<label>Error message</label>
|
| 70 |
+
<comment>Error message for when a ShipHawk rate does not return</comment>
|
| 71 |
+
<frontend_type>text</frontend_type>
|
| 72 |
+
<sort_order>18</sort_order>
|
| 73 |
+
<show_in_default>1</show_in_default>
|
| 74 |
+
<show_in_website>1</show_in_website>
|
| 75 |
+
<show_in_store>1</show_in_store>
|
| 76 |
+
</shiphawk_error_message>
|
| 77 |
+
<calc_rate_on_cart_change translate="label">
|
| 78 |
+
<label>Calculate Rate on Cart Change</label>
|
| 79 |
+
<comment>Disabling this will decrease cart load time, but not provided updated shipping rates</comment>
|
| 80 |
+
<frontend_type>select</frontend_type>
|
| 81 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 82 |
+
<sort_order>19</sort_order>
|
| 83 |
+
<show_in_default>1</show_in_default>
|
| 84 |
+
<show_in_website>1</show_in_website>
|
| 85 |
+
<show_in_store>1</show_in_store>
|
| 86 |
+
</calc_rate_on_cart_change>
|
| 87 |
+
<api_key translate="label">
|
| 88 |
+
<label>Api Key</label>
|
| 89 |
+
<frontend_type>text</frontend_type>
|
| 90 |
+
<sort_order>20</sort_order>
|
| 91 |
+
<show_in_default>1</show_in_default>
|
| 92 |
+
<show_in_website>1</show_in_website>
|
| 93 |
+
<show_in_store>1</show_in_store>
|
| 94 |
+
</api_key>
|
| 95 |
+
<gateway_url translate="label">
|
| 96 |
+
<label>Gateway Mode</label>
|
| 97 |
+
<frontend_type>select</frontend_type>
|
| 98 |
+
<source_model>shiphawk_shipping/source_gateway</source_model>
|
| 99 |
+
<sort_order>21</sort_order>
|
| 100 |
+
<show_in_default>1</show_in_default>
|
| 101 |
+
<show_in_website>1</show_in_website>
|
| 102 |
+
<show_in_store>1</show_in_store>
|
| 103 |
+
</gateway_url>
|
| 104 |
+
<rate_filter translate="label">
|
| 105 |
+
<label>Rate Filter</label>
|
| 106 |
+
<frontend_type>select</frontend_type>
|
| 107 |
+
<source_model>shiphawk_shipping/source_ratefilter</source_model>
|
| 108 |
+
<sort_order>22</sort_order>
|
| 109 |
+
<show_in_default>1</show_in_default>
|
| 110 |
+
<show_in_website>1</show_in_website>
|
| 111 |
+
<show_in_store>1</show_in_store>
|
| 112 |
+
</rate_filter>
|
| 113 |
+
<admin_rate_filter translate="label">
|
| 114 |
+
<label>Admin panel rate filter</label>
|
| 115 |
+
<frontend_type>select</frontend_type>
|
| 116 |
+
<source_model>shiphawk_shipping/source_adminratefilter</source_model>
|
| 117 |
+
<sort_order>23</sort_order>
|
| 118 |
+
<show_in_default>1</show_in_default>
|
| 119 |
+
<show_in_website>1</show_in_website>
|
| 120 |
+
<show_in_store>1</show_in_store>
|
| 121 |
+
</admin_rate_filter>
|
| 122 |
+
<discount_percentage translate="label">
|
| 123 |
+
<label>Markup or Discount Percentage</label>
|
| 124 |
+
<frontend_type>text</frontend_type>
|
| 125 |
+
<sort_order>24</sort_order>
|
| 126 |
+
<show_in_default>1</show_in_default>
|
| 127 |
+
<show_in_website>1</show_in_website>
|
| 128 |
+
<show_in_store>1</show_in_store>
|
| 129 |
+
<comment>possible values from -100 to 100</comment>
|
| 130 |
+
</discount_percentage>
|
| 131 |
+
<discount_fixed translate="label">
|
| 132 |
+
<label>Markup or Discount Flat Amount</label>
|
| 133 |
+
<frontend_type>text</frontend_type>
|
| 134 |
+
<sort_order>25</sort_order>
|
| 135 |
+
<show_in_default>1</show_in_default>
|
| 136 |
+
<show_in_website>1</show_in_website>
|
| 137 |
+
<show_in_store>1</show_in_store>
|
| 138 |
+
<comment>possible values from -∞ to ∞</comment>
|
| 139 |
+
</discount_fixed>
|
| 140 |
+
<carrier_type translate="label">
|
| 141 |
+
<label>Carrier Type</label>
|
| 142 |
+
<frontend_type>multiselect</frontend_type>
|
| 143 |
+
<source_model>shiphawk_shipping/source_carriertype</source_model>
|
| 144 |
+
<sort_order>26</sort_order>
|
| 145 |
+
<show_in_default>1</show_in_default>
|
| 146 |
+
<show_in_website>1</show_in_website>
|
| 147 |
+
<show_in_store>1</show_in_store>
|
| 148 |
+
</carrier_type>
|
| 149 |
+
<free_method>
|
| 150 |
+
<label>Free Shipping Method</label>
|
| 151 |
+
<frontend_type>select</frontend_type>
|
| 152 |
+
<source_model>shiphawk_shipping/source_freeshipping</source_model>
|
| 153 |
+
<sort_order>27</sort_order>
|
| 154 |
+
<show_in_default>1</show_in_default>
|
| 155 |
+
<show_in_website>1</show_in_website>
|
| 156 |
+
<show_in_store>1</show_in_store>
|
| 157 |
+
</free_method>
|
| 158 |
+
<item_is_packed translate="label">
|
| 159 |
+
<label>Default packing setting</label>
|
| 160 |
+
<frontend_type>select</frontend_type>
|
| 161 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 162 |
+
<sort_order>40</sort_order>
|
| 163 |
+
<show_in_default>1</show_in_default>
|
| 164 |
+
<show_in_website>1</show_in_website>
|
| 165 |
+
<show_in_store>1</show_in_store>
|
| 166 |
+
</item_is_packed>
|
| 167 |
+
<opt_to_self_pack translate="label">
|
| 168 |
+
<label>Opt to Self Pack</label>
|
| 169 |
+
<frontend_type>select</frontend_type>
|
| 170 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 171 |
+
<sort_order>41</sort_order>
|
| 172 |
+
<show_in_default>1</show_in_default>
|
| 173 |
+
<show_in_website>1</show_in_website>
|
| 174 |
+
<show_in_store>1</show_in_store>
|
| 175 |
+
</opt_to_self_pack>
|
| 176 |
+
<charge_customer_for_packing translate="label">
|
| 177 |
+
<label>Charge customer for packing</label>
|
| 178 |
+
<frontend_type>select</frontend_type>
|
| 179 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 180 |
+
<sort_order>42</sort_order>
|
| 181 |
+
<show_in_default>1</show_in_default>
|
| 182 |
+
<show_in_website>1</show_in_website>
|
| 183 |
+
<show_in_store>1</show_in_store>
|
| 184 |
+
<comment>This option works only when Opt to Self Pack set to Yes.</comment>
|
| 185 |
+
<depends><opt_to_self_pack>1</opt_to_self_pack></depends>
|
| 186 |
+
</charge_customer_for_packing>
|
| 187 |
+
<shiphawk_custom_packing_price translate="label">
|
| 188 |
+
<label>Custom Packing Prices?</label>
|
| 189 |
+
<frontend_type>select</frontend_type>
|
| 190 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 191 |
+
<sort_order>43</sort_order>
|
| 192 |
+
<show_in_default>1</show_in_default>
|
| 193 |
+
<show_in_website>1</show_in_website>
|
| 194 |
+
<show_in_store>1</show_in_store>
|
| 195 |
+
</shiphawk_custom_packing_price>
|
| 196 |
+
<book_shipment translate="label">
|
| 197 |
+
<label>Manual book shipment</label>
|
| 198 |
+
<frontend_type>select</frontend_type>
|
| 199 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 200 |
+
<sort_order>61</sort_order>
|
| 201 |
+
<show_in_default>1</show_in_default>
|
| 202 |
+
<show_in_website>1</show_in_website>
|
| 203 |
+
<show_in_store>1</show_in_store>
|
| 204 |
+
</book_shipment>
|
| 205 |
+
<order_received translate="label">
|
| 206 |
+
<label>Send order receipts to:</label>
|
| 207 |
+
<frontend_type>select</frontend_type>
|
| 208 |
+
<source_model>shiphawk_shipping/source_received</source_model>
|
| 209 |
+
<sort_order>62</sort_order>
|
| 210 |
+
<show_in_default>1</show_in_default>
|
| 211 |
+
<show_in_website>1</show_in_website>
|
| 212 |
+
<show_in_store>1</show_in_store>
|
| 213 |
+
</order_received>
|
| 214 |
+
<administrator_email translate="label">
|
| 215 |
+
<label>Administrator Email</label>
|
| 216 |
+
<frontend_type>text</frontend_type>
|
| 217 |
+
<sort_order>63</sort_order>
|
| 218 |
+
<show_in_default>1</show_in_default>
|
| 219 |
+
<show_in_website>1</show_in_website>
|
| 220 |
+
<show_in_store>1</show_in_store>
|
| 221 |
+
</administrator_email>
|
| 222 |
+
<shipment_status_updates translate="label">
|
| 223 |
+
<label>Email status updates to customer?</label>
|
| 224 |
+
<frontend_type>select</frontend_type>
|
| 225 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 226 |
+
<comment>There can be many updates for each shipment</comment>
|
| 227 |
+
<sort_order>64</sort_order>
|
| 228 |
+
<show_in_default>1</show_in_default>
|
| 229 |
+
<show_in_website>1</show_in_website>
|
| 230 |
+
<show_in_store>1</show_in_store>
|
| 231 |
+
</shipment_status_updates>
|
| 232 |
+
<updates_tracking_url translate="label">
|
| 233 |
+
<label>Email tracking URL to customer?</label>
|
| 234 |
+
<frontend_type>select</frontend_type>
|
| 235 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 236 |
+
<sort_order>65</sort_order>
|
| 237 |
+
<show_in_default>1</show_in_default>
|
| 238 |
+
<show_in_website>1</show_in_website>
|
| 239 |
+
<show_in_store>1</show_in_store>
|
| 240 |
+
</updates_tracking_url>
|
| 241 |
+
<sallowspecific translate="label">
|
| 242 |
+
<label>Available for specific countries only</label>
|
| 243 |
+
<frontend_type>select</frontend_type>
|
| 244 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
| 245 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
| 246 |
+
<sort_order>70</sort_order>
|
| 247 |
+
<show_in_default>1</show_in_default>
|
| 248 |
+
<show_in_website>1</show_in_website>
|
| 249 |
+
<show_in_store>1</show_in_store>
|
| 250 |
+
</sallowspecific>
|
| 251 |
+
<specificcountry translate="label">
|
| 252 |
+
<label>Ship to Specific Countries</label>
|
| 253 |
+
<frontend_type>multiselect</frontend_type>
|
| 254 |
+
<sort_order>71</sort_order>
|
| 255 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 256 |
+
<show_in_default>1</show_in_default>
|
| 257 |
+
<show_in_website>1</show_in_website>
|
| 258 |
+
<show_in_store>1</show_in_store>
|
| 259 |
+
<can_be_empty>1</can_be_empty>
|
| 260 |
+
</specificcountry>
|
| 261 |
+
<origin_first_name translate="label">
|
| 262 |
+
<label>Origin First Name</label>
|
| 263 |
+
<frontend_type>text</frontend_type>
|
| 264 |
+
<sort_order>80</sort_order>
|
| 265 |
+
<show_in_default>1</show_in_default>
|
| 266 |
+
<show_in_website>1</show_in_website>
|
| 267 |
+
<show_in_store>1</show_in_store>
|
| 268 |
+
</origin_first_name>
|
| 269 |
+
<origin_last_name translate="label">
|
| 270 |
+
<label>Origin Last Name</label>
|
| 271 |
+
<frontend_type>text</frontend_type>
|
| 272 |
+
<sort_order>81</sort_order>
|
| 273 |
+
<show_in_default>1</show_in_default>
|
| 274 |
+
<show_in_website>1</show_in_website>
|
| 275 |
+
<show_in_store>1</show_in_store>
|
| 276 |
+
</origin_last_name>
|
| 277 |
+
<origin_address translate="label">
|
| 278 |
+
<label>Origin Address</label>
|
| 279 |
+
<frontend_type>text</frontend_type>
|
| 280 |
+
<sort_order>82</sort_order>
|
| 281 |
+
<show_in_default>1</show_in_default>
|
| 282 |
+
<show_in_website>1</show_in_website>
|
| 283 |
+
<show_in_store>1</show_in_store>
|
| 284 |
+
</origin_address>
|
| 285 |
+
<origin_address2 translate="label">
|
| 286 |
+
<label>Origin Address 2</label>
|
| 287 |
+
<frontend_type>text</frontend_type>
|
| 288 |
+
<sort_order>83</sort_order>
|
| 289 |
+
<show_in_default>1</show_in_default>
|
| 290 |
+
<show_in_website>1</show_in_website>
|
| 291 |
+
<show_in_store>1</show_in_store>
|
| 292 |
+
</origin_address2>
|
| 293 |
+
<origin_city translate="label">
|
| 294 |
+
<label>Origin City</label>
|
| 295 |
+
<frontend_type>text</frontend_type>
|
| 296 |
+
<sort_order>84</sort_order>
|
| 297 |
+
<show_in_default>1</show_in_default>
|
| 298 |
+
<show_in_website>1</show_in_website>
|
| 299 |
+
<show_in_store>1</show_in_store>
|
| 300 |
+
</origin_city>
|
| 301 |
+
<origin_state translate="label">
|
| 302 |
+
<label>Origin State</label>
|
| 303 |
+
<frontend_type>text</frontend_type>
|
| 304 |
+
<comment>2 letter abbrev.</comment>
|
| 305 |
+
<sort_order>85</sort_order>
|
| 306 |
+
<show_in_default>1</show_in_default>
|
| 307 |
+
<show_in_website>1</show_in_website>
|
| 308 |
+
<show_in_store>1</show_in_store>
|
| 309 |
+
</origin_state>
|
| 310 |
+
<default_origin translate="label">
|
| 311 |
+
<label>Default Origin Zipcode </label>
|
| 312 |
+
<frontend_type>text</frontend_type>
|
| 313 |
+
<sort_order>86</sort_order>
|
| 314 |
+
<show_in_default>1</show_in_default>
|
| 315 |
+
<show_in_website>1</show_in_website>
|
| 316 |
+
<show_in_store>1</show_in_store>
|
| 317 |
+
</default_origin>
|
| 318 |
+
<origin_location_type translate="label">
|
| 319 |
+
<label>Origin Location Type</label>
|
| 320 |
+
<frontend_type>select</frontend_type>
|
| 321 |
+
<source_model>shiphawk_shipping/source_location</source_model>
|
| 322 |
+
<sort_order>87</sort_order>
|
| 323 |
+
<show_in_default>1</show_in_default>
|
| 324 |
+
<show_in_website>1</show_in_website>
|
| 325 |
+
<show_in_store>1</show_in_store>
|
| 326 |
+
</origin_location_type>
|
| 327 |
+
<origin_phone translate="label">
|
| 328 |
+
<label>Origin Phone</label>
|
| 329 |
+
<frontend_type>text</frontend_type>
|
| 330 |
+
<sort_order>88</sort_order>
|
| 331 |
+
<show_in_default>1</show_in_default>
|
| 332 |
+
<show_in_website>1</show_in_website>
|
| 333 |
+
<show_in_store>1</show_in_store>
|
| 334 |
+
</origin_phone>
|
| 335 |
+
<origin_email translate="label">
|
| 336 |
+
<label>Origin Email </label>
|
| 337 |
+
<frontend_type>text</frontend_type>
|
| 338 |
+
<sort_order>89</sort_order>
|
| 339 |
+
<show_in_default>1</show_in_default>
|
| 340 |
+
<show_in_website>1</show_in_website>
|
| 341 |
+
<show_in_store>1</show_in_store>
|
| 342 |
+
</origin_email>
|
| 343 |
+
<file_import translate="label comment">
|
| 344 |
+
<label>Import Origins</label>
|
| 345 |
+
<comment><![CDATA[File saved in <strong><span style="color: red;">var/shiphawk/import</span></strong> folder.]]></comment>
|
| 346 |
+
<frontend_type>file</frontend_type>
|
| 347 |
+
<backend_model>adminhtml/system_config_backend_file</backend_model>
|
| 348 |
+
<upload_dir>var/shiphawk/import</upload_dir>
|
| 349 |
+
<sort_order>50</sort_order>
|
| 350 |
+
<show_in_default>1</show_in_default>
|
| 351 |
+
<show_in_website>0</show_in_website>
|
| 352 |
+
<show_in_store>0</show_in_store>
|
| 353 |
+
</file_import>
|
| 354 |
+
|
| 355 |
+
<importbutton translate="label">
|
| 356 |
+
<frontend_type>button</frontend_type>
|
| 357 |
+
<frontend_model>shiphawk_shipping/adminhtml_system_config_form_button</frontend_model>
|
| 358 |
+
<sort_order>60</sort_order>
|
| 359 |
+
<show_in_default>1</show_in_default>
|
| 360 |
+
<show_in_website>1</show_in_website>
|
| 361 |
+
<show_in_store>1</show_in_store>
|
| 362 |
+
<comment>Upload csv file, before start import</comment>
|
| 363 |
+
</importbutton>
|
| 364 |
+
</fields>
|
| 365 |
+
</shiphawk_shipping>
|
| 366 |
+
</groups>
|
| 367 |
+
</carriers>
|
| 368 |
+
</sections>
|
| 369 |
+
</config>
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$type_of_product_data = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Type of Item',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'input' => 'text',
|
| 13 |
+
'system' => false,
|
| 14 |
+
'required' => false,
|
| 15 |
+
'user_defined' => 1,
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
$installer->addAttribute('catalog_product','shiphawk_type_of_product',$type_of_product_data);
|
| 19 |
+
|
| 20 |
+
$shiphawk_quantity_data = array (
|
| 21 |
+
'attribute_set' => 'Default',
|
| 22 |
+
'group' => 'ShipHawk Attributes',
|
| 23 |
+
'label' => 'Number of items per Product',
|
| 24 |
+
'visible' => true,
|
| 25 |
+
'type' => 'int',
|
| 26 |
+
'apply_to' => 'simple',
|
| 27 |
+
'input' => 'text',
|
| 28 |
+
'default' => 1,
|
| 29 |
+
'frontend_class' => 'validate-not-negative-number',
|
| 30 |
+
'system' => false,
|
| 31 |
+
'required' => false,
|
| 32 |
+
'user_defined' => 1,
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
$installer->addAttribute('catalog_product','shiphawk_quantity', $shiphawk_quantity_data);
|
| 36 |
+
|
| 37 |
+
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'shiphawk_item_is_packed', array(
|
| 38 |
+
'group' => 'ShipHawk Attributes',
|
| 39 |
+
'backend' => 'catalog/product_attribute_backend_msrp',
|
| 40 |
+
'label' => 'Packaged?',
|
| 41 |
+
'input' => 'select',
|
| 42 |
+
'source' => 'catalog/product_attribute_source_msrp_type_enabled',
|
| 43 |
+
'type' => 'varchar',
|
| 44 |
+
'apply_to' => 'simple',
|
| 45 |
+
'visible' => true,
|
| 46 |
+
'required' => false,
|
| 47 |
+
'user_defined' => 1,
|
| 48 |
+
'default' => '2',
|
| 49 |
+
'input_renderer' => 'adminhtml/catalog_product_helper_form_msrp_enabled',
|
| 50 |
+
'visible_on_front' => false
|
| 51 |
+
));
|
| 52 |
+
|
| 53 |
+
$length_data = array (
|
| 54 |
+
'attribute_set' => 'Default',
|
| 55 |
+
'group' => 'ShipHawk Attributes',
|
| 56 |
+
'label' => 'Length',
|
| 57 |
+
'visible' => true,
|
| 58 |
+
'type' => 'varchar',
|
| 59 |
+
'apply_to' => 'simple',
|
| 60 |
+
'input' => 'text',
|
| 61 |
+
'system' => false,
|
| 62 |
+
'required' => false,
|
| 63 |
+
'user_defined' => 1,
|
| 64 |
+
);
|
| 65 |
+
|
| 66 |
+
$installer->addAttribute('catalog_product','shiphawk_length',$length_data);
|
| 67 |
+
|
| 68 |
+
$width_data = array (
|
| 69 |
+
'attribute_set' => 'Default',
|
| 70 |
+
'group' => 'ShipHawk Attributes',
|
| 71 |
+
'label' => 'Width',
|
| 72 |
+
'visible' => true,
|
| 73 |
+
'type' => 'varchar',
|
| 74 |
+
'apply_to' => 'simple',
|
| 75 |
+
'input' => 'text',
|
| 76 |
+
'system' => false,
|
| 77 |
+
'required' => false,
|
| 78 |
+
'user_defined' => 1,
|
| 79 |
+
);
|
| 80 |
+
|
| 81 |
+
$installer->addAttribute('catalog_product','shiphawk_width',$width_data);
|
| 82 |
+
|
| 83 |
+
$height_data = array (
|
| 84 |
+
'attribute_set' => 'Default',
|
| 85 |
+
'group' => 'ShipHawk Attributes',
|
| 86 |
+
'label' => 'Height',
|
| 87 |
+
'visible' => true,
|
| 88 |
+
'type' => 'varchar',
|
| 89 |
+
'apply_to' => 'simple',
|
| 90 |
+
'input' => 'text',
|
| 91 |
+
'system' => false,
|
| 92 |
+
'required' => false,
|
| 93 |
+
'user_defined' => 1,
|
| 94 |
+
);
|
| 95 |
+
|
| 96 |
+
$installer->addAttribute('catalog_product','shiphawk_height',$height_data);
|
| 97 |
+
|
| 98 |
+
$item_value_data = array (
|
| 99 |
+
'attribute_set' => 'Default',
|
| 100 |
+
'group' => 'ShipHawk Attributes',
|
| 101 |
+
'label' => 'Item Value',
|
| 102 |
+
'visible' => true,
|
| 103 |
+
'type' => 'varchar',
|
| 104 |
+
'apply_to' => 'simple',
|
| 105 |
+
'frontend_class' => 'validate-number',
|
| 106 |
+
'input' => 'text',
|
| 107 |
+
'system' => false,
|
| 108 |
+
'required' => false,
|
| 109 |
+
'user_defined' => 1,
|
| 110 |
+
);
|
| 111 |
+
|
| 112 |
+
$installer->addAttribute('catalog_product','shiphawk_item_value', $item_value_data);
|
| 113 |
+
|
| 114 |
+
/* use as separator too */
|
| 115 |
+
$type_of_product_value = array (
|
| 116 |
+
'attribute_set' => 'Default',
|
| 117 |
+
'group' => 'ShipHawk Attributes',
|
| 118 |
+
'label' => 'Origin Contact:',
|
| 119 |
+
'visible' => true,
|
| 120 |
+
'type' => 'varchar',
|
| 121 |
+
'apply_to' => 'simple',
|
| 122 |
+
'input' => 'text',
|
| 123 |
+
'system' => false,
|
| 124 |
+
'required' => false,
|
| 125 |
+
'user_defined' => 1,
|
| 126 |
+
);
|
| 127 |
+
|
| 128 |
+
$installer->addAttribute('catalog_product','shiphawk_type_of_product_value',$type_of_product_value);
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
$firstname_origin_data = array (
|
| 132 |
+
'attribute_set' => 'Default',
|
| 133 |
+
'group' => 'ShipHawk Attributes',
|
| 134 |
+
'label' => 'Origin First Name',
|
| 135 |
+
'visible' => true,
|
| 136 |
+
'type' => 'varchar',
|
| 137 |
+
'apply_to' => 'simple',
|
| 138 |
+
'input' => 'text',
|
| 139 |
+
'system' => false,
|
| 140 |
+
'required' => false,
|
| 141 |
+
'user_defined' => 1,
|
| 142 |
+
);
|
| 143 |
+
|
| 144 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_firstname',$firstname_origin_data);
|
| 145 |
+
|
| 146 |
+
$last_name_origin_data = array (
|
| 147 |
+
'attribute_set' => 'Default',
|
| 148 |
+
'group' => 'ShipHawk Attributes',
|
| 149 |
+
'label' => 'Origin Last Name',
|
| 150 |
+
'visible' => true,
|
| 151 |
+
'type' => 'varchar',
|
| 152 |
+
'apply_to' => 'simple',
|
| 153 |
+
'input' => 'text',
|
| 154 |
+
'system' => false,
|
| 155 |
+
'required' => false,
|
| 156 |
+
'user_defined' => 1,
|
| 157 |
+
);
|
| 158 |
+
|
| 159 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_lastname',$last_name_origin_data);
|
| 160 |
+
|
| 161 |
+
$address_line_1_origin_data = array (
|
| 162 |
+
'attribute_set' => 'Default',
|
| 163 |
+
'group' => 'ShipHawk Attributes',
|
| 164 |
+
'label' => 'Origin Address',
|
| 165 |
+
'visible' => true,
|
| 166 |
+
'type' => 'varchar',
|
| 167 |
+
'apply_to' => 'simple',
|
| 168 |
+
'input' => 'text',
|
| 169 |
+
'system' => false,
|
| 170 |
+
'required' => false,
|
| 171 |
+
'user_defined' => 1,
|
| 172 |
+
);
|
| 173 |
+
|
| 174 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_addressline1',$address_line_1_origin_data);
|
| 175 |
+
|
| 176 |
+
$address_line_2_origin_data = array (
|
| 177 |
+
'attribute_set' => 'Default',
|
| 178 |
+
'group' => 'ShipHawk Attributes',
|
| 179 |
+
'label' => 'Origin Address 2',
|
| 180 |
+
'visible' => true,
|
| 181 |
+
'type' => 'varchar',
|
| 182 |
+
'apply_to' => 'simple',
|
| 183 |
+
'input' => 'text',
|
| 184 |
+
'system' => false,
|
| 185 |
+
'required' => false,
|
| 186 |
+
'user_defined' => 1,
|
| 187 |
+
);
|
| 188 |
+
|
| 189 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_addressline2',$address_line_2_origin_data);
|
| 190 |
+
|
| 191 |
+
$city_origin_data = array (
|
| 192 |
+
'attribute_set' => 'Default',
|
| 193 |
+
'group' => 'ShipHawk Attributes',
|
| 194 |
+
'label' => 'Origin City',
|
| 195 |
+
'visible' => true,
|
| 196 |
+
'type' => 'varchar',
|
| 197 |
+
'apply_to' => 'simple',
|
| 198 |
+
'input' => 'text',
|
| 199 |
+
'system' => false,
|
| 200 |
+
'required' => false,
|
| 201 |
+
'user_defined' => 1,
|
| 202 |
+
);
|
| 203 |
+
|
| 204 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_city',$city_origin_data);
|
| 205 |
+
|
| 206 |
+
$state_origin_data = array (
|
| 207 |
+
'attribute_set' => 'Default',
|
| 208 |
+
'group' => 'ShipHawk Attributes',
|
| 209 |
+
'label' => 'State',
|
| 210 |
+
'visible' => true,
|
| 211 |
+
'type' => 'varchar',
|
| 212 |
+
'apply_to' => 'simple',
|
| 213 |
+
'input' => 'text',
|
| 214 |
+
'system' => false,
|
| 215 |
+
'required' => false,
|
| 216 |
+
'user_defined' => 1,
|
| 217 |
+
);
|
| 218 |
+
|
| 219 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_state',$state_origin_data);
|
| 220 |
+
|
| 221 |
+
$zip_code_origin_data = array (
|
| 222 |
+
'attribute_set' => 'Default',
|
| 223 |
+
'group' => 'ShipHawk Attributes',
|
| 224 |
+
'label' => 'Origin Zipcode',
|
| 225 |
+
'visible' => true,
|
| 226 |
+
'type' => 'varchar',
|
| 227 |
+
'apply_to' => 'simple',
|
| 228 |
+
'input' => 'text',
|
| 229 |
+
'system' => false,
|
| 230 |
+
'required' => false,
|
| 231 |
+
'user_defined' => 1,
|
| 232 |
+
);
|
| 233 |
+
|
| 234 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_zipcode',$zip_code_origin_data);
|
| 235 |
+
|
| 236 |
+
$phone_num_origin_data = array (
|
| 237 |
+
'attribute_set' => 'Default',
|
| 238 |
+
'group' => 'ShipHawk Attributes',
|
| 239 |
+
'label' => 'Origin Phone',
|
| 240 |
+
'visible' => true,
|
| 241 |
+
'type' => 'varchar',
|
| 242 |
+
'apply_to' => 'simple',
|
| 243 |
+
'input' => 'text',
|
| 244 |
+
'system' => false,
|
| 245 |
+
'required' => false,
|
| 246 |
+
'user_defined' => 1,
|
| 247 |
+
);
|
| 248 |
+
|
| 249 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_phonenum',$phone_num_origin_data);
|
| 250 |
+
|
| 251 |
+
$location_origin_data = array (
|
| 252 |
+
'attribute_set' => 'Default',
|
| 253 |
+
'group' => 'ShipHawk Attributes',
|
| 254 |
+
'label' => 'Origin Location',
|
| 255 |
+
'visible' => true,
|
| 256 |
+
'type' => 'varchar',
|
| 257 |
+
'apply_to' => 'simple',
|
| 258 |
+
'option' => array ('value' => array(
|
| 259 |
+
'commercial' => array('commercial'),
|
| 260 |
+
'residential' => array('residential'))),
|
| 261 |
+
'input' => 'select',
|
| 262 |
+
'system' => false,
|
| 263 |
+
'required' => false,
|
| 264 |
+
'user_defined' => 1,
|
| 265 |
+
);
|
| 266 |
+
|
| 267 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_location',$location_origin_data);
|
| 268 |
+
|
| 269 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.0-0.7.1.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_book_id', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_book_id', 'text');
|
| 8 |
+
|
| 9 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.1-0.7.2.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.2-1.0.0.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$origin_email = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Origin Email',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'input' => 'text',
|
| 13 |
+
'system' => false,
|
| 14 |
+
'required' => false,
|
| 15 |
+
'user_defined' => 1,
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
$installer->addAttribute('catalog_product','shiphawk_origin_email', $origin_email);
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.1-1.0.2.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$installer->run("
|
| 6 |
+
|
| 7 |
+
-- DROP TABLE IF EXISTS {$this->getTable('shiphawk_shipping/origins')};
|
| 8 |
+
CREATE TABLE {$this->getTable('shiphawk_shipping/origins')} (
|
| 9 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
| 10 |
+
`shiphawk_origin_firstname` varchar(250) NULL default '',
|
| 11 |
+
`shiphawk_origin_lastname` varchar(250) NULL default '',
|
| 12 |
+
`shiphawk_origin_addressline1` varchar(250) NULL default '',
|
| 13 |
+
`shiphawk_origin_addressline2` varchar(250) NULL default '',
|
| 14 |
+
`shiphawk_origin_city` varchar(250) NULL default '',
|
| 15 |
+
`shiphawk_origin_state` varchar(250) NULL default '',
|
| 16 |
+
`shiphawk_origin_zipcode` varchar(250) NULL default '',
|
| 17 |
+
`shiphawk_origin_phonenum` varchar(250) NULL default '',
|
| 18 |
+
`shiphawk_origin_location` varchar(250) NULL default '',
|
| 19 |
+
`shiphawk_origin_email` varchar(250) NULL default '',
|
| 20 |
+
`shiphawk_origin_title` varchar(250) NULL default '',
|
| 21 |
+
|
| 22 |
+
PRIMARY KEY (`id`)
|
| 23 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 24 |
+
|
| 25 |
+
");
|
| 26 |
+
|
| 27 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.10-1.0.11.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$data = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Freight Class',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'option' => array ('values' => array(
|
| 13 |
+
0 => '50',
|
| 14 |
+
1 => '55',
|
| 15 |
+
2 => '60',
|
| 16 |
+
3 => '65',
|
| 17 |
+
4 => '70',
|
| 18 |
+
5 => '77.5',
|
| 19 |
+
6 => '85',
|
| 20 |
+
7 => '92.5',
|
| 21 |
+
8 => '100',
|
| 22 |
+
9 => '110',
|
| 23 |
+
10 => '125',
|
| 24 |
+
11 => '150',
|
| 25 |
+
12 => '175',
|
| 26 |
+
13 => '200',
|
| 27 |
+
14 => '250',
|
| 28 |
+
15 => '300',
|
| 29 |
+
16 => '400',
|
| 30 |
+
17 => '500'
|
| 31 |
+
)),
|
| 32 |
+
'input' => 'select',
|
| 33 |
+
'system' => false,
|
| 34 |
+
'required' => false,
|
| 35 |
+
'user_defined' => 1,
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
$installer->addAttribute('catalog_product', 'shiphawk_freight_class', $data);
|
| 39 |
+
|
| 40 |
+
/* for sortOrder */
|
| 41 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_freight_class', 'frontend_label', 'Freight Class', 7);
|
| 42 |
+
|
| 43 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.11-1.0.12.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_location_type', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->addAttribute('quote', 'shiphawk_location_type', array('type' => 'text', 'input' => 'text'));
|
| 8 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_location_type', 'text');
|
| 9 |
+
|
| 10 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.12-1.0.13.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_rate_filter', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->addAttribute('quote', 'shiphawk_rate_filter', array('type' => 'text', 'input' => 'text'));
|
| 8 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_rate_filter', 'text');
|
| 9 |
+
|
| 10 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.13-1.1.0.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$percentage = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Markup or Discount Percentage',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'input' => 'text',
|
| 13 |
+
'system' => false,
|
| 14 |
+
'required' => false,
|
| 15 |
+
'user_defined' => 1,
|
| 16 |
+
'note' => 'possible values from -100 to 100'
|
| 17 |
+
);
|
| 18 |
+
|
| 19 |
+
$installer->addAttribute('catalog_product','shiphawk_discount_percentage', $percentage);
|
| 20 |
+
/* for sortOrder */
|
| 21 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_percentage', 'frontend_label', 'Markup or Discount Percentage', 7);
|
| 22 |
+
|
| 23 |
+
$fixed = array (
|
| 24 |
+
'attribute_set' => 'Default',
|
| 25 |
+
'group' => 'ShipHawk Attributes',
|
| 26 |
+
'label' => 'Markup or Discount Flat Amount',
|
| 27 |
+
'visible' => true,
|
| 28 |
+
'type' => 'varchar',
|
| 29 |
+
'apply_to' => 'simple',
|
| 30 |
+
'input' => 'text',
|
| 31 |
+
'system' => false,
|
| 32 |
+
'required' => false,
|
| 33 |
+
'user_defined' => 1,
|
| 34 |
+
'note' => 'possible values from -∞ to ∞'
|
| 35 |
+
);
|
| 36 |
+
|
| 37 |
+
$installer->addAttribute('catalog_product','shiphawk_discount_fixed', $fixed);
|
| 38 |
+
/* for sortOrder */
|
| 39 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_fixed', 'frontend_label', 'Markup or Discount Flat Amount', 7);
|
| 40 |
+
|
| 41 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.2-1.0.3.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$shipping_origins = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Shipping Origins',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'input' => 'text',
|
| 13 |
+
'system' => false,
|
| 14 |
+
'required' => false,
|
| 15 |
+
'user_defined' => 1,
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
$installer->addAttribute('catalog_product','shiphawk_shipping_origins', $shipping_origins);
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.4-1.0.5.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_shipping_amount', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_shipping_amount', 'text');
|
| 8 |
+
|
| 9 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.5-1.0.6.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
// Remove Product Attribute
|
| 5 |
+
|
| 6 |
+
/*$origins_attributes = array('shiphawk_origin_firstname', 'shiphawk_origin_lastname', 'shiphawk_origin_addressline1', 'shiphawk_origin_addressline2',
|
| 7 |
+
'shiphawk_origin_city', 'shiphawk_origin_state', 'shiphawk_origin_zipcode', 'shiphawk_origin_phonenum', 'shiphawk_origin_location', 'shiphawk_origin_email');
|
| 8 |
+
|
| 9 |
+
foreach($origins_attributes as $code) {
|
| 10 |
+
$attr = Mage::getModel('catalog/resource_eav_attribute')
|
| 11 |
+
->loadByCode('catalog_product',$code);
|
| 12 |
+
if(!(null == $attr->getId())) {
|
| 13 |
+
//attribute does exist
|
| 14 |
+
$installer->removeAttribute('catalog_product', $code);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
}*/
|
| 18 |
+
|
| 19 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.6-1.0.7.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
|
| 4 |
+
$io = new Varien_Io_File();
|
| 5 |
+
$io->checkAndCreateFolder(Mage::getBaseDir('var').DS.'shiphawk'.DS.'import');
|
| 6 |
+
|
| 7 |
+
$installer->startSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.7-1.0.8.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
|
| 4 |
+
$io = new Varien_Io_File();
|
| 5 |
+
$io->checkAndCreateFolder(Mage::getBaseDir('media').DS.'shiphawk'.DS.'bol');
|
| 6 |
+
|
| 7 |
+
$installer->startSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.8-1.0.9.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_shipping_package_info', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_shipping_package_info', 'text');
|
| 8 |
+
|
| 9 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.0.9-1.0.10.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var Mage_Eav_Model_Entity_Setup $installer */
|
| 3 |
+
$installer = Mage::getResourceModel('sales/setup','sales_setup');
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$installer->addAttribute('order', 'shiphawk_shipping_accessories', array('type' => 'text', 'input' => 'text'));
|
| 7 |
+
$installer->addAttribute('quote', 'shiphawk_shipping_accessories', array('type' => 'text', 'input' => 'text'));
|
| 8 |
+
$installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_shipping_accessories', 'text');
|
| 9 |
+
|
| 10 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.0-1.1.1.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$data = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Carrier Type',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'option' => array ('values' => array(
|
| 13 |
+
'' => 'All',
|
| 14 |
+
'ltl' => 'ltl',
|
| 15 |
+
'blanket wrap' => 'blanket wrap',
|
| 16 |
+
'small parcel' => 'small parcel',
|
| 17 |
+
'vehicle' => 'vehicle',
|
| 18 |
+
'intermodal' => 'intermodal',
|
| 19 |
+
'local delivery' => 'local delivery',
|
| 20 |
+
)),
|
| 21 |
+
'input' => 'select',
|
| 22 |
+
'system' => false,
|
| 23 |
+
'required' => false,
|
| 24 |
+
'user_defined' => 1,
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
$installer->addAttribute('catalog_product', 'shiphawk_carrier_type', $data);
|
| 28 |
+
|
| 29 |
+
/* for sortOrder */
|
| 30 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_carrier_type', 'frontend_label', 'Carrier Type', 7);
|
| 31 |
+
|
| 32 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.3-1.1.4.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
// Remove shiphawk_carrier_type dropdown
|
| 6 |
+
$installer->removeAttribute('catalog_product', 'shiphawk_carrier_type');
|
| 7 |
+
|
| 8 |
+
$data = array (
|
| 9 |
+
'attribute_set' => 'Default',
|
| 10 |
+
'group' => 'ShipHawk Attributes',
|
| 11 |
+
'label' => 'Carrier Type',
|
| 12 |
+
'visible' => true,
|
| 13 |
+
'type' => 'varchar',
|
| 14 |
+
'apply_to' => 'simple',
|
| 15 |
+
'option' => array ('values' => array(
|
| 16 |
+
'' => 'All',
|
| 17 |
+
'ltl' => 'ltl',
|
| 18 |
+
'blanket wrap' => 'blanket wrap',
|
| 19 |
+
'small parcel' => 'small parcel',
|
| 20 |
+
'vehicle' => 'vehicle',
|
| 21 |
+
'intermodal' => 'intermodal',
|
| 22 |
+
'local delivery' => 'local delivery',
|
| 23 |
+
)),
|
| 24 |
+
'input' => 'multiselect',
|
| 25 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
| 26 |
+
'system' => false,
|
| 27 |
+
'required' => false,
|
| 28 |
+
'user_defined' => 1,
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
$installer->addAttribute('catalog_product', 'shiphawk_carrier_type', $data);
|
| 32 |
+
|
| 33 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.4-1.1.5.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_type_of_product', 'frontend_label', 'Type of Item', 1);
|
| 6 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_quantity', 'frontend_label', 'Number of items per Product', 2);
|
| 7 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_item_is_packed', 'frontend_label', 'Packaged?', 3);
|
| 8 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_length', 'frontend_label', 'Length', 4);
|
| 9 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_width', 'frontend_label', 'Width', 5);
|
| 10 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_height', 'frontend_label', 'Height', 6);
|
| 11 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_carrier_type', 'frontend_label', 'Carrier Type', 7);
|
| 12 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_freight_class', 'frontend_label', 'Freight Class', 8);
|
| 13 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_item_value', 'frontend_label', 'Item Value', 9);
|
| 14 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_percentage', 'frontend_label', 'Markup or Discount Percentage', 10);
|
| 15 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_fixed', 'frontend_label', 'Markup or Discount Flat Amount', 11);
|
| 16 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_type_of_product_value', 'frontend_label', 'Origin Contact:', 12);
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.5.1-1.1.5.3.php
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magento.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magento.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Sales
|
| 23 |
+
* @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/* @var $installer Mage_Sales_Model_Entity_Setup */
|
| 28 |
+
$installer = $this;
|
| 29 |
+
$installer->startSetup();
|
| 30 |
+
$installer->getConnection()
|
| 31 |
+
->addColumn($installer->getTable('sales/shipment'), 'shiphawk_shipping_method_title', array(
|
| 32 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
| 33 |
+
'comment' => 'Shiphawk Shipping Method Title',
|
| 34 |
+
'length' => '2000'
|
| 35 |
+
));
|
| 36 |
+
|
| 37 |
+
$installer->getConnection()
|
| 38 |
+
->addColumn($installer->getTable('sales/shipment'), 'shiphawk_shipping_price', array(
|
| 39 |
+
'type' => Varien_Db_Ddl_Table::TYPE_FLOAT,
|
| 40 |
+
'comment' => 'Shiphawk Shipping Price'
|
| 41 |
+
));
|
| 42 |
+
|
| 43 |
+
$installer->endSetup();
|
| 44 |
+
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.5.3-1.1.6.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_item_is_packed', 'frontend_label', 'Is Product Already Packed?');
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
$installer->endSetup();
|
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-1.1.7-1.1.8.php
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$packing_price = array (
|
| 6 |
+
'attribute_set' => 'Default',
|
| 7 |
+
'group' => 'ShipHawk Attributes',
|
| 8 |
+
'label' => 'Custom Packing Price',
|
| 9 |
+
'visible' => true,
|
| 10 |
+
'type' => 'varchar',
|
| 11 |
+
'apply_to' => 'simple',
|
| 12 |
+
'input' => 'text',
|
| 13 |
+
'system' => false,
|
| 14 |
+
'required' => false,
|
| 15 |
+
'user_defined' => 1,
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
$installer->addAttribute('catalog_product','shiphawk_custom_packing_price', $packing_price);
|
| 19 |
+
|
| 20 |
+
/* for sortOrder */
|
| 21 |
+
|
| 22 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_type_of_product', 'frontend_label', 'Type of Item', 10);
|
| 23 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_quantity', 'frontend_label', 'Number of items per Product', 20);
|
| 24 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_item_is_packed', 'frontend_label', 'Is Product Already Packed?', 30);
|
| 25 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_custom_packing_price', 'frontend_label', 'Custom Packing Price', 40);
|
| 26 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_length', 'frontend_label', 'Length', 50);
|
| 27 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_width', 'frontend_label', 'Width', 60);
|
| 28 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_height', 'frontend_label', 'Height', 70);
|
| 29 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_carrier_type', 'frontend_label', 'Carrier Type', 80);
|
| 30 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_freight_class', 'frontend_label', 'Freight Class', 90);
|
| 31 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_item_value', 'frontend_label', 'Item Value', 100);
|
| 32 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_percentage', 'frontend_label', 'Markup or Discount Percentage', 110);
|
| 33 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_discount_fixed', 'frontend_label', 'Markup or Discount Flat Amount', 120);
|
| 34 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_shipping_origins', 'frontend_label', 'Shipping Origins', 121);
|
| 35 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_type_of_product_value', 'frontend_label', 'Origin Contact:', 125);
|
| 36 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_firstname', 'frontend_label', 'Origin First Name', 130);
|
| 37 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_lastname', 'frontend_label', 'Origin Last Name', 140);
|
| 38 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_addressline1', 'frontend_label', 'Origin Address', 150);
|
| 39 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_addressline2', 'frontend_label', 'Origin Address 2', 160);
|
| 40 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_city', 'frontend_label', 'Origin City', 170);
|
| 41 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_state', 'frontend_label', 'Origin State', 180);
|
| 42 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_zipcode', 'frontend_label', 'Origin Zipcode', 190);
|
| 43 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_phonenum', 'frontend_label', 'Origin Phone', 200);
|
| 44 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_email', 'frontend_label', 'Origin Email', 210);
|
| 45 |
+
$installer->updateAttribute('catalog_product', 'shiphawk_origin_location', 'frontend_label', 'Origin Location', 220);
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
$installer->endSetup();
|
package.xml
CHANGED
|
@@ -1,18 +1,21 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
-
<name>
|
| 4 |
-
<version>2.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license uri="
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary
|
| 10 |
-
<description
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
<
|
| 14 |
-
|
| 15 |
-
<
|
|
|
|
|
|
|
|
|
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies><required><php><min>5.
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
+
<name>Shiphawk</name>
|
| 4 |
+
<version>2.2.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>All-in-one shipping platform offering the best delivery network, in-cart rates, & post-purchase tracking.</summary>
|
| 10 |
+
<description>Everything You Need to Support an Enterprise Shipping Experience
|
| 11 |
+

|
| 12 |
+
ShipHawk is a powerful, all-in-one shipping intelligence platform that offers the best delivery network (including parcel, LTL, and white glove carriers), in-cart rating, on-demand shipping policies, and clear-cut post-purchase shipment tracking. To learn more about ShipHawk, our robust shipping intelligence engine, our powerful APIs, and other integrations that are available, please contact us today.</description>
|
| 13 |
+
<notes>- bug fixes 
|
| 14 |
+
- added support for Magento coupons</notes>
|
| 15 |
+
<authors><author><name>ShipHawk</name><user>ShipHawk</user><email>contact@shiphawk.com</email></author></authors>
|
| 16 |
+
<date>2017-04-12</date>
|
| 17 |
+
<time>15:52:43</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Shiphawk"><dir name="Checkout"><dir name="Model"><file name="Cart.php" hash="e36459fa6fb1b52b66c0365665269ffc"/></dir></dir><dir name="MyCarrier"><dir name="Model"><file name="Carrier.php" hash="ee48a5d0151c697ef2084a15e50c9d45"/><file name="Freemethod.php" hash="b9c74865f43a8c4efd4f1ef30e7a9daa"/></dir><dir name="etc"><file name="config.xml" hash="a37ce5727366f406e4525e76a9253be8"/><file name="system.xml" hash="b42a37e75f679986f0f3c4c6ad6885c0"/></dir></dir><dir name="Order"><dir name="Block"><dir name="System"><file name="Link.php" hash="c44c95b4b5f8b1d87038d9707a970737"/></dir></dir><dir name="Helper"><file name="Data.php" hash="1a2f8a93a310d337787a34c3d6f1ecbb"/></dir><dir name="Model"><dir name="Command"><file name="ChangeStatus.php" hash="3d916b6ed60957849c27222bcaeb4672"/><file name="CheckConfiguration.php" hash="39b710b50ac78dc67346922609852f23"/><file name="SendOrder.php" hash="96e2d981420044c25e3d2ef95a20d8ad"/></dir><dir name="Cron"><file name="ProcessOrderForLast14Days.php" hash="1c59e28101bc110c05296a13878da537"/></dir><dir name="Observer"><file name="Config.php" hash="e44707a0586a18fea8a69646ff21b74a"/><file name="Order.php" hash="89674e02cb81fe2d062defa09bbb4d22"/></dir><dir name="Source"><file name="Gateway.php" hash="18df9d2ee851cbbcd2654ed69c2b311c"/><file name="Ordersync.php" hash="a15ba0ffe025a8a190516b09ce826022"/></dir><file name="StatusMapper.php" hash="45807c1a7f87acffdb8fde23405433d5"/></dir><dir name="etc"><file name="config.xml" hash="6a483558d2c3164d0fbc2f65fbd272e1"/><file name="system.xml" hash="fb7f76fbd0d21f3d89b51fa0378b61ce"/></dir></dir><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Origins"><dir name="Edit"><file name="Form.php" hash="fc372c73fac12c592d40ff9ae9297381"/></dir><file name="Edit.php" hash="1202b50bc520ebf18bfbb033280f1ddf"/><file name="Grid.php" hash="9af28e730d7c476f1c8a5254402d8429"/></dir><file name="Origins.php" hash="748725e017dcbca92de4adf9de59d23f"/><dir name="Sales"><dir name="Order"><dir name="Shipment"><file name="View.php" hash="49b1612a21244178d517eecd492beaca"/></dir><file name="View.php" hash="fc8f1e2607f7ced87edb73dad8d515c3"/></dir></dir><file name="Shipment.php" hash="caad45a2164bbfba83e6d5a41a75f50d"/><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="fbffbfa54f05d2da4cf380ffec35e38f"/></dir></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="Helper"><dir name="Form"><file name="Disabled.php" hash="05adb96db0b68dc900174c4fefa3b39d"/><file name="Type.php" hash="4dd966de022cc9fc6d69dc5e0ecb4726"/></dir></dir></dir></dir><dir name="Shipping"><dir name="Tracking"><file name="Popup.php" hash="73358c38983dc18b6ccb4420e98a7043"/></dir></dir><file name="Version.php" hash="f91bc825ee1b6225e727c825e72ece71"/></dir><dir name="Helper"><file name="Data.php" hash="7e17b34e42f94f374ab1d23500574aa0"/><file name="Origin.php" hash="5a1ef27d1cb4db9ccb4a4a9f0c29c10e"/></dir><dir name="Model"><file name="Api.php" hash="e2e06f1ec9c1f8fd2752b028ead54855"/><file name="Carrier.php" hash="9c815b55e6283bccdff3d84a57f82830"/><file name="Observer.php" hash="752b90edd29a9a10db3dcb678921a97a"/><file name="Origins.php" hash="763f9064fcbf04f3cd873553a0002625"/><dir name="Product"><dir name="Attribute"><dir name="Source"><file name="Location.php" hash="e8cefabd60ff8ef6b09559c35ae4ff8c"/></dir></dir></dir><dir name="Resource"><dir name="Origins"><file name="Collection.php" hash="8aa8fb73c9db05975621106940b6519f"/></dir><file name="Origins.php" hash="e8c73d70433c1c4b21deca7b2baf1374"/></dir><dir name="Source"><file name="Adminratefilter.php" hash="e6096208ee165e06b016fcbc64b1a545"/><file name="Carriertype.php" hash="b2311da4909f59060bb60df14c7a5c59"/><file name="Freeshipping.php" hash="f35aa4a9483d2bdae1e3b60ce27b0f55"/><file name="Gateway.php" hash="1fa95fb657bc67f2973dd7e55a1046ad"/><file name="Location.php" hash="222ee55e43cc161204bc05e1a08b3db6"/><file name="Ratefilter.php" hash="56ed7f5059d2f9804387915eaa4f4b3b"/><file name="Received.php" hash="6d50e8c1fe6e13c971ba63348e98aac0"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ImportController.php" hash="6207c7ac200e882eb44b25b7e2587415"/><file name="OriginsController.php" hash="0f1e6e724f555bc0efd631257584779c"/><file name="ShipmentController.php" hash="a0dd7f3c78c40eb613e32bec0c95cf19"/></dir><file name="IndexController.php" hash="2f4e3b0a7202da44278957822d6a8379"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ceec9868f5c072336c97aebd7da0dc03"/><file name="config.xml" hash="cf07cfa64b67682b16fc7462594f6e27"/><file name="system.xml" hash="d05cc04c30a5b344bcc0f17a975ef395"/></dir><dir name="sql"><dir name="shiphawk_setup"><file name="mysql4-install-0.1.0.php" hash="951c03164740882fac36a0ccd6bec66f"/><file name="mysql4-upgrade-0.7.0-0.7.1.php" hash="eb3f0b3185cce381ea63a0d7fa4c76c6"/><file name="mysql4-upgrade-0.7.1-0.7.2.php" hash="8df91551c06b3f4dd0ac125bd445ceb4"/><file name="mysql4-upgrade-0.7.2-1.0.0.php" hash="930d934e4528a05d3fdf864cd43b55bb"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="a8d2ffa83e57b6983aadc84a800fd233"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="14ee57a3dbd6262796dfa53ac334b60e"/><file name="mysql4-upgrade-1.0.10-1.0.11.php" hash="535c9a3e34e9b26cdce3a99a7f56671b"/><file name="mysql4-upgrade-1.0.11-1.0.12.php" hash="e27f74deda031e8c221c838f44ff8002"/><file name="mysql4-upgrade-1.0.12-1.0.13.php" hash="65f1c19944d7c86f1acbb05e7627d622"/><file name="mysql4-upgrade-1.0.13-1.1.0.php" hash="e3ae5cb573422d100dee9c55de15533c"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="4ff24d716c62172ef4b85d18b91934c0"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="ba820664a791ed852b9238e113a41be9"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="054fd8d6946d5fd02b5943bfd2a73fad"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="e9fca7a2e71ae27cf8e66c27bed7274b"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="868c422c61c17dd39a948fcdaa1b58ac"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="5f545c7ec60cb16810ce96fdc9686ac7"/><file name="mysql4-upgrade-1.0.9-1.0.10.php" hash="3a8a2a44ce08382e40b809e3108ca795"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="5037a768822190cea8e08fdc8ab8f483"/><file name="mysql4-upgrade-1.1.3-1.1.4.php" hash="1d0088f0dce6b6e9c88627c996f486b6"/><file name="mysql4-upgrade-1.1.4-1.1.5.php" hash="dbc6cb1d4e8d204ac8d08820c7d62824"/><file name="mysql4-upgrade-1.1.5.1-1.1.5.3.php" hash="fffb846c7c16cdeecd9ce796ce2f8795"/><file name="mysql4-upgrade-1.1.5.3-1.1.6.php" hash="0ab1729e8311494b71fd1b50bd8f421e"/><file name="mysql4-upgrade-1.1.7-1.1.8.php" hash="669e5188d858ba37a854a6f0705086e0"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shiphawk_Order.xml" hash="41c5c882c390ff710b6632f2251165f5"/><file name="Shiphawk_Shipping.xml" hash="a9b0d8dcac01ccccef7f0f9ff52a7aba"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="shiphawk"><file name="shiphawkicon.png" hash="58d5c12ac147f24185425198621dc715"/></dir></dir></dir></dir></dir></target></contents>
|
| 19 |
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.3.0</min><max>7.1.2</max></php></required></dependencies>
|
| 21 |
</package>
|
skin/adminhtml/default/default/images/shiphawk/shiphawkicon.png
ADDED
|
Binary file
|
