Version Notes
---
Download this release
Release Info
Developer | Intelipost |
Extension | Intelipost |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Intelipost/Shipping/Helper/Data.php +4 -0
- app/code/local/Intelipost/Shipping/Model/Carrier/Category.php +23 -0
- app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php +212 -0
- app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php~ +211 -0
- app/code/local/Intelipost/Shipping/Model/Config/Apikey.php +58 -0
- app/code/local/Intelipost/Shipping/Model/Config/Apikey.php~ +58 -0
- app/code/local/Intelipost/Shipping/Model/Config/Password.php +15 -0
- app/code/local/Intelipost/Shipping/Model/Config/Token.php +13 -0
- app/code/local/Intelipost/Shipping/Model/Config/Useraccount.php +13 -0
- app/code/local/Intelipost/Shipping/Model/Resource/Quote.php +13 -0
- app/code/local/Intelipost/Shipping/Model/Resource/Setup.php +106 -0
- app/code/local/Intelipost/Shipping/Model/Resource/Volume.php +32 -0
- app/code/local/Intelipost/Shipping/etc/config.xml +81 -0
- app/code/local/Intelipost/Shipping/etc/system.xml +116 -0
- app/code/local/Intelipost/Shipping/sql/intelipost_setup/mysql4-install-0.0.1.php +8 -0
- app/etc/modules/Intelipost_Shipping.xml +26 -0
- app/locale/pt_BR/Intelipost_Shipping.csv +31 -0
- package.xml +19 -0
app/code/local/Intelipost/Shipping/Helper/Data.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intelipost_Shipping_Helper_Data
|
4 |
+
extends Mage_Core_Helper_Abstract {}
|
app/code/local/Intelipost/Shipping/Model/Carrier/Category.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intelipost_Shipping_Model_Carrier_Category {
|
4 |
+
public function toOptionArray() {
|
5 |
+
return array(
|
6 |
+
array('value' => '2', 'label' => Mage::helper('catalog')->__('Machinery and/or parts')),
|
7 |
+
array('value' => '5', 'label' => Mage::helper('catalog')->__('Eletronics')),
|
8 |
+
array('value' => '6', 'label' => Mage::helper('catalog')->__('Fragile products')),
|
9 |
+
array('value' => '7', 'label' => Mage::helper('catalog')->__('Cosmetics')),
|
10 |
+
array('value' => '10', 'label' => Mage::helper('catalog')->__('Office supplies and furniture')),
|
11 |
+
array('value' => '12', 'label' => Mage::helper('catalog')->__('Pharmacy')),
|
12 |
+
array('value' => '13', 'label' => Mage::helper('catalog')->__('Books and/or graphical material')),
|
13 |
+
array('value' => '14', 'label' => Mage::helper('catalog')->__('Floriculture')),
|
14 |
+
array('value' => '19', 'label' => Mage::helper('catalog')->__('Beverages')),
|
15 |
+
array('value' => '20', 'label' => Mage::helper('catalog')->__('Alcoholic')),
|
16 |
+
array('value' => '25', 'label' => Mage::helper('catalog')->__('Toys')),
|
17 |
+
array('value' => '22', 'label' => Mage::helper('catalog')->__('Food')),
|
18 |
+
array('value' => '26', 'label' => Mage::helper('catalog')->__('Documents')),
|
19 |
+
array('value' => '23', 'label' => Mage::helper('catalog')->__('High value products')),
|
20 |
+
array('value' => '24', 'label' => Mage::helper('catalog')->__('Clothing'))
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Quote.php';
|
4 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Volume.php';
|
5 |
+
|
6 |
+
class Intelipost_Shipping_Model_Carrier_Intelipost
|
7 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
8 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
9 |
+
{
|
10 |
+
protected $_code = 'intelipost';
|
11 |
+
protected $_helper = null;
|
12 |
+
|
13 |
+
private $_zipCodeRegex = '/[0-9]{2}\.?[0-9]{3}-?[0-9]{3}/';
|
14 |
+
|
15 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
|
16 |
+
$this->_helper = Mage::helper('intelipost');
|
17 |
+
|
18 |
+
if (!$this->getConfigFlag('active')) {
|
19 |
+
Mage::log('Intelipost is inactive', null, 'intelipost.log');
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
|
23 |
+
$originZipCode = $this->getConfigData('zipcode');
|
24 |
+
$destinationZipCode = $request->getDestPostcode();
|
25 |
+
|
26 |
+
if (!preg_match($this->_zipCodeRegex, $originZipCode) || !preg_match($this->_zipCodeRegex, $destinationZipCode)) {
|
27 |
+
Mage::log('Invalid zip code ' . $originZipCode . ' or ' . $destinationZipCode, null, 'intelipost.log');
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
|
31 |
+
// only numbers allowed
|
32 |
+
$originZipCode = preg_replace('/[^0-9]/', '', $originZipCode);
|
33 |
+
$destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
|
34 |
+
|
35 |
+
$weight = $request->getPackageWeight();
|
36 |
+
if ($weight <= 0) {
|
37 |
+
$this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
|
38 |
+
}
|
39 |
+
|
40 |
+
// weight must be in Kg
|
41 |
+
if($this->getConfigData('weight_type') == 'gr') {
|
42 |
+
$weight = number_format($weight/1000, 2, '.', '');
|
43 |
+
}else{
|
44 |
+
// TODO: do the weight defaults to Kg if it is not gr?
|
45 |
+
$weight = number_format($weight, 2, '.', '');
|
46 |
+
}
|
47 |
+
|
48 |
+
$price = $request->getPackageValue();
|
49 |
+
|
50 |
+
$encryption = Mage::getSingleton('core/encryption');
|
51 |
+
$account = $encryption->decrypt($this->getConfigData('account'));
|
52 |
+
$password = $encryption->decrypt($this->getConfigData('password'));
|
53 |
+
$api_key = $encryption->decrypt($this->getConfigData('apikey'));
|
54 |
+
// $token = $encryption->decrypt($this->getConfigData('token'));
|
55 |
+
|
56 |
+
if(!isset($api_key)/* || !isset($token) ||*/
|
57 |
+
|| !is_string($api_key)/* || !is_string($token)*/
|
58 |
+
){
|
59 |
+
Mage::log('Intelipost not configured', null, 'intelipost.log');
|
60 |
+
Mage::log('account: ' . $account, null, 'intelipost.log');
|
61 |
+
// take care to not log the password
|
62 |
+
Mage::log('password length: ' . strlen($password) , null, 'intelipost.log');
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$item_list = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
|
67 |
+
$productsCount = count($item_list);
|
68 |
+
|
69 |
+
$quote = new Intelipost_Model_Request_Quote();
|
70 |
+
$quote->origin_zip_code = $originZipCode;
|
71 |
+
$quote->destination_zip_code = $destinationZipCode;
|
72 |
+
|
73 |
+
if (!$request->getAllItems()) {
|
74 |
+
Mage::log('Cart is empty', null, 'intelipost.log');
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
// if notification is disabled we send the request anyways (changed on version 0.0.2)
|
79 |
+
$dimension_check = $this->getConfigData('notification');
|
80 |
+
|
81 |
+
$i=0;
|
82 |
+
foreach ($item_list as $item) {
|
83 |
+
$product = $item->getProduct();
|
84 |
+
|
85 |
+
$volume = new Intelipost_Model_Request_Volume();
|
86 |
+
$volume->volume_type = 'BOX';
|
87 |
+
|
88 |
+
if (!$this->isDimensionSet($product)) {
|
89 |
+
Mage::log('Product does not have dimensions set', null, 'intelipost.log');
|
90 |
+
|
91 |
+
if ($dimension_check) {
|
92 |
+
$this->notifyProductsDimension($item_list);
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}else{
|
96 |
+
$volume->width = $product->getVolumeLargura();
|
97 |
+
$volume->height = $product->getVolumeAltura();
|
98 |
+
$volume->length = $product->getVolumeComprimento();
|
99 |
+
}
|
100 |
+
|
101 |
+
$volume->weight = number_format(floatval($item->getWeight()), 2, ',', '') * $item->getQty();
|
102 |
+
$volume->cost_of_goods = number_format(floatval($item->getPrice()), 2, ',', '') * $item->getQty();
|
103 |
+
|
104 |
+
array_push($quote->volumes, $volume);
|
105 |
+
}
|
106 |
+
|
107 |
+
$body = json_encode($quote);
|
108 |
+
|
109 |
+
$s = curl_init();
|
110 |
+
curl_setopt($s, CURLOPT_TIMEOUT, 5000);
|
111 |
+
curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
|
112 |
+
if ($username != null && $password != null) {
|
113 |
+
curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
|
114 |
+
}
|
115 |
+
curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: $token"*/));
|
116 |
+
curl_setopt($s, CURLOPT_POST, true);
|
117 |
+
curl_setopt($s, CURLOPT_ENCODING , "");
|
118 |
+
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
|
119 |
+
curl_setopt($s, CURLOPT_POSTFIELDS, $body);
|
120 |
+
$responseBody = curl_exec($s);
|
121 |
+
|
122 |
+
$response = json_decode($responseBody);
|
123 |
+
// echo $responseBody;
|
124 |
+
curl_close($s);
|
125 |
+
|
126 |
+
$result = Mage::getModel('shipping/rate_result');
|
127 |
+
|
128 |
+
foreach ($response->content->delivery_options as $deliveryOption) {
|
129 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
130 |
+
|
131 |
+
$method->setCarrier ('intelipost');
|
132 |
+
$method->setCarrierTitle('Intelipost');
|
133 |
+
$method->setMethod ($deliveryOption->description);
|
134 |
+
$method->setMethodTitle ($deliveryOption->description);
|
135 |
+
$method->setPrice ($deliveryOption->final_shipping_cost);
|
136 |
+
$method->setCost ($deliveryOption->provider_shipping_cost);
|
137 |
+
|
138 |
+
$result->append($method);
|
139 |
+
}
|
140 |
+
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function getAllowedMethods() {
|
145 |
+
return array($this->_code => $this->getConfigData('name'));
|
146 |
+
}
|
147 |
+
|
148 |
+
private function isDimensionSet($product) {
|
149 |
+
$volume_altura = $product->getData('volume_altura');
|
150 |
+
$volume_largura = $product->getData('volume_largura');
|
151 |
+
$volume_comprimento = $product->getData('volume_comprimento');
|
152 |
+
|
153 |
+
if ($volume_comprimento == '' || (int)$volume_comprimento == 0
|
154 |
+
|| $volume_largura == '' || (int)$volume_largura == 0
|
155 |
+
|| $volume_altura == '' || (int)$volume_altura == 0
|
156 |
+
) {
|
157 |
+
return false;
|
158 |
+
}
|
159 |
+
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
|
163 |
+
private function notifyProductsDimension($item_list) {
|
164 |
+
$notification = Mage::getSingleton('adminnotification/inbox');
|
165 |
+
$message = $this->_helper->__('The following products do not have dimension set:');
|
166 |
+
|
167 |
+
$message .= '<ul>';
|
168 |
+
foreach ($item_list as $item) {
|
169 |
+
$product = $item->getProduct();
|
170 |
+
|
171 |
+
if (!$this->isDimensionSet($product)) {
|
172 |
+
$message .= '<li>';
|
173 |
+
$message .= sprintf(
|
174 |
+
'<a href="%s">',
|
175 |
+
Mage::helper('adminhtml')->getUrl(
|
176 |
+
'adminhtml/catalog_product/edit',
|
177 |
+
array( 'id' => $product->getId())
|
178 |
+
)
|
179 |
+
);
|
180 |
+
$message .= $item->getName();
|
181 |
+
$message .= '</a>';
|
182 |
+
$message .= '</li>';
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$message .= '</ul>';
|
186 |
+
|
187 |
+
$message .= $this->_helper->__('<small>Disable these notifications in System > Settings > Carriers > Intelipost</small>');
|
188 |
+
|
189 |
+
$notification->add(
|
190 |
+
Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR,
|
191 |
+
$this->_helper->__('Product missing dimensions'),
|
192 |
+
$message
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
private function formatDeadline($days) {
|
197 |
+
if ($days == 0) {
|
198 |
+
return $this->_helper->__('(same day)');
|
199 |
+
}
|
200 |
+
|
201 |
+
if ($days == 1) {
|
202 |
+
return $this->_helper->__('(1 day)');
|
203 |
+
}
|
204 |
+
|
205 |
+
if ($days == 101) {
|
206 |
+
return $this->_helper->__('(On acknowledgment)');
|
207 |
+
}
|
208 |
+
|
209 |
+
return sprintf($this->_helper->__('(%s days)'), $days);
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php~
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Quote.php';
|
4 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Volume.php';
|
5 |
+
|
6 |
+
class Intelipost_Shipping_Model_Carrier_Intelipost
|
7 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
8 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
9 |
+
{
|
10 |
+
protected $_code = 'intelipost';
|
11 |
+
protected $_helper = null;
|
12 |
+
|
13 |
+
private $_zipCodeRegex = '/[0-9]{2}\.?[0-9]{3}-?[0-9]{3}/';
|
14 |
+
|
15 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
|
16 |
+
$this->_helper = Mage::helper('intelipost');
|
17 |
+
|
18 |
+
if (!$this->getConfigFlag('active')) {
|
19 |
+
Mage::log('Intelipost is inactive', null, 'intelipost.log');
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
|
23 |
+
$originZipCode = $this->getConfigData('zipcode');
|
24 |
+
$destinationZipCode = $request->getDestPostcode();
|
25 |
+
|
26 |
+
if (!preg_match($this->_zipCodeRegex, $originZipCode) || !preg_match($this->_zipCodeRegex, $destinationZipCode)) {
|
27 |
+
Mage::log('Invalid zip code ' . $originZipCode . ' or ' . $destinationZipCode, null, 'intelipost.log');
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
|
31 |
+
// only numbers allowed
|
32 |
+
$originZipCode = preg_replace('/[^0-9]/', '', $originZipCode);
|
33 |
+
$destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
|
34 |
+
|
35 |
+
$weight = $request->getPackageWeight();
|
36 |
+
if ($weight <= 0) {
|
37 |
+
$this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
|
38 |
+
}
|
39 |
+
|
40 |
+
// weight must be in Kg
|
41 |
+
if($this->getConfigData('weight_type') == 'gr') {
|
42 |
+
$weight = number_format($weight/1000, 2, '.', '');
|
43 |
+
}else{
|
44 |
+
// TODO: do the weight defaults to Kg if it is not gr?
|
45 |
+
$weight = number_format($weight, 2, '.', '');
|
46 |
+
}
|
47 |
+
|
48 |
+
$price = $request->getPackageValue();
|
49 |
+
|
50 |
+
$encryption = Mage::getSingleton('core/encryption');
|
51 |
+
// $account = $encryption->decrypt($this->getConfigData('account'));
|
52 |
+
// $password = $encryption->decrypt($this->getConfigData('password'));
|
53 |
+
$api_key = $encryption->decrypt($this->getConfigData('apikey'));
|
54 |
+
// $token = $encryption->decrypt($this->getConfigData('token'));
|
55 |
+
|
56 |
+
if(!isset($account) || !isset($password) || !isset($api_key) || !isset($token) ||
|
57 |
+
!is_string($account) || !is_string($password) || !is_string($api_key) || !is_string($token)
|
58 |
+
){
|
59 |
+
Mage::log('Intelipost not configured', null, 'intelipost.log');
|
60 |
+
Mage::log('account: ' . $account, null, 'intelipost.log');
|
61 |
+
// take care to not log the password
|
62 |
+
Mage::log('password length: ' . strlen($password) , null, 'intelipost.log');
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$item_list = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
|
67 |
+
$productsCount = count($item_list);
|
68 |
+
|
69 |
+
$quote = new Intelipost_Model_Request_Quote();
|
70 |
+
$quote->origin_zip_code = $originZipCode;
|
71 |
+
$quote->destination_zip_code = $destinationZipCode;
|
72 |
+
|
73 |
+
if (!$request->getAllItems()) {
|
74 |
+
Mage::log('Cart is empty', null, 'intelipost.log');
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
// if notification is disabled we send the request anyways (changed on version 0.0.2)
|
79 |
+
$dimension_check = $this->getConfigData('notification');
|
80 |
+
|
81 |
+
$i=0;
|
82 |
+
foreach ($item_list as $item) {
|
83 |
+
$product = $item->getProduct();
|
84 |
+
|
85 |
+
$volume = new Intelipost_Model_Request_Volume();
|
86 |
+
$volume->volume_type = 'BOX';
|
87 |
+
|
88 |
+
if (!$this->isDimensionSet($product)) {
|
89 |
+
Mage::log('Product does not have dimensions set', null, 'intelipost.log');
|
90 |
+
|
91 |
+
if ($dimension_check) {
|
92 |
+
$this->notifyProductsDimension($item_list);
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}else{
|
96 |
+
$volume->width = $product->getVolumeLargura();
|
97 |
+
$volume->height = $product->getVolumeAltura();
|
98 |
+
$volume->length = $product->getVolumeComprimento();
|
99 |
+
}
|
100 |
+
|
101 |
+
$volume->weight = number_format(floatval($item->getWeight()), 2, ',', '') * $item->getQty();
|
102 |
+
$volume->cost_of_goods = number_format(floatval($item->getPrice()), 2, ',', '') * $item->getQty();
|
103 |
+
|
104 |
+
array_push($quote->volumes, $volume);
|
105 |
+
}
|
106 |
+
|
107 |
+
$body = json_encode($quote);
|
108 |
+
|
109 |
+
$s = curl_init();
|
110 |
+
curl_setopt($s, CURLOPT_TIMEOUT, 5000);
|
111 |
+
curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
|
112 |
+
/*if ($username != null && $password != null) {
|
113 |
+
curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
|
114 |
+
}*/
|
115 |
+
curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: $token"*/));
|
116 |
+
curl_setopt($s, CURLOPT_POST, true);
|
117 |
+
curl_setopt($s, CURLOPT_ENCODING , "");
|
118 |
+
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
|
119 |
+
curl_setopt($s, CURLOPT_POSTFIELDS, $body);
|
120 |
+
$responseBody = curl_exec($s);
|
121 |
+
|
122 |
+
$response = json_decode($responseBody);
|
123 |
+
// echo $responseBody;
|
124 |
+
curl_close($s);
|
125 |
+
|
126 |
+
$result = Mage::getModel('shipping/rate_result');
|
127 |
+
|
128 |
+
foreach ($response->content->delivery_options as $deliveryOption) {
|
129 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
130 |
+
|
131 |
+
$method->setCarrier ('intelipost');
|
132 |
+
$method->setCarrierTitle('Intelipost');
|
133 |
+
$method->setMethod ($deliveryOption->description);
|
134 |
+
$method->setMethodTitle ($deliveryOption->description);
|
135 |
+
$method->setPrice ($deliveryOption->final_shipping_cost);
|
136 |
+
$method->setCost ($deliveryOption->provider_shipping_cost);
|
137 |
+
|
138 |
+
$result->append($method);
|
139 |
+
}
|
140 |
+
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function getAllowedMethods() {
|
145 |
+
return array($this->_code => $this->getConfigData('name'));
|
146 |
+
}
|
147 |
+
|
148 |
+
private function isDimensionSet($product) {
|
149 |
+
$volume_altura = $product->getData('volume_altura');
|
150 |
+
$volume_largura = $product->getData('volume_largura');
|
151 |
+
$volume_comprimento = $product->getData('volume_comprimento');
|
152 |
+
|
153 |
+
if ($volume_comprimento == '' || (int)$volume_comprimento == 0
|
154 |
+
|| $volume_largura == '' || (int)$volume_largura == 0
|
155 |
+
|| $volume_altura == '' || (int)$volume_altura == 0
|
156 |
+
) {
|
157 |
+
return false;
|
158 |
+
}
|
159 |
+
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
|
163 |
+
private function notifyProductsDimension($item_list) {
|
164 |
+
$notification = Mage::getSingleton('adminnotification/inbox');
|
165 |
+
$message = $this->_helper->__('The following products do not have dimension set:');
|
166 |
+
|
167 |
+
$message .= '<ul>';
|
168 |
+
foreach ($item_list as $item) {
|
169 |
+
$product = $item->getProduct();
|
170 |
+
|
171 |
+
if (!$this->isDimensionSet($product)) {
|
172 |
+
$message .= '<li>';
|
173 |
+
$message .= sprintf(
|
174 |
+
'<a href="%s">',
|
175 |
+
Mage::helper('adminhtml')->getUrl(
|
176 |
+
'adminhtml/catalog_product/edit',
|
177 |
+
array( 'id' => $product->getId())
|
178 |
+
)
|
179 |
+
);
|
180 |
+
$message .= $item->getName();
|
181 |
+
$message .= '</a>';
|
182 |
+
$message .= '</li>';
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$message .= '</ul>';
|
186 |
+
|
187 |
+
$message .= $this->_helper->__('<small>Disable these notifications in System > Settings > Carriers > Intelipost</small>');
|
188 |
+
|
189 |
+
$notification->add(
|
190 |
+
Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR,
|
191 |
+
$this->_helper->__('Product missing dimensions'),
|
192 |
+
$message
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
private function formatDeadline($days) {
|
197 |
+
if ($days == 0) {
|
198 |
+
return $this->_helper->__('(same day)');
|
199 |
+
}
|
200 |
+
|
201 |
+
if ($days == 1) {
|
202 |
+
return $this->_helper->__('(1 day)');
|
203 |
+
}
|
204 |
+
|
205 |
+
if ($days == 101) {
|
206 |
+
return $this->_helper->__('(On acknowledgment)');
|
207 |
+
}
|
208 |
+
|
209 |
+
return sprintf($this->_helper->__('(%s days)'), $days);
|
210 |
+
}
|
211 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Config/Apikey.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Quote.php';
|
4 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Volume.php';
|
5 |
+
|
6 |
+
class Intelipost_Shipping_Model_Config_Apikey
|
7 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
8 |
+
{
|
9 |
+
|
10 |
+
public function save() {
|
11 |
+
$api_key = $this->getValue();
|
12 |
+
$token = $this->getData('groups/intelipost/fields/token/value');
|
13 |
+
$password = $this->getData('groups/intelipost/fields/password/value');
|
14 |
+
// $username = $this->getData('groups/intelipost/fields/account/value');
|
15 |
+
$password = 'mate20mg';
|
16 |
+
$username = 'projecta';
|
17 |
+
$helper = Mage::helper('intelipost');
|
18 |
+
|
19 |
+
$volume = new Intelipost_Model_Request_Volume();
|
20 |
+
$volume->weight = 10;
|
21 |
+
$volume->volume_type = 'BOX';
|
22 |
+
$volume->cost_of_goods = "10";
|
23 |
+
$volume->width = 1;
|
24 |
+
$volume->height = 1;
|
25 |
+
$volume->length = 1;
|
26 |
+
|
27 |
+
$quote = new Intelipost_Model_Request_Quote();
|
28 |
+
$quote->origin_zip_code = "04037-002";
|
29 |
+
$quote->destination_zip_code = "04037-002";
|
30 |
+
array_push($quote->volumes, $volume);
|
31 |
+
|
32 |
+
$body = json_encode($quote);
|
33 |
+
$s = curl_init();
|
34 |
+
curl_setopt($s, CURLOPT_TIMEOUT, 5000);
|
35 |
+
curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
|
36 |
+
if ($username != null && $password != null) {
|
37 |
+
curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
|
38 |
+
}
|
39 |
+
curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: testtoken"*/));
|
40 |
+
curl_setopt($s, CURLOPT_POST, true);
|
41 |
+
curl_setopt($s, CURLOPT_ENCODING , "");
|
42 |
+
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
|
43 |
+
curl_setopt($s, CURLOPT_POSTFIELDS, $body);
|
44 |
+
|
45 |
+
$responseBody = curl_exec($s);
|
46 |
+
|
47 |
+
$response = json_decode($responseBody);
|
48 |
+
curl_close($s);
|
49 |
+
|
50 |
+
if (!isset($response->status)) {
|
51 |
+
// Mage::getSingleton('core/session')->addWarning($helper->__('Could not validate username and password!'));
|
52 |
+
Mage::throwException($helper->__('Invalid ApiKey!'));
|
53 |
+
}
|
54 |
+
|
55 |
+
parent::save();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
app/code/local/Intelipost/Shipping/Model/Config/Apikey.php~
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Quote.php';
|
4 |
+
require_once Mage::getBaseDir('code') . '/local/Intelipost/Shipping/Model/Resource/Volume.php';
|
5 |
+
|
6 |
+
class Intelipost_Shipping_Model_Config_Apikey
|
7 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
8 |
+
{
|
9 |
+
|
10 |
+
public function save() {
|
11 |
+
$api_key = $this->getValue();
|
12 |
+
// $token = $this->getData('groups/intelipost/fields/token/value');
|
13 |
+
// $password = $this->getData('groups/intelipost/fields/password/value');
|
14 |
+
// $username = $this->getData('groups/intelipost/fields/account/value');
|
15 |
+
$helper = Mage::helper('intelipost');
|
16 |
+
|
17 |
+
$volume = new Intelipost_Model_Request_Volume();
|
18 |
+
$volume->weight = 10;
|
19 |
+
$volume->volume_type = 'BOX';
|
20 |
+
$volume->cost_of_goods = "10";
|
21 |
+
$volume->width = 1;
|
22 |
+
$volume->height = 1;
|
23 |
+
$volume->length = 1;
|
24 |
+
|
25 |
+
$quote = new Intelipost_Model_Request_Quote();
|
26 |
+
$quote->origin_zip_code = "04037-002";
|
27 |
+
$quote->destination_zip_code = "04037-002";
|
28 |
+
array_push($quote->volumes, $volume);
|
29 |
+
|
30 |
+
$body = json_encode($quote);
|
31 |
+
$s = curl_init();
|
32 |
+
curl_setopt($s, CURLOPT_TIMEOUT, 5000);
|
33 |
+
curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
|
34 |
+
// if ($this->username != null && $this->password != null) {
|
35 |
+
// curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
|
36 |
+
// }
|
37 |
+
curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: $token"*/));
|
38 |
+
curl_setopt($s, CURLOPT_POST, true);
|
39 |
+
curl_setopt($s, CURLOPT_ENCODING , "");
|
40 |
+
curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
|
41 |
+
curl_setopt($s, CURLOPT_POSTFIELDS, $body);
|
42 |
+
|
43 |
+
$responseBody = curl_exec($s);
|
44 |
+
Mage::log(var_dump($responseBody, true), null, intelipost.log);
|
45 |
+
$responseBody = curl_exec($s);
|
46 |
+
Mage::log(var_dump($responseBody, true), null, intelipost.log);
|
47 |
+
|
48 |
+
$response = json_decode($responseBody);
|
49 |
+
curl_close($s);
|
50 |
+
|
51 |
+
if (!isset($response->status)) {
|
52 |
+
// Mage::getSingleton('core/session')->addWarning($helper->__('Could not validate username and password!'));
|
53 |
+
Mage::throwException($helper->__('Invalid ApiKey!'));
|
54 |
+
}
|
55 |
+
|
56 |
+
parent::save();
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Config/Password.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intelipost_Shipping_Model_Config_Password
|
4 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
5 |
+
{
|
6 |
+
|
7 |
+
public function save() {
|
8 |
+
|
9 |
+
$password = $this->getValue();
|
10 |
+
parent::save();
|
11 |
+
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Config/Token.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intelipost_Shipping_Model_Config_Token
|
4 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
5 |
+
{
|
6 |
+
|
7 |
+
public function save() {
|
8 |
+
|
9 |
+
$token = $this->getValue();
|
10 |
+
parent::save();
|
11 |
+
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Config/Useraccount.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intelipost_Shipping_Model_Config_Useraccount
|
4 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
|
5 |
+
{
|
6 |
+
|
7 |
+
public function save() {
|
8 |
+
|
9 |
+
$useraccount = $this->getValue();
|
10 |
+
parent::save();
|
11 |
+
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Resource/Quote.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author eSprinter (it@e-sprinter.com.br)
|
5 |
+
*/
|
6 |
+
class Intelipost_Model_Request_Quote {
|
7 |
+
public $origin_zip_code;
|
8 |
+
public $destination_zip_code;
|
9 |
+
/**
|
10 |
+
* @var ESprinter_Model_Request_Volume[]
|
11 |
+
*/
|
12 |
+
public $volumes = array();
|
13 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Intelipost_Shipping_Model_Resource_Setup
|
5 |
+
extends Mage_Eav_Model_Entity_Setup
|
6 |
+
{
|
7 |
+
public function getDefaultEntities() {
|
8 |
+
return array(
|
9 |
+
// 'catalog_product' => array(
|
10 |
+
// 'catalog/product' => array(
|
11 |
+
Mage_Catalog_Model_Product::ENTITY => array(
|
12 |
+
'entity_model' => 'catalog/product',
|
13 |
+
'attribute_model' => 'catalog/resource_eav_attribute',
|
14 |
+
'table' => 'catalog/product',
|
15 |
+
|
16 |
+
// INFO: these two entries bellow are needed for magento 1.4, they do not exist on magento 1.3!
|
17 |
+
'additional_attribute_table' => 'catalog/eav_attribute',
|
18 |
+
'entity_attribute_collection' => 'catalog/product_attribute_collection',
|
19 |
+
|
20 |
+
// this seems to break the shopping cart (http://www.magentocommerce.com/boards/viewthread/176130/#t232548)
|
21 |
+
// 'entity_attribute_collection' => 'catalog/category_attribute_collection',
|
22 |
+
|
23 |
+
// 'frontend_prefix' => '',
|
24 |
+
// 'backend_prefix' => '',
|
25 |
+
// 'source_prefix' => '',
|
26 |
+
|
27 |
+
'attributes' => array(
|
28 |
+
// attributes are called 'volume_altura', 'volume_largura', and 'volume_comprimento' so that this plugin is compatible with
|
29 |
+
// the Correios plugin
|
30 |
+
// 'height' => array(
|
31 |
+
'volume_altura' => array(
|
32 |
+
'group' => 'General', // tab
|
33 |
+
'type' => 'int', // magento attribute type
|
34 |
+
'backend' => '',
|
35 |
+
'frontend' => '',
|
36 |
+
'label' => 'Height',
|
37 |
+
'input' => 'text',
|
38 |
+
'class' => '', // input validation class
|
39 |
+
'source' => '', // options for the select
|
40 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
41 |
+
'visible' => true,
|
42 |
+
'required' => false,
|
43 |
+
'user_defined' => false, // true => user attribute, false => system attribute
|
44 |
+
'default' => '',
|
45 |
+
'searchable' => false,
|
46 |
+
'filterable' => false,
|
47 |
+
'comparable' => false,
|
48 |
+
'visible_on_front' => false,
|
49 |
+
'used_in_product_listing' => true, // needed to load this EAV attribute on collectRates()
|
50 |
+
'unique' => false,
|
51 |
+
'apply_to' => array('bundle,simple'), //array('bundle,virtual,simple'),
|
52 |
+
'is_configurable' => false
|
53 |
+
),
|
54 |
+
// 'width' => array(
|
55 |
+
'volume_largura' => array(
|
56 |
+
'group' => 'General', // tab
|
57 |
+
'type' => 'int', // magento attribute type
|
58 |
+
'backend' => '',
|
59 |
+
'frontend' => '',
|
60 |
+
'label' => 'Width',
|
61 |
+
'input' => 'text',
|
62 |
+
'class' => '', // input validation class
|
63 |
+
'source' => '', // options for the select
|
64 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
65 |
+
'visible' => true,
|
66 |
+
'required' => false,
|
67 |
+
'user_defined' => false, // true => user attribute, false => system attribute
|
68 |
+
'default' => '',
|
69 |
+
'searchable' => false,
|
70 |
+
'filterable' => false,
|
71 |
+
'comparable' => false,
|
72 |
+
'visible_on_front' => false,
|
73 |
+
'used_in_product_listing' => true, // needed to load this EAV attribute on collectRates()
|
74 |
+
'unique' => false,
|
75 |
+
'apply_to' => array('bundle,simple'), //array('bundle,virtual,simple'),
|
76 |
+
'is_configurable' => false
|
77 |
+
),
|
78 |
+
// 'length' => array(
|
79 |
+
'volume_comprimento' => array(
|
80 |
+
'group' => 'General', // tab
|
81 |
+
'type' => 'int', // magento attribute type
|
82 |
+
'backend' => '',
|
83 |
+
'frontend' => '',
|
84 |
+
'label' => 'Length',
|
85 |
+
'input' => 'text',
|
86 |
+
'class' => '', // input validation class
|
87 |
+
'source' => '', // options for the select
|
88 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
89 |
+
'visible' => true,
|
90 |
+
'required' => false,
|
91 |
+
'user_defined' => false, // true => user attribute, false => system attribute
|
92 |
+
'default' => '',
|
93 |
+
'searchable' => false,
|
94 |
+
'filterable' => false,
|
95 |
+
'comparable' => false,
|
96 |
+
'visible_on_front' => false,
|
97 |
+
'used_in_product_listing' => true, // needed to load this EAV attribute on collectRates()
|
98 |
+
'unique' => false,
|
99 |
+
'apply_to' => array('bundle,simple'), //array('bundle,virtual,simple'),
|
100 |
+
'is_configurable' => false
|
101 |
+
)
|
102 |
+
)
|
103 |
+
)
|
104 |
+
);
|
105 |
+
}
|
106 |
+
}
|
app/code/local/Intelipost/Shipping/Model/Resource/Volume.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author eSprinter (it@e-sprinter.com.br)
|
4 |
+
*/
|
5 |
+
|
6 |
+
class Intelipost_Model_Request_Volume {
|
7 |
+
/**
|
8 |
+
* @var double
|
9 |
+
*/
|
10 |
+
public $weight;
|
11 |
+
/**
|
12 |
+
* @var string[BOX|ENVELOPE]
|
13 |
+
*/
|
14 |
+
public $volume_type;
|
15 |
+
/**
|
16 |
+
* @var double
|
17 |
+
*/
|
18 |
+
public $cost_of_goods;
|
19 |
+
/**
|
20 |
+
* @var double
|
21 |
+
*/
|
22 |
+
public $width;
|
23 |
+
/**
|
24 |
+
* @var double
|
25 |
+
*/
|
26 |
+
public $height;
|
27 |
+
/**
|
28 |
+
* @var double
|
29 |
+
*/
|
30 |
+
public $length;
|
31 |
+
|
32 |
+
}
|
app/code/local/Intelipost/Shipping/etc/config.xml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Intelipost_Shipping>
|
6 |
+
<version>0.0.1</version>
|
7 |
+
</Intelipost_Shipping>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<global>
|
11 |
+
<models>
|
12 |
+
<intelipost_shipping>
|
13 |
+
<class>Intelipost_Shipping_Model</class>
|
14 |
+
</intelipost_shipping>
|
15 |
+
</models>
|
16 |
+
|
17 |
+
<helpers>
|
18 |
+
<intelipost>
|
19 |
+
<class>Intelipost_Shipping_Helper</class>
|
20 |
+
</intelipost>
|
21 |
+
</helpers>
|
22 |
+
|
23 |
+
<resources>
|
24 |
+
<intelipost_setup>
|
25 |
+
<setup>
|
26 |
+
<module>Intelipost_Shipping</module>
|
27 |
+
<class>Intelipost_Shipping_Model_Resource_Setup</class>
|
28 |
+
</setup>
|
29 |
+
</intelipost_setup>
|
30 |
+
</resources>
|
31 |
+
|
32 |
+
<sales>
|
33 |
+
<quote>
|
34 |
+
<item>
|
35 |
+
<product_attributes>
|
36 |
+
<volume_altura />
|
37 |
+
<volume_largura />
|
38 |
+
<volume_comprimento />
|
39 |
+
</product_attributes>
|
40 |
+
</item>
|
41 |
+
</quote>
|
42 |
+
</sales>
|
43 |
+
</global>
|
44 |
+
|
45 |
+
<adminhtml>
|
46 |
+
<translate>
|
47 |
+
<modules>
|
48 |
+
<Intelipost_Shipping>
|
49 |
+
<files>
|
50 |
+
<default>Intelipost_Shipping.csv</default>
|
51 |
+
</files>
|
52 |
+
</Intelipost_Shipping>
|
53 |
+
</modules>
|
54 |
+
</translate>
|
55 |
+
</adminhtml>
|
56 |
+
|
57 |
+
<frontend>
|
58 |
+
<translate>
|
59 |
+
<modules>
|
60 |
+
<Intelipost_Shipping>
|
61 |
+
<files>
|
62 |
+
<default>Intelipost_Shipping.csv</default>
|
63 |
+
</files>
|
64 |
+
</Intelipost_Shipping>
|
65 |
+
</modules>
|
66 |
+
</translate>
|
67 |
+
</frontend>
|
68 |
+
|
69 |
+
<default>
|
70 |
+
<carriers>
|
71 |
+
<intelipost>
|
72 |
+
<active>1</active>
|
73 |
+
<model>intelipost_shipping/carrier_intelipost</model>
|
74 |
+
<name>Intelipost</name>
|
75 |
+
<title>Intelipost</title>
|
76 |
+
<notification>1</notification>
|
77 |
+
</intelipost>
|
78 |
+
</carriers>
|
79 |
+
</default>
|
80 |
+
|
81 |
+
</config>
|
app/code/local/Intelipost/Shipping/etc/system.xml
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<carriers>
|
6 |
+
<groups>
|
7 |
+
<intelipost translate="label" module="shipping">
|
8 |
+
<label>Intelipost Shipping</label>
|
9 |
+
<frontend_type>text</frontend_type>
|
10 |
+
<sort_order>5</sort_order>
|
11 |
+
<show_in_default>1</show_in_default>
|
12 |
+
<show_in_website>1</show_in_website>
|
13 |
+
<show_in_store>1</show_in_store>
|
14 |
+
|
15 |
+
<fields>
|
16 |
+
<active translate="label">
|
17 |
+
<label>Enabled</label>
|
18 |
+
<frontend_type>select</frontend_type>
|
19 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
20 |
+
<sort_order>1</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
</active>
|
25 |
+
|
26 |
+
<!-- <account translate="label">
|
27 |
+
<label>User Account</label>
|
28 |
+
<frontend_type>text</frontend_type>
|
29 |
+
<backend_model>intelipost_shipping/config_useraccount</backend_model>
|
30 |
+
<validate>required-entry</validate>
|
31 |
+
<sort_order>2</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
</account> -->
|
36 |
+
|
37 |
+
<!-- Model/Config/Password depends on this tag name + hierarchy -->
|
38 |
+
<!-- <password translate="label">
|
39 |
+
<label>Password</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<backend_model>intelipost_shipping/config_password</backend_model>
|
42 |
+
<validate>required-entry</validate>
|
43 |
+
<sort_order>3</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
</password> -->
|
48 |
+
|
49 |
+
<apikey translate="label">
|
50 |
+
<label>API Key</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<backend_model>intelipost_shipping/config_apikey</backend_model>
|
53 |
+
<validate>required-entry</validate>
|
54 |
+
<sort_order>4</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>1</show_in_store>
|
58 |
+
</apikey>
|
59 |
+
|
60 |
+
<!-- <token translate="label">
|
61 |
+
<label>Token</label>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<backend_model>intelipost_shipping/config_token</backend_model>
|
64 |
+
<validate>required-entry</validate>
|
65 |
+
<sort_order>5</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
</token> -->
|
70 |
+
|
71 |
+
<zipcode translate="label">
|
72 |
+
<label>Postal Code</label>
|
73 |
+
<frontend_type>text</frontend_type>
|
74 |
+
<!--<validate>validate-zip-international required-entry</validate>-->
|
75 |
+
<validate>required-entry</validate>
|
76 |
+
<sort_order>6</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
</zipcode>
|
81 |
+
|
82 |
+
<!-- <category translate="label">
|
83 |
+
<label>Choose the best fitting category for your products</label>
|
84 |
+
<frontend_type>select</frontend_type>
|
85 |
+
<source_model>intelipost_shipping/carrier_category</source_model>
|
86 |
+
<sort_order>7</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
</category>-->
|
91 |
+
|
92 |
+
<notification translate="label">
|
93 |
+
<label>Enable dimension check and notifications</label>
|
94 |
+
<frontend_type>select</frontend_type>
|
95 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
96 |
+
<sort_order>8</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>1</show_in_store>
|
100 |
+
</notification>
|
101 |
+
|
102 |
+
<!-- <webservice_url translate="label">
|
103 |
+
<label>Axado's webservice url</label>
|
104 |
+
<frontend_type>text</frontend_type>
|
105 |
+
<sort_order>10</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</webservice_url> -->
|
110 |
+
</fields>
|
111 |
+
|
112 |
+
</intelipost>
|
113 |
+
</groups>
|
114 |
+
</carriers>
|
115 |
+
</sections>
|
116 |
+
</config>
|
app/code/local/Intelipost/Shipping/sql/intelipost_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// EIntelipost_Shipping_Model_Resource_Setup
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
$installer->installEntities();
|
8 |
+
$installer->endSetup();
|
app/etc/modules/Intelipost_Shipping.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Intelipost_Shipping>
|
6 |
+
<active>true</active>
|
7 |
+
<codePool>local</codePool>
|
8 |
+
<depends>
|
9 |
+
<Mage_Shipping />
|
10 |
+
</depends>
|
11 |
+
</Intelipost_Shipping>
|
12 |
+
</modules>
|
13 |
+
<global>
|
14 |
+
<sales>
|
15 |
+
<quote>
|
16 |
+
<item>
|
17 |
+
<product_attributes>
|
18 |
+
<height />
|
19 |
+
<length />
|
20 |
+
<width />
|
21 |
+
</product_attributes>
|
22 |
+
</item>
|
23 |
+
</quote>
|
24 |
+
</sales>
|
25 |
+
</global>
|
26 |
+
</config>
|
app/locale/pt_BR/Intelipost_Shipping.csv
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"User Account","Usuário"
|
2 |
+
"Postal Code","CEP"
|
3 |
+
"Choose the best fitting category for your products","Escolha a melhor categoria para os seus produtos"
|
4 |
+
"Enable notification","Habilitar notificações"
|
5 |
+
"Enable notification and dimension check","Habilitar notificações e validação de dimensões"
|
6 |
+
"Enable dimension check and notifications","Habilitar validação de dimensões e notificações"
|
7 |
+
"Alcoholic","Bebidas"
|
8 |
+
"Beverages","Líquidos Diversos"
|
9 |
+
"Books and/or graphical material","Livros ou Materiais gráficos"
|
10 |
+
"Clothing","Roupas e vestuários"
|
11 |
+
"Cosmetics","Cosméticos"
|
12 |
+
"Documents","Documentos"
|
13 |
+
"Eletronics","Eletrônicos e informática"
|
14 |
+
"Floriculture","Floricultura"
|
15 |
+
"Food","Alimentos"
|
16 |
+
"Fragile products","Produto Frágil"
|
17 |
+
"High value products","Objetos de alto valor"
|
18 |
+
"Machinery and/or parts","Máquinas ou Peças em geral"
|
19 |
+
"Office supplies and furniture","Móveis ou Objetos de escritório"
|
20 |
+
"Pharmacy","Produto Farmacêutico"
|
21 |
+
"Toys","Brinquedos"
|
22 |
+
"The following products do not have dimension set:","Os seguintes produtos não tem as dimensões definidas:"
|
23 |
+
"<small>Disable these notifications in System > Settings > Carriers > Intelipost</small>","<small>Desabilite as notifações em Sistema > Configuração > Métodos de envio > Intelipost</small>"
|
24 |
+
"Product missing dimensions","Produto sem dimensões"
|
25 |
+
"(same day)","(mesmo dia)"
|
26 |
+
"(1 day)","(1 dia útil)"
|
27 |
+
"(On acknowledgment)","(Sob consulta)"
|
28 |
+
"(%s days)","(%s dias úteis)"
|
29 |
+
"User account has the wrong size!","Usuário/Senha não número certo de caracteres!"
|
30 |
+
"Invalid username or password!","Usuário e/ou senha inválidos!"
|
31 |
+
"Could not validate username and password!","Erro ao validar usuário e senha"
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Intelipost</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License Version 2 (GPLv2)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Intelipost</summary>
|
10 |
+
<description>Extens&#xE3;o para utilizar o servi&#xE7;o de cota&#xE7;&#xE3;o do intelipost.com.br . 
|
11 |
+
Gateway de logística para o e-commerce</description>
|
12 |
+
<notes>---</notes>
|
13 |
+
<authors><author><name>Intelipost</name><user>Intelipost</user><email>info@intelipost.com.br</email></author></authors>
|
14 |
+
<date>2014-03-27</date>
|
15 |
+
<time>11:14:30</time>
|
16 |
+
<contents><target name="magelocal"><dir><dir name="Intelipost"><dir name="Shipping"><dir name="Helper"><file name="Data.php" hash="7523e254d75d8ec6413164bdfc9484ce"/></dir><dir name="Model"><dir name="Carrier"><file name="Category.php" hash="9e3f8a5013f819dc65c9b84848182c8a"/><file name="Intelipost.php" hash="ed0b097f70db82ca33e0f2107fe2f34d"/><file name="Intelipost.php~" hash="fc48f350e774fae6523449efedbccf62"/></dir><dir name="Config"><file name="Apikey.php" hash="b74ed350e2aad08f58f56caaa2b6f7a4"/><file name="Apikey.php~" hash="9df9c5ccba568dfc991586151894b6b5"/><file name="Password.php" hash="a3b0f867850520e637ed6d1561047093"/><file name="Token.php" hash="ae2ef4b4527f06c17061d6c984fa0a28"/><file name="Useraccount.php" hash="89a67edacda5169a4f58590e6ac24006"/></dir><dir name="Resource"><file name="Quote.php" hash="1f02542b8f6c4a16400da34e723c0541"/><file name="Setup.php" hash="8f10c3277be3454dbf61abb1fb0b06f4"/><file name="Volume.php" hash="e1e8de42eeb5d1e02e7ebc4a2dff6dd0"/></dir></dir><dir name="etc"><file name="config.xml" hash="5e5cf688524df28ee306b11424804363"/><file name="system.xml" hash="ff6564d28de2203c67379147d24fdea7"/></dir><dir name="sql"><dir name="intelipost_setup"><file name="mysql4-install-0.0.1.php" hash="7cbddb7bad3e35cba43d14d8e2308900"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelipost_Shipping.xml" hash="285e60144ae15077910cb9200038adb9"/></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="Intelipost_Shipping.csv" hash="ae1e673344d004666d04b254556685c5"/></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|