Version Notes
- Fixed an issue the locale folder
Download this release
Release Info
Developer | Parcify |
Extension | PARCIFY |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- app/code/community/Parcify/.DS_Store +0 -0
- app/code/community/Parcify/Carrier/.DS_Store +0 -0
- app/code/community/Parcify/Carrier/Model/Carrier.php +161 -0
- app/code/community/Parcify/Carrier/Model/Observer.php +274 -0
- app/code/community/Parcify/Carrier/etc/config.xml +55 -0
- app/code/community/Parcify/Carrier/etc/system.xml +187 -0
- app/code/community/Parcify/Carrier/locale/.DS_Store +0 -0
- app/code/community/Parcify/Carrier/locale/fr_FR/Parcify_Carrier.csv +1 -0
- app/code/community/Parcify/Carrier/locale/nl_NL/Parcify_Carrier.csv +1 -0
- app/etc/modules/Parcify_Carrier.xml +12 -0
- package.xml +3 -3
app/code/community/Parcify/.DS_Store
ADDED
Binary file
|
app/code/community/Parcify/Carrier/.DS_Store
ADDED
Binary file
|
app/code/community/Parcify/Carrier/Model/Carrier.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Parcify_Carrier_Model_Carrier
|
5 |
+
*/
|
6 |
+
class Parcify_Carrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
|
7 |
+
{
|
8 |
+
|
9 |
+
// Properties
|
10 |
+
protected $_code = 'parcify_carrier';
|
11 |
+
protected static $_parcifyCache = array();
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Collect rates for Parcify shipping method
|
15 |
+
*
|
16 |
+
* @param \Mage_Shipping_Model_Rate_Request $request
|
17 |
+
* @return bool|false|\Mage_Core_Model_Abstract|\Mage_Shipping_Model_Rate_Result
|
18 |
+
*/
|
19 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
20 |
+
{
|
21 |
+
$result = Mage::getModel('shipping/rate_result');
|
22 |
+
/* @var $result Mage_Shipping_Model_Rate_Result */
|
23 |
+
|
24 |
+
// Only available in Antwerp
|
25 |
+
$availablePostCodes = array('2000', '2020', '2050', '2060', '2018', '2600', '2610', '2140', '2100');
|
26 |
+
if (!in_array($request->getDestPostcode(), $availablePostCodes)) {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
if (($request->getFreeShipping()) || ($request->getBaseSubtotalInclTax() >= $this->getConfigData('free_shipping_subtotal'))) {
|
31 |
+
/**
|
32 |
+
* If the request has the free shipping flag,
|
33 |
+
* append a free shipping rate to the result.
|
34 |
+
*/
|
35 |
+
$shippingRate = $this->_getFreeShippingRate();
|
36 |
+
$result->append($shippingRate);
|
37 |
+
} else {
|
38 |
+
/**
|
39 |
+
* Standard rate.
|
40 |
+
*/
|
41 |
+
$shippingRate = $this->_getStandardShippingRate();
|
42 |
+
$result->append($shippingRate);
|
43 |
+
}
|
44 |
+
|
45 |
+
return $result;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get standard shipping rate
|
50 |
+
*
|
51 |
+
* @return false|\Mage_Core_Model_Abstract|\Mage_Shipping_Model_Rate_Result_Method
|
52 |
+
*/
|
53 |
+
protected function _getStandardShippingRate()
|
54 |
+
{
|
55 |
+
$rate = Mage::getModel('shipping/rate_result_method');
|
56 |
+
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
57 |
+
|
58 |
+
$rate->setCarrier($this->_code);
|
59 |
+
$rate->setCarrierTitle($this->getConfigData('title'));
|
60 |
+
$rate->setMethod('free_shipping');
|
61 |
+
$lbl = __('Personal delivery');
|
62 |
+
$rate->setMethodTitle($lbl);
|
63 |
+
|
64 |
+
$price = $this->getConfigData('price');
|
65 |
+
$rate->setPrice($price);
|
66 |
+
$rate->setCost(0);
|
67 |
+
|
68 |
+
return $rate;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get free shipping rate
|
74 |
+
*
|
75 |
+
* @return false|\Mage_Core_Model_Abstract|\Mage_Shipping_Model_Rate_Result_Method
|
76 |
+
*/
|
77 |
+
protected function _getFreeShippingRate()
|
78 |
+
{
|
79 |
+
$rate = Mage::getModel('shipping/rate_result_method');
|
80 |
+
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
81 |
+
$rate->setCarrier($this->_code);
|
82 |
+
$rate->setCarrierTitle($this->getConfigData('title'));
|
83 |
+
$rate->setMethod('free_shipping');
|
84 |
+
$lbl = __('Personal delivery');
|
85 |
+
$rate->setMethodTitle($lbl);
|
86 |
+
$rate->setPrice(0);
|
87 |
+
$rate->setCost(0);
|
88 |
+
|
89 |
+
return $rate;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Helper function - get allowed methods
|
94 |
+
*
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
public function getAllowedMethods()
|
98 |
+
{
|
99 |
+
return array(
|
100 |
+
'standard' => 'Standard',
|
101 |
+
'free_shipping' => 'Free Shipping',
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Return code of carrier
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
public function getCarrierCode()
|
111 |
+
{
|
112 |
+
return isset($this->_code) ? $this->_code : null;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Returns cache key for some request to Parcify service
|
117 |
+
*
|
118 |
+
* @param string|array $requestParams
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
protected function _getDataCacheKey($requestParams)
|
122 |
+
{
|
123 |
+
if (is_array($requestParams)) {
|
124 |
+
$requestParams = implode(',', array_merge(
|
125 |
+
array($this->getCarrierCode()),
|
126 |
+
array_keys($requestParams),
|
127 |
+
$requestParams)
|
128 |
+
);
|
129 |
+
}
|
130 |
+
return crc32($requestParams);
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Checks whether some request to rates have already been done, so we have cache for it
|
135 |
+
* Used to reduce number of same requests done to carrier service during one session
|
136 |
+
*
|
137 |
+
* Returns cached response or null
|
138 |
+
*
|
139 |
+
* @param string|array $requestParams
|
140 |
+
* @return null|string
|
141 |
+
*/
|
142 |
+
protected function _getCachedData($requestParams)
|
143 |
+
{
|
144 |
+
$key = $this->_getDataCacheKey($requestParams);
|
145 |
+
return isset(self::$_parcifyCache[$key]) ? self::$_parcifyCache[$key] : null;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Sets received carrier quotes to cache
|
150 |
+
*
|
151 |
+
* @param string|array $requestParams
|
152 |
+
* @param string $response
|
153 |
+
* @return Mage_Usa_Model_Shipping_Carrier_Abstract
|
154 |
+
*/
|
155 |
+
protected function _setCachedData($requestParams, $response)
|
156 |
+
{
|
157 |
+
$key = $this->_getDataCacheKey($requestParams);
|
158 |
+
self::$_parcifyCache[$key] = $response;
|
159 |
+
return $this;
|
160 |
+
}
|
161 |
+
}
|
app/code/community/Parcify/Carrier/Model/Observer.php
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Parcify_Carrier_Model_Observer
|
5 |
+
*/
|
6 |
+
class Parcify_Carrier_Model_Observer
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Register Shipment as Parcify parcel
|
10 |
+
* Magento event overwrite
|
11 |
+
*
|
12 |
+
* @param \Magento $observer
|
13 |
+
*/
|
14 |
+
public function salesOrderShipmentSaveBefore(Magento $observer)
|
15 |
+
{
|
16 |
+
// Config data
|
17 |
+
// $carrier = Mage::getStoreConfig('carriers/parcify_carrier');
|
18 |
+
$origin = Mage::getStoreConfig('shipping/origin');
|
19 |
+
|
20 |
+
// Get Shipment
|
21 |
+
$shipment = $observer->getEvent()->getShipment();
|
22 |
+
|
23 |
+
// Get order
|
24 |
+
$order = Mage::getModel('sales/order')->load($shipment->getOrderId());
|
25 |
+
|
26 |
+
// Get customer shipment address and contact info
|
27 |
+
$shippingAddress = $order->getShippingAddress();
|
28 |
+
// var_dump($order->getData());
|
29 |
+
// var_dump($shippingAddress->getData());
|
30 |
+
|
31 |
+
if (strpos($order->getShippingMethod(), 'parcify') !== false) {
|
32 |
+
// New parcel
|
33 |
+
$parcel = $this->newParcel();
|
34 |
+
|
35 |
+
// Name
|
36 |
+
$parcelNamePrefix = Mage::getStoreConfig('carriers/parcify_carrier/parcelname');
|
37 |
+
$parcel->package->name = $parcelNamePrefix.$order->getIncrementId();
|
38 |
+
|
39 |
+
// Receiver
|
40 |
+
$parcel->delivery->receiver->email = $shippingAddress->getEmail();
|
41 |
+
$parcel->delivery->receiver->mobileNumber = $shippingAddress->getTelephone();
|
42 |
+
|
43 |
+
// Pickup address
|
44 |
+
$pickupAddress = Mage::getStoreConfig('carriers/parcify_carrier/pickup_address');
|
45 |
+
if (!empty($pickupAddress)) {
|
46 |
+
// Use pick-up address from Config
|
47 |
+
$parcel->pickup->address = $pickupAddress;
|
48 |
+
} else {
|
49 |
+
// Use Magento Origin as pick-up address
|
50 |
+
$parcel->pickup->address = $this->getPickupAddress($origin);
|
51 |
+
}
|
52 |
+
|
53 |
+
// Delivery address
|
54 |
+
$parcel->delivery->address = $this->getDeliveryAddress($shippingAddress);
|
55 |
+
|
56 |
+
// Create parcel
|
57 |
+
$response = $this->createParcifyParcel($parcel);
|
58 |
+
|
59 |
+
if ($response['code'] == '200') {
|
60 |
+
// Success parcel created
|
61 |
+
if (isset($response['body'], $response['body']['parcelId'])) {
|
62 |
+
$track = Mage::getModel('sales/order_shipment_track')
|
63 |
+
->setNumber($response['body']['parcelId'])//tracking number / awb number
|
64 |
+
->setCarrierCode('Parcify')//carrier code
|
65 |
+
->setTitle('Parcel'); //carrier title
|
66 |
+
$shipment->addTrack($track);
|
67 |
+
}
|
68 |
+
// Success notification
|
69 |
+
Mage::getSingleton('core/session')->addSuccess('Successful registered shipment as Parcify parcel.');
|
70 |
+
|
71 |
+
} else {
|
72 |
+
$errorMsg = '';
|
73 |
+
|
74 |
+
if (isset($response['body'], $response['body']['errors'])) {
|
75 |
+
foreach ($response['body']['errors'] as $error) {
|
76 |
+
$errorMsg .= $error;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
// Error notification
|
80 |
+
Mage::getSingleton('core/session')->addError('Error creating Parcify parcel: '.$errorMsg);
|
81 |
+
|
82 |
+
// Prevent from saving the shipment
|
83 |
+
Mage::app()->getResponse()->setRedirect($_SERVER['HTTP_REFERER']);
|
84 |
+
Mage::app()->getResponse()->sendResponse();
|
85 |
+
exit;
|
86 |
+
}
|
87 |
+
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Initiate new Parcel object skeleton
|
93 |
+
*
|
94 |
+
* @return \stdClass
|
95 |
+
*/
|
96 |
+
public function newParcel()
|
97 |
+
{
|
98 |
+
// New parcel
|
99 |
+
$parcel = new stdClass();
|
100 |
+
|
101 |
+
// Set parcel info
|
102 |
+
$parcel->package->imageId;
|
103 |
+
$parcel->package->name = Mage::getStoreConfig('carriers/parcify_carrier/parcelname');
|
104 |
+
$parcel->package->instructions;
|
105 |
+
|
106 |
+
// Set sender info
|
107 |
+
$parcel->pickup->sender->id = Mage::getStoreConfig('carriers/parcify_carrier/userid');
|
108 |
+
|
109 |
+
// Set receiver info
|
110 |
+
$parcel->delivery->receiver->mobileNumber;
|
111 |
+
$parcel->delivery->receiver->email;
|
112 |
+
|
113 |
+
// Set delivery address
|
114 |
+
$parcel->delivery->address;
|
115 |
+
|
116 |
+
// Set pickup address
|
117 |
+
$parcel->pickup->address;
|
118 |
+
|
119 |
+
return $parcel;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get full delivery address from Order shippingAddress
|
124 |
+
*
|
125 |
+
* @param $shippingAddress
|
126 |
+
* @return string
|
127 |
+
*/
|
128 |
+
public function getDeliveryAddress($shippingAddress)
|
129 |
+
{
|
130 |
+
// Street
|
131 |
+
$streetAddress = $shippingAddress->getStreetFull();
|
132 |
+
$street = (!empty($streetAddress) ? $streetAddress.', ' : '');
|
133 |
+
$postCodeAddress = $shippingAddress->getPostcode();
|
134 |
+
$postCode = (!empty($postCodeAddress) ? $postCodeAddress.' ' : '');
|
135 |
+
$cityAddress = $shippingAddress->getCity();
|
136 |
+
$city = (!empty($cityAddress) ? $cityAddress.', ' : '');
|
137 |
+
$regionAddress = $shippingAddress->getRegion();
|
138 |
+
$region = (!empty($regionAddress) ? $regionAddress.', ' : '');
|
139 |
+
$countryCode = $shippingAddress->getCountry();
|
140 |
+
$countryAddress = Mage::app()->getLocale()->getCountryTranslation($countryCode);
|
141 |
+
$country = (!empty($countryAddress) ? $countryAddress : '');
|
142 |
+
|
143 |
+
$fullAddress = $street.$postCode.$city.$region.$country;
|
144 |
+
|
145 |
+
return $fullAddress;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get full pickup address from Store Shipping Origin settings
|
150 |
+
*
|
151 |
+
* @param $origin
|
152 |
+
* @return string
|
153 |
+
*/
|
154 |
+
public function getPickupAddress($origin)
|
155 |
+
{
|
156 |
+
// Street
|
157 |
+
$streetAddress1 = $origin['street_line1'];
|
158 |
+
$street1 = (!empty($streetAddress1) ? $streetAddress1.' ' : '');
|
159 |
+
$streetAddress2 = $origin['street_line2'];
|
160 |
+
$street2 = (!empty($streetAddress2) ? $streetAddress2 : '');
|
161 |
+
$streetAddress = $street1.$street2;
|
162 |
+
$street = (!empty($streetAddress) ? $streetAddress.', ' : '');
|
163 |
+
$postCodeAddress = $origin['postcode'];
|
164 |
+
$postCode = (!empty($postCodeAddress) ? $postCodeAddress.' ' : '');
|
165 |
+
$cityAddress = $origin['city'];
|
166 |
+
$city = (!empty($cityAddress) ? $cityAddress.', ' : '');
|
167 |
+
// $regionAddress = $origin['street_line1'];
|
168 |
+
// $region = (!empty($regionAddress) ? $regionAddress.', ' : '');
|
169 |
+
$countryCode = $origin['country_id'];
|
170 |
+
$countryAddress = Mage::app()->getLocale()->getCountryTranslation($countryCode);
|
171 |
+
$country = (!empty($countryAddress) ? $countryAddress : '');
|
172 |
+
|
173 |
+
$fullAddress = $street.$postCode.$city.$country;
|
174 |
+
|
175 |
+
return $fullAddress;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Register a Parcify Parcel
|
180 |
+
* API call
|
181 |
+
* @param $parcel
|
182 |
+
* @return mixed
|
183 |
+
*/
|
184 |
+
public function createParcifyParcel($parcel)
|
185 |
+
{
|
186 |
+
// Defaults
|
187 |
+
$response['body'] = '';
|
188 |
+
|
189 |
+
try {
|
190 |
+
// API data
|
191 |
+
$url = Mage::getStoreConfig('carriers/parcify_carrier/gateway_url');
|
192 |
+
$username = Mage::getStoreConfig('carriers/parcify_carrier/userid');
|
193 |
+
$passwordEncrypted = Mage::getStoreConfig('carriers/parcify_carrier/password');
|
194 |
+
$password = Mage::helper('core')->decrypt($passwordEncrypted);
|
195 |
+
|
196 |
+
// Check required gateway settings
|
197 |
+
if (empty($url)) {
|
198 |
+
$response['body']['errors'][] = 'Parcify Shipping - Missing Gateway URL';
|
199 |
+
}
|
200 |
+
if (empty($username)) {
|
201 |
+
$response['body']['errors'][] = 'Parcify Shipping - Missing Gateway user ID';
|
202 |
+
}
|
203 |
+
if (empty($password)) {
|
204 |
+
$response['body']['errors'][] = 'Parcify Shipping - Missing Gateway password';
|
205 |
+
}
|
206 |
+
|
207 |
+
// Cancel and report errors in case of missing required data
|
208 |
+
if(isset($response['body'], $response['body']['errors'])) {
|
209 |
+
return $response;
|
210 |
+
}
|
211 |
+
|
212 |
+
// data
|
213 |
+
$data = array('parcel' => $parcel);
|
214 |
+
$data = json_encode($data);
|
215 |
+
|
216 |
+
$ch = curl_init();
|
217 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
218 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
219 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
220 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
221 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
222 |
+
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
|
223 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
224 |
+
$responseBody = curl_exec($ch);
|
225 |
+
$responseHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
226 |
+
curl_close($ch);
|
227 |
+
|
228 |
+
if ($responseHttpCode == '200') {
|
229 |
+
$debugData['code'] = $responseHttpCode;
|
230 |
+
$debugData['body'] = $responseBody;
|
231 |
+
} else {
|
232 |
+
$debugData['code'] = $responseHttpCode;
|
233 |
+
$debugData['body'] = $responseBody;
|
234 |
+
|
235 |
+
$responseHttpCode = '-';
|
236 |
+
$responseBody = array();
|
237 |
+
$responseBody['errors'][] = 'Error Parcify parcel create API, check the "shipping_parcify.log" files for details.';
|
238 |
+
$responseBody = json_encode($responseBody);
|
239 |
+
}
|
240 |
+
|
241 |
+
} catch (Exception $e) {
|
242 |
+
|
243 |
+
$debugData['code'] = $responseBody;
|
244 |
+
$debugData['body'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
|
245 |
+
|
246 |
+
Mage::getSingleton('core/session')->addError('Error Parcify parcel create API: '.$e->getMessage());
|
247 |
+
|
248 |
+
$responseHttpCode = '-';
|
249 |
+
$responseBody['errors'][] = 'Error Parcify parcel create API';
|
250 |
+
}
|
251 |
+
$this->_debug($debugData);
|
252 |
+
|
253 |
+
// Response data
|
254 |
+
$response['code'] = $responseHttpCode;
|
255 |
+
$response['body'] = json_decode($responseBody, true);
|
256 |
+
|
257 |
+
return $response;
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Log debug data to file
|
262 |
+
*
|
263 |
+
* @param mixed $debugData
|
264 |
+
*/
|
265 |
+
public function _debug($debugData)
|
266 |
+
{
|
267 |
+
$_debugFlag = Mage::getStoreConfig('carriers/parcify_carrier/debug');
|
268 |
+
|
269 |
+
if ($_debugFlag) {
|
270 |
+
Mage::getModel('core/log_adapter', 'shipping_parcify.log')
|
271 |
+
->log($debugData);
|
272 |
+
}
|
273 |
+
}
|
274 |
+
}
|
app/code/community/Parcify/Carrier/etc/config.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Parcify_Carrier>
|
5 |
+
<module>0.0.1</module>
|
6 |
+
</Parcify_Carrier>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<parcify_carrier>
|
11 |
+
<class>Parcify_Carrier_Model</class>
|
12 |
+
</parcify_carrier>
|
13 |
+
</models>
|
14 |
+
<events>
|
15 |
+
<sales_order_shipment_save_before>
|
16 |
+
<observers>
|
17 |
+
<parcify_carrier_model_observer>
|
18 |
+
<type>singleton</type>
|
19 |
+
<class>Parcify_Carrier_Model_Observer</class>
|
20 |
+
<method>salesOrderShipmentSaveBefore</method>
|
21 |
+
</parcify_carrier_model_observer>
|
22 |
+
</observers>
|
23 |
+
</sales_order_shipment_save_before>
|
24 |
+
</events>
|
25 |
+
</global>
|
26 |
+
<frontend>
|
27 |
+
<translate>
|
28 |
+
<modules>
|
29 |
+
<parcify_carrier>
|
30 |
+
<files>
|
31 |
+
<default>Parcify_Carrier.csv</default>
|
32 |
+
</files>
|
33 |
+
</parcify_carrier>
|
34 |
+
</modules>
|
35 |
+
</translate>
|
36 |
+
</frontend>
|
37 |
+
<!-- Default configuration -->
|
38 |
+
<default>
|
39 |
+
<carriers>
|
40 |
+
<parcify_carrier>
|
41 |
+
<active>1</active>
|
42 |
+
<model>parcify_carrier/carrier</model>
|
43 |
+
<title>Parcify</title>
|
44 |
+
<price>4.50</price>
|
45 |
+
<free_shipping_subtotal>45</free_shipping_subtotal>
|
46 |
+
<parcelname>Pelican Rouge order #</parcelname>
|
47 |
+
<pickup_address>Sint-Aldegondiskaai 36, 2000 Antwerpen</pickup_address>
|
48 |
+
<sort_order>1</sort_order>
|
49 |
+
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
50 |
+
<gateway_url>https://api.parcify.it/v1</gateway_url>
|
51 |
+
<sallowspecific>0</sallowspecific>
|
52 |
+
</parcify_carrier>
|
53 |
+
</carriers>
|
54 |
+
</default>
|
55 |
+
</config>
|
app/code/community/Parcify/Carrier/etc/system.xml
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<carriers translate="label" module="shipping">
|
5 |
+
<groups>
|
6 |
+
<parcify_carrier translate="label">
|
7 |
+
<label>Parcify</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>1</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<!--
|
15 |
+
The following fields are available
|
16 |
+
to modify in the admin panel.
|
17 |
+
The values are saved in the
|
18 |
+
database.
|
19 |
+
|
20 |
+
This shipping carrier abstract checks
|
21 |
+
this value to determine whether
|
22 |
+
the carrier should be shown.
|
23 |
+
-->
|
24 |
+
<active translate="label">
|
25 |
+
<label>Enabled</label>
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>1</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>0</show_in_store>
|
32 |
+
</active>
|
33 |
+
<!--
|
34 |
+
This value can be used to specify a
|
35 |
+
custom title for our method.
|
36 |
+
-->
|
37 |
+
<title translate="label">
|
38 |
+
<label>Title</label>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>2</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
</title>
|
45 |
+
<price translate="label">
|
46 |
+
<label>Price</label>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<validate>validate-number validate-zero-or-greater</validate>
|
49 |
+
<sort_order>3</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
</price>
|
54 |
+
<free_shipping_subtotal translate="label">
|
55 |
+
<label>Minimum Order Amount</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<validate>validate-number validate-zero-or-greater</validate>
|
58 |
+
<sort_order>4</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
</free_shipping_subtotal>
|
63 |
+
<!--
|
64 |
+
The sort order is used in Magento
|
65 |
+
to determine what order the carrier
|
66 |
+
will appear in relative to the
|
67 |
+
other carriers available.
|
68 |
+
-->
|
69 |
+
<sort_order translate="label">
|
70 |
+
<label>Sort Order</label>
|
71 |
+
<frontend_type>text</frontend_type>
|
72 |
+
<sort_order>1940</sort_order>
|
73 |
+
<show_in_default>1</show_in_default>
|
74 |
+
<show_in_website>1</show_in_website>
|
75 |
+
<show_in_store>0</show_in_store>
|
76 |
+
</sort_order>
|
77 |
+
<!--
|
78 |
+
This value is used to specify the
|
79 |
+
Service base URL and user / password
|
80 |
+
to use the service
|
81 |
+
-->
|
82 |
+
<gateway_url translate="label">
|
83 |
+
<label>Gateway URL</label>
|
84 |
+
<frontend_type>text</frontend_type>
|
85 |
+
<sort_order>20</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>0</show_in_store>
|
89 |
+
</gateway_url>
|
90 |
+
<userid translate="label">
|
91 |
+
<label>User ID</label>
|
92 |
+
<frontend_type>text</frontend_type>
|
93 |
+
<sort_order>21</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>1</show_in_website>
|
96 |
+
<show_in_store>0</show_in_store>
|
97 |
+
</userid>
|
98 |
+
<password translate="label">
|
99 |
+
<label>Password</label>
|
100 |
+
<frontend_type>obscure</frontend_type>
|
101 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
102 |
+
<sort_order>22</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
<show_in_website>1</show_in_website>
|
105 |
+
<show_in_store>0</show_in_store>
|
106 |
+
</password>
|
107 |
+
|
108 |
+
<parcelname translate="label">
|
109 |
+
<label>Parcel name prefix</label>
|
110 |
+
<frontend_type>text</frontend_type>
|
111 |
+
<sort_order>89</sort_order>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>1</show_in_store>
|
115 |
+
</parcelname>
|
116 |
+
|
117 |
+
<pickup_address translate="label">
|
118 |
+
<label>Pick-up address</label>
|
119 |
+
<frontend_type>textarea</frontend_type>
|
120 |
+
<sort_order>88</sort_order>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<show_in_store>1</show_in_store>
|
124 |
+
</pickup_address>
|
125 |
+
|
126 |
+
<!--
|
127 |
+
This value is used to specify whether
|
128 |
+
the carrier is available only for
|
129 |
+
specific countries or all countries
|
130 |
+
available in the current Magento
|
131 |
+
installation.
|
132 |
+
-->
|
133 |
+
<sallowspecific translate="label">
|
134 |
+
<label>Ship to Applicable Countries</label>
|
135 |
+
<frontend_type>select</frontend_type>
|
136 |
+
<sort_order>90</sort_order>
|
137 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
138 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
139 |
+
<show_in_default>1</show_in_default>
|
140 |
+
<show_in_website>1</show_in_website>
|
141 |
+
<show_in_store>0</show_in_store>
|
142 |
+
</sallowspecific>
|
143 |
+
<!--
|
144 |
+
If 'specific countries' is chosen
|
145 |
+
in the previous option, then this field
|
146 |
+
allows the administrator to specify
|
147 |
+
which specific countries this carrier
|
148 |
+
should be available for.
|
149 |
+
-->
|
150 |
+
<specificcountry translate="label">
|
151 |
+
<label>Ship to Specific Countries</label>
|
152 |
+
<frontend_type>multiselect</frontend_type>
|
153 |
+
<sort_order>91</sort_order>
|
154 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
155 |
+
<show_in_default>1</show_in_default>
|
156 |
+
<show_in_website>1</show_in_website>
|
157 |
+
<show_in_store>0</show_in_store>
|
158 |
+
<can_be_empty>1</can_be_empty>
|
159 |
+
</specificcountry>
|
160 |
+
|
161 |
+
<debug translate="label">
|
162 |
+
<label>Debug</label>
|
163 |
+
<frontend_type>select</frontend_type>
|
164 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
165 |
+
<sort_order>1950</sort_order>
|
166 |
+
<show_in_default>1</show_in_default>
|
167 |
+
<show_in_website>1</show_in_website>
|
168 |
+
<show_in_store>0</show_in_store>
|
169 |
+
</debug>
|
170 |
+
<!--
|
171 |
+
Show an error message
|
172 |
+
-->
|
173 |
+
<specificerrmsg translate="label">
|
174 |
+
<label>Displayed Error Message</label>
|
175 |
+
<frontend_type>textarea</frontend_type>
|
176 |
+
<sort_order>101</sort_order>
|
177 |
+
<show_in_default>1</show_in_default>
|
178 |
+
<show_in_website>1</show_in_website>
|
179 |
+
<show_in_store>1</show_in_store>
|
180 |
+
</specificerrmsg>
|
181 |
+
|
182 |
+
</fields>
|
183 |
+
</parcify_carrier>
|
184 |
+
</groups>
|
185 |
+
</carriers>
|
186 |
+
</sections>
|
187 |
+
</config>
|
app/code/community/Parcify/Carrier/locale/.DS_Store
ADDED
Binary file
|
app/code/community/Parcify/Carrier/locale/fr_FR/Parcify_Carrier.csv
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
"Personal delivery","Remise en main propre"
|
app/code/community/Parcify/Carrier/locale/nl_NL/Parcify_Carrier.csv
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
"Personal delivery","Persoonlijke levering"
|
app/etc/modules/Parcify_Carrier.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Parcify_Carrier>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Shipping />
|
9 |
+
</depends>
|
10 |
+
</Parcify_Carrier>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Parcify</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -31,8 +31,8 @@ We use your GPS position in the foreground and background so that we can bring y
|
|
31 |
<notes>- Fixed an issue the locale folder</notes>
|
32 |
<authors><author><name>Parcify</name><user>parcify</user><email>app@parcify.com</email></author></authors>
|
33 |
<date>2016-08-16</date>
|
34 |
-
<time>14:
|
35 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Parcify_Carrier.xml" hash=""/></dir></target></contents>
|
36 |
<compatible/>
|
37 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
38 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Parcify</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
31 |
<notes>- Fixed an issue the locale folder</notes>
|
32 |
<authors><author><name>Parcify</name><user>parcify</user><email>app@parcify.com</email></author></authors>
|
33 |
<date>2016-08-16</date>
|
34 |
+
<time>14:20:41</time>
|
35 |
+
<contents><target name="magecommunity"><dir name="Parcify"><dir name="Carrier"><dir name="Model"><file name="Carrier.php" hash="e3e2952cea1e8a04777ec9812ac41da2"/><file name="Observer.php" hash="28f2447df3a84359362a3f204145b0e7"/></dir><dir name="etc"><file name="config.xml" hash="620e564cd44358468880fb00cc01aa61"/><file name="system.xml" hash="b124a8960a79b3384b3a43431b35425f"/></dir><dir name="locale"><dir name="fr_FR"><file name="Parcify_Carrier.csv" hash="1957e8bfed497a09e7085a2f58d0bb6f"/></dir><dir name="nl_NL"><file name="Parcify_Carrier.csv" hash="68455524d8b752133b91c8b301e90b81"/></dir><file name=".DS_Store" hash="cc332b840582e3c73f7e72c3efccb76a"/></dir><file name=".DS_Store" hash="9c1eabbd67a1f40dc85d61503491466a"/></dir><file name=".DS_Store" hash="c163e41cde922b3772c668fd0e0d1868"/></dir></target><target name="mageetc"><dir name="modules"><file name="Parcify_Carrier.xml" hash="93657d0745ae7b716023cf33e8f76b4c"/></dir></target></contents>
|
36 |
<compatible/>
|
37 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
38 |
</package>
|