Version Notes
Shipwire Shipping Rating API integrated
1.2.4 Added multiple Intl support
1.2.2
- Fixed issue with encoding of rate request
1.2.1
- Fixed issue with ship-to postcode not passing
1.2.5
- Fixed PHP coding error
1.3.0
- Added multiple currency support
- Fixed problem some installs had with Invoicing
Download this release
Release Info
| Developer | Shipwire |
| Extension | Mage_Shipwire |
| Version | 1.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.2.5 to 1.3.0
app/code/local/Shipwire/Shipping/Model/Carrier/ShippingMethod.php
CHANGED
|
@@ -1,195 +1,146 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
-
*
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
{
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
* @var string [a-z0-9_]
|
| 14 |
-
*/
|
| 15 |
|
| 16 |
-
protected $_code = 'shipwire_shipping';
|
| 17 |
|
| 18 |
/**
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
| 25 |
{
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
$result->append($method);
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
return $result;
|
| 68 |
}
|
| 69 |
|
| 70 |
|
| 71 |
public function getAllowedMethods()
|
| 72 |
{
|
| 73 |
-
return array('shipwire_shipping'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
{
|
| 78 |
|
| 79 |
-
$
|
| 80 |
-
|
| 81 |
-
$
|
| 82 |
-
|
| 83 |
-
$address_street1 = $requestVar->dest_street;
|
| 84 |
-
$address_street2 = '';
|
| 85 |
-
$address_city = $requestVar->dest_city;
|
| 86 |
-
$address_region = $requestVar->dest_region_code;
|
| 87 |
-
$address_country = $requestVar->dest_country_id;
|
| 88 |
-
$address_postcode =
|
| 89 |
-
!empty($requestVar->dest_postcode)
|
| 90 |
-
? $requestVar->dest_postcode
|
| 91 |
-
: (!empty($requestVar->dest_zip)
|
| 92 |
-
? $requestVar->dest_zip
|
| 93 |
-
: $requestVar->getDestPostcode());
|
| 94 |
-
|
| 95 |
-
$items = $requestVar->all_items;
|
| 96 |
-
|
| 97 |
-
$item_xml = '';
|
| 98 |
-
$num = 1;
|
| 99 |
-
if (count($items) > 0) {
|
| 100 |
-
$itemIncluded = array();
|
| 101 |
-
$index = 0;
|
| 102 |
-
// First match up Configurable's with likely simples, mark off the items as included or not included. Any simple types left over will be included
|
| 103 |
-
foreach ($items as $item) {
|
| 104 |
-
if (!array_key_exists( $index, $itemIncluded ) && $item->product_type == 'configurable') { // See if we have a configurable SKU
|
| 105 |
-
// Next see if the next item is the same SKU, simple, and with quantity 1
|
| 106 |
-
if( array_key_exists( $index+1, $items) &&
|
| 107 |
-
$items[$index+1]->product_type == 'simple' &&
|
| 108 |
-
$items[$index+1]->sku == $item->sku &&
|
| 109 |
-
$items[$index+1]->qty == 1) {
|
| 110 |
-
$itemIncluded[$index] = 1; // Include the configurable
|
| 111 |
-
$itemIncluded[$index+1] = 0; // Don't include the following simple
|
| 112 |
-
}
|
| 113 |
-
else {
|
| 114 |
-
$foundSimple = 0;
|
| 115 |
-
// If we can't find a simple one after then see if we have and matching simple that is not already used.
|
| 116 |
-
for( $i = 0; $i < count($items); $i++) {
|
| 117 |
-
if( $items[$i]->product_type == 'simple' &&
|
| 118 |
-
!array_key_exists( $i, $itemIncluded )&& // Only consider items that are otherwise not yet evaluated
|
| 119 |
-
$items[$i]->sku == $item->sku &&
|
| 120 |
-
$items[$i]->qty == 1) {
|
| 121 |
-
$itemIncluded[$index] = 1; // Include configurable
|
| 122 |
-
$itemIncluded[$i] = 0; // Don't include matching simple
|
| 123 |
-
$foundSimple = 1;
|
| 124 |
-
break;
|
| 125 |
-
}
|
| 126 |
-
}
|
| 127 |
-
if( !$foundSimple ){ // If we can't find a matching simple then don't consider the configurable
|
| 128 |
-
$itemIncluded[$index] = 0; // Don't include this configurable
|
| 129 |
-
}
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
}
|
| 133 |
-
$index++;
|
| 134 |
-
}
|
| 135 |
-
// Now spin throught again using the $itemIncluded array to determin what goes into rating
|
| 136 |
-
$index = 0;
|
| 137 |
-
foreach ($items as $item) {
|
| 138 |
-
if (!array_key_exists( $index, $itemIncluded ) || $itemIncluded[$index] == 1 ) { // We need detached singles (no array key, or included items
|
| 139 |
-
$item_xml .= '<Item num="' . $num++ . '">';
|
| 140 |
-
$item_xml .= '<Code>' . $item->sku . '</Code>';
|
| 141 |
-
$item_xml .= '<Quantity>' . $item->qty . '</Quantity>';
|
| 142 |
-
$item_xml .= '</Item>';
|
| 143 |
-
}
|
| 144 |
-
$index++;
|
| 145 |
-
|
| 146 |
-
}
|
| 147 |
-
}
|
| 148 |
-
$xml = '
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
<?xml version="1.0" encoding="utf-8"?>
|
| 151 |
<!DOCTYPE RateRequest SYSTEM "http://www.shipwire.com/exec/download/RateRequest.dtd">
|
| 152 |
-
<RateRequest currency="
|
| 153 |
-
<
|
| 154 |
-
<Password><![CDATA[
|
| 155 |
-
<Source>
|
| 156 |
-
<Order id="
|
| 157 |
-
<Warehouse>00</Warehouse>
|
| 158 |
<AddressInfo type="ship">
|
| 159 |
-
<Address1><![CDATA[
|
| 160 |
-
<
|
| 161 |
-
<
|
| 162 |
-
<
|
| 163 |
-
<
|
| 164 |
-
<Zip><![CDATA[' . $address_postcode . ']]></Zip>
|
| 165 |
</AddressInfo>
|
| 166 |
-
|
| 167 |
</Order>
|
| 168 |
-
</RateRequest>
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
$
|
| 173 |
-
|
| 174 |
-
$
|
| 175 |
-
|
| 176 |
-
curl_setopt($
|
| 177 |
-
curl_setopt($
|
| 178 |
-
curl_setopt($
|
| 179 |
-
curl_setopt($
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
/*
|
| 185 |
-
$client = new Varien_Http_Client('https://api.shipwire.com/exec/RateServices.php');
|
| 186 |
-
$client->setMethod(Zend_Http_Client::POST);
|
| 187 |
-
$client->setParameterPost('RateRequestXML', $xml);
|
| 188 |
-
$response = $client->request();
|
| 189 |
-
*/
|
| 190 |
-
$rateResult = array();
|
| 191 |
if (FALSE === $response) {
|
| 192 |
-
$
|
| 193 |
}
|
| 194 |
|
| 195 |
$parser = xml_parser_create();
|
|
@@ -198,29 +149,35 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
|
|
| 198 |
|
| 199 |
xml_parser_free($parser);
|
| 200 |
|
| 201 |
-
foreach($xmlVals as $key){
|
| 202 |
-
if($key['tag'] ==
|
| 203 |
-
if($key['value'] !=
|
| 204 |
-
|
| 205 |
}
|
| 206 |
|
| 207 |
}
|
| 208 |
}
|
| 209 |
|
| 210 |
-
$code
|
| 211 |
-
$method
|
| 212 |
-
$cost
|
| 213 |
-
$supportedServices = explode(
|
| 214 |
|
| 215 |
-
foreach($xmlVals as $key){
|
| 216 |
-
if($key['tag'] ==
|
| 217 |
-
|
|
|
|
|
|
|
| 218 |
}
|
| 219 |
-
if($key['tag'] ==
|
| 220 |
-
|
|
|
|
|
|
|
| 221 |
}
|
| 222 |
-
if($key['tag'] ==
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
}
|
| 226 |
|
|
@@ -228,12 +185,15 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
|
|
| 228 |
$lb = count($method);
|
| 229 |
$lc = count($cost);
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
|
|
|
| 233 |
if (in_array($value, $supportedServices)) {
|
| 234 |
-
$rateResult[] = array(
|
| 235 |
-
|
| 236 |
-
|
|
|
|
|
|
|
| 237 |
}
|
| 238 |
}
|
| 239 |
}
|
|
@@ -241,28 +201,73 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
|
|
| 241 |
|
| 242 |
}
|
| 243 |
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
|
|
|
| 267 |
|
|
|
|
|
|
|
| 268 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
+
* Shipwire real-time rating method for Magento
|
| 5 |
+
*
|
| 6 |
+
* Copyright (C) 2012, Shipwire Inc.
|
| 7 |
+
*/
|
| 8 |
+
class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
|
| 9 |
{
|
| 10 |
+
protected $_code = 'shipwire_shipping';
|
| 11 |
|
| 12 |
+
protected $_version = 'Magento Rating Module 1.3.0';
|
| 13 |
+
|
| 14 |
+
protected $_apiEndpoint = 'https://api.shipwire.com/exec/RateServices.php';
|
|
|
|
|
|
|
| 15 |
|
|
|
|
| 16 |
|
| 17 |
/**
|
| 18 |
+
* Collect rates for this shipping method based on information in $request
|
| 19 |
+
*
|
| 20 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
| 21 |
+
* @return Mage_Shipping_Model_Rate_Result
|
| 22 |
+
*/
|
| 23 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
| 24 |
{
|
| 25 |
+
// skip if not enabled
|
| 26 |
+
if (!$this->getConfigFlag('active')) {
|
| 27 |
+
return FALSE;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$response = $this->_submitRequest($request);
|
| 31 |
+
|
| 32 |
+
if (empty($response)) {
|
| 33 |
+
/**
|
| 34 |
+
* @var $error Mage_Shipping_Model_Rate_Result_Error
|
| 35 |
+
*/
|
| 36 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
| 37 |
+
$error->setCarrier($this->_code);
|
| 38 |
+
$error->setCarrierTitle($this->getConfigData('title'));
|
| 39 |
+
$error->setErrorMessage('No shipping methods are available');
|
| 40 |
+
return $error;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* @var $result Mage_Shipping_Model_Rate_Result
|
| 45 |
+
*/
|
| 46 |
+
$result = Mage::getModel('shipping/rate_result');
|
| 47 |
+
foreach ($response as $rMethod) {
|
| 48 |
+
/**
|
| 49 |
+
* @var $method Mage_Shipping_Model_Rate_Result_Method
|
| 50 |
+
*/
|
| 51 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
| 52 |
+
$method->setCarrier($this->_code);
|
| 53 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
| 54 |
+
$method->setMethod($rMethod['code']);
|
| 55 |
+
$method->setMethodTitle($rMethod['title']);
|
| 56 |
+
$method->setCost($rMethod['amount']);
|
| 57 |
+
$method->setPrice($rMethod['amount']);
|
| 58 |
+
|
| 59 |
+
$result->append($method);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
return $result;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
|
| 66 |
public function getAllowedMethods()
|
| 67 |
{
|
| 68 |
+
return array('shipwire_shipping'=> $this->getConfigData('name'));
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
public function isTrackingAvailable()
|
| 72 |
+
{
|
| 73 |
+
return TRUE;
|
| 74 |
}
|
| 75 |
|
| 76 |
+
/**
|
| 77 |
+
* @param Mage_Shipping_Model_Rate_Request $requestVar
|
| 78 |
+
* @return array
|
| 79 |
+
*/
|
| 80 |
+
private function _submitRequest(Mage_Shipping_Model_Rate_Request $requestVar)
|
| 81 |
{
|
| 82 |
|
| 83 |
+
$shipwireAvailableServices = $this->getConfigData('availableservices');
|
| 84 |
+
|
| 85 |
+
$shipwireUsername = $this->getConfigData('shipwire_email');
|
| 86 |
+
$shipwirePassword = $this->getConfigData('shipwire_password');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
$orderCurrencyCode = 'USD';
|
| 89 |
+
/**
|
| 90 |
+
* @var $orderCurrency Mage_Directory_Model_Currency
|
| 91 |
+
*/
|
| 92 |
+
$orderCurrency = $requestVar->getBaseCurrency();
|
| 93 |
+
if (!empty($orderCurrency)) {
|
| 94 |
+
$orderCurrencyCode = $orderCurrency->getCode();
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
$orderNumber = md5(serialize($requestVar));
|
| 98 |
+
|
| 99 |
+
$shipToAddress1 = $requestVar->getDestStreet();
|
| 100 |
+
$shipToCity = $requestVar->getDestCity();
|
| 101 |
+
$shipToRegion = $requestVar->getDestRegionCode();
|
| 102 |
+
$shipToCountry = $requestVar->getDestCountryId();
|
| 103 |
+
$shiptoPostalCode = $requestVar->getDestPostcode();
|
| 104 |
+
|
| 105 |
+
$requestItems = $requestVar->getAllItems();
|
| 106 |
+
|
| 107 |
+
$itemXml = $this->_buildRequestItemXml($requestItems);
|
| 108 |
+
|
| 109 |
+
$rateRequestXml = <<<XML
|
| 110 |
<?xml version="1.0" encoding="utf-8"?>
|
| 111 |
<!DOCTYPE RateRequest SYSTEM "http://www.shipwire.com/exec/download/RateRequest.dtd">
|
| 112 |
+
<RateRequest currency="$orderCurrencyCode">
|
| 113 |
+
<Username><![CDATA[$shipwireUsername]]></Username>
|
| 114 |
+
<Password><![CDATA[$shipwirePassword]]></Password>
|
| 115 |
+
<Source>{$this->_version}</Source>
|
| 116 |
+
<Order id="$orderNumber">
|
|
|
|
| 117 |
<AddressInfo type="ship">
|
| 118 |
+
<Address1><![CDATA[$shipToAddress1]]></Address1>
|
| 119 |
+
<City><![CDATA[$shipToCity]]></City>
|
| 120 |
+
<State><![CDATA[$shipToRegion]]></State>
|
| 121 |
+
<Country><![CDATA[$shipToCountry]]></Country>
|
| 122 |
+
<Zip><![CDATA[$shiptoPostalCode]]></Zip>
|
|
|
|
| 123 |
</AddressInfo>
|
| 124 |
+
$itemXml
|
| 125 |
</Order>
|
| 126 |
+
</RateRequest>
|
| 127 |
+
XML;
|
| 128 |
+
|
| 129 |
+
$curlSession = curl_init();
|
| 130 |
+
curl_setopt($curlSession, CURLOPT_URL, $this->_apiEndpoint);
|
| 131 |
+
curl_setopt($curlSession, CURLOPT_POST, true);
|
| 132 |
+
curl_setopt($curlSession, CURLOPT_HTTPHEADER,
|
| 133 |
+
array('Content-Type: application/xml'));
|
| 134 |
+
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $rateRequestXml);
|
| 135 |
+
curl_setopt($curlSession, CURLOPT_HEADER, false);
|
| 136 |
+
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
|
| 137 |
+
curl_setopt($curlSession, CURLOPT_TIMEOUT, 60);
|
| 138 |
+
$response = curl_exec($curlSession);
|
| 139 |
+
|
| 140 |
+
$emptyRateResult = array();
|
| 141 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
if (FALSE === $response) {
|
| 143 |
+
return $emptyRateResult;
|
| 144 |
}
|
| 145 |
|
| 146 |
$parser = xml_parser_create();
|
| 149 |
|
| 150 |
xml_parser_free($parser);
|
| 151 |
|
| 152 |
+
foreach ($xmlVals as $key) {
|
| 153 |
+
if ($key['tag'] == 'STATUS') {
|
| 154 |
+
if ($key['value'] != 'OK') {
|
| 155 |
+
return $emptyRateResult;
|
| 156 |
}
|
| 157 |
|
| 158 |
}
|
| 159 |
}
|
| 160 |
|
| 161 |
+
$code = array();
|
| 162 |
+
$method = array();
|
| 163 |
+
$cost = array();
|
| 164 |
+
$supportedServices = explode(',', $shipwireAvailableServices);
|
| 165 |
|
| 166 |
+
foreach ($xmlVals as $key) {
|
| 167 |
+
if ($key['tag'] == 'QUOTE' && $key['type'] == 'open'
|
| 168 |
+
&& $key['level'] == 4
|
| 169 |
+
) {
|
| 170 |
+
$code[] = $key['attributes']['METHOD'];
|
| 171 |
}
|
| 172 |
+
if ($key['tag'] == 'SERVICE' && $key['type'] == 'complete'
|
| 173 |
+
&& $key['level'] == 5
|
| 174 |
+
) {
|
| 175 |
+
$method[] = $key['value'];
|
| 176 |
}
|
| 177 |
+
if ($key['tag'] == 'COST' && $key['type'] == 'complete'
|
| 178 |
+
&& $key['level'] == 5
|
| 179 |
+
) {
|
| 180 |
+
$cost[] = $key['value'];
|
| 181 |
}
|
| 182 |
}
|
| 183 |
|
| 185 |
$lb = count($method);
|
| 186 |
$lc = count($cost);
|
| 187 |
|
| 188 |
+
$rateResult = array();
|
| 189 |
+
if ($la == $lb && $lb == $lc) {
|
| 190 |
+
foreach ($code as $index => $value) {
|
| 191 |
if (in_array($value, $supportedServices)) {
|
| 192 |
+
$rateResult[] = array(
|
| 193 |
+
'code' => $code[$index],
|
| 194 |
+
'title' => $method[$index],
|
| 195 |
+
'amount' => $cost[$index]
|
| 196 |
+
);
|
| 197 |
}
|
| 198 |
}
|
| 199 |
}
|
| 201 |
|
| 202 |
}
|
| 203 |
|
| 204 |
+
/**
|
| 205 |
+
* @param array $requestItems
|
| 206 |
+
* @return string
|
| 207 |
+
*/
|
| 208 |
+
private function _buildRequestItemXml(array $requestItems)
|
| 209 |
+
{
|
| 210 |
+
$itemXml = '';
|
| 211 |
+
$itemNum = 1;
|
| 212 |
+
if (count($requestItems) > 0) {
|
| 213 |
+
$itemIncluded = array();
|
| 214 |
+
$index = 0;
|
| 215 |
+
// First match up Configurable's with likely simples, mark off the items as included or not included. Any simple types left over will be included
|
| 216 |
+
foreach ($requestItems as $requestItem) {
|
| 217 |
+
if (!array_key_exists($index, $itemIncluded)
|
| 218 |
+
&& $requestItem->product_type == 'configurable'
|
| 219 |
+
) { // See if we have a configurable SKU
|
| 220 |
+
// Next see if the next item is the same SKU, simple, and with quantity 1
|
| 221 |
+
if (array_key_exists($index + 1, $requestItems)
|
| 222 |
+
&& $requestItems[$index + 1]->product_type == 'simple'
|
| 223 |
+
&& $requestItems[$index + 1]->sku == $requestItem->sku
|
| 224 |
+
&& $requestItems[$index + 1]->qty == 1
|
| 225 |
+
) {
|
| 226 |
+
$itemIncluded[$index] = 1; // Include the configurable
|
| 227 |
+
$itemIncluded[$index
|
| 228 |
+
+ 1] = 0; // Don't include the following simple
|
| 229 |
+
} else {
|
| 230 |
+
$foundSimple = 0;
|
| 231 |
+
// If we can't find a simple one after then see if we have and matching simple that is not already used.
|
| 232 |
+
for ($i = 0; $i < count($requestItems); $i++) {
|
| 233 |
+
if ($requestItems[$i]->product_type == 'simple'
|
| 234 |
+
&& !array_key_exists($i, $itemIncluded)
|
| 235 |
+
&& // Only consider items that are otherwise not yet evaluated
|
| 236 |
+
$requestItems[$i]->sku == $requestItem->sku
|
| 237 |
+
&& $requestItems[$i]->qty == 1
|
| 238 |
+
) {
|
| 239 |
+
$itemIncluded[$index] = 1; // Include configurable
|
| 240 |
+
$itemIncluded[$i] = 0; // Don't include matching simple
|
| 241 |
+
$foundSimple = 1;
|
| 242 |
+
break;
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
if (!$foundSimple) { // If we can't find a matching simple then don't consider the configurable
|
| 246 |
+
$itemIncluded[$index] = 0; // Don't include this configurable
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
|
| 250 |
+
}
|
| 251 |
+
$index++;
|
| 252 |
+
}
|
| 253 |
+
// Now spin through again using the $itemIncluded array to determine what goes into rating
|
| 254 |
+
$index = 0;
|
| 255 |
+
foreach ($requestItems as $requestItem) {
|
| 256 |
+
if (!array_key_exists($index, $itemIncluded)
|
| 257 |
+
|| $itemIncluded[$index] == 1
|
| 258 |
+
) { // We need detached singles (no array key, or included items
|
| 259 |
+
$itemXml .= '<Item num="' . $itemNum++ . '">';
|
| 260 |
+
$itemXml .= '<Code>' . $requestItem->sku . '</Code>';
|
| 261 |
+
$itemXml .=
|
| 262 |
+
'<Quantity>' . $requestItem->qty . '</Quantity>';
|
| 263 |
+
$itemXml .= '</Item>';
|
| 264 |
+
}
|
| 265 |
+
$index++;
|
| 266 |
|
| 267 |
+
}
|
| 268 |
+
return $itemXml;
|
| 269 |
+
}
|
| 270 |
|
| 271 |
+
return $itemXml;
|
| 272 |
+
}
|
| 273 |
}
|
app/code/local/Shipwire/Shipping/etc/config.xml
CHANGED
|
@@ -1,27 +1,45 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</config>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Shipwire_Shipping>
|
| 5 |
+
<version>1.3.0</version>
|
| 6 |
+
</Shipwire_Shipping>
|
| 7 |
+
</modules>
|
| 8 |
+
|
| 9 |
+
<global>
|
| 10 |
+
<models>
|
| 11 |
+
<shipwire_shipping>
|
| 12 |
+
<class>Shipwire_Shipping_Model</class>
|
| 13 |
+
</shipwire_shipping>
|
| 14 |
+
</models>
|
| 15 |
+
|
| 16 |
+
<resources>
|
| 17 |
+
<shipwire_shipping_setup>
|
| 18 |
+
<setup>
|
| 19 |
+
<module>Shipwire_Shipping</module>
|
| 20 |
+
</setup>
|
| 21 |
+
<connection>
|
| 22 |
+
<use>core_setup</use>
|
| 23 |
+
</connection>
|
| 24 |
+
</shipwire_shipping_setup>
|
| 25 |
+
</resources>
|
| 26 |
+
</global>
|
| 27 |
+
|
| 28 |
+
<default>
|
| 29 |
+
<carriers>
|
| 30 |
+
<shipwire_shipping>
|
| 31 |
+
<active>1</active>
|
| 32 |
+
<allowed_methods>delivery</allowed_methods>
|
| 33 |
+
<methods>delivery</methods>
|
| 34 |
+
<sallowspecific>0</sallowspecific>
|
| 35 |
+
<model>shipwire_shipping/carrier_ShippingMethod</model>
|
| 36 |
+
<name>Shipwire</name>
|
| 37 |
+
<title>Real-time Shipping Rates</title>
|
| 38 |
+
<specificerrmsg>
|
| 39 |
+
This shipping method is currently unavailable.
|
| 40 |
+
</specificerrmsg>
|
| 41 |
+
<handling_type>F</handling_type>
|
| 42 |
+
</shipwire_shipping>
|
| 43 |
+
</carriers>
|
| 44 |
+
</default>
|
| 45 |
</config>
|
app/code/local/Shipwire/Shipping/etc/system.xml
CHANGED
|
@@ -28,13 +28,6 @@
|
|
| 28 |
<show_in_website>1</show_in_website>
|
| 29 |
<show_in_store>1</show_in_store>
|
| 30 |
</title>
|
| 31 |
-
<model translate="label">
|
| 32 |
-
<label>Model</label>
|
| 33 |
-
<frontend_type>text</frontend_type>
|
| 34 |
-
<sort_order>900</sort_order>
|
| 35 |
-
<show_in_default>1</show_in_default>
|
| 36 |
-
<show_in_website>1</show_in_website>
|
| 37 |
-
</model>
|
| 38 |
<shipwire_email translate="label">
|
| 39 |
<label>Shipwire Email</label>
|
| 40 |
<frontend_type>text</frontend_type>
|
|
@@ -65,4 +58,4 @@
|
|
| 65 |
</groups>
|
| 66 |
</carriers>
|
| 67 |
</sections>
|
| 68 |
-
</config>
|
| 28 |
<show_in_website>1</show_in_website>
|
| 29 |
<show_in_store>1</show_in_store>
|
| 30 |
</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
<shipwire_email translate="label">
|
| 32 |
<label>Shipwire Email</label>
|
| 33 |
<frontend_type>text</frontend_type>
|
| 58 |
</groups>
|
| 59 |
</carriers>
|
| 60 |
</sections>
|
| 61 |
+
</config>
|
app/etc/modules/Shipwire_Shipping.xml
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
</config>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Shipwire_Shipping>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Shipping/>
|
| 9 |
+
</depends>
|
| 10 |
+
</Shipwire_Shipping>
|
| 11 |
+
</modules>
|
| 12 |
</config>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_Shipwire</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -19,11 +19,15 @@
|
|
| 19 |
- Fixed issue with ship-to postcode not passing
|
| 20 |

|
| 21 |
1.2.5
|
| 22 |
-
- Fixed PHP coding error
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
<compatible/>
|
| 28 |
-
<dependencies
|
| 29 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_Shipwire</name>
|
| 4 |
+
<version>1.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 19 |
- Fixed issue with ship-to postcode not passing
|
| 20 |

|
| 21 |
1.2.5
|
| 22 |
+
- Fixed PHP coding error
|
| 23 |
+

|
| 24 |
+
1.3.0
|
| 25 |
+
- Added multiple currency support
|
| 26 |
+
- Fixed problem some installs had with Invoicing</notes>
|
| 27 |
+
<authors><author><name>Shipwire</name><user>Shipwire</user><email>magento-dev@shipwire.com</email></author></authors>
|
| 28 |
+
<date>2012-08-03</date>
|
| 29 |
+
<time>22:14:20</time>
|
| 30 |
+
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Shipwire_Shipping.xml" hash="22ed62daa00faeb3219b05484c5a02a4"/></dir></dir></dir></target><target name="magelocal"><dir name="Shipwire"><dir name="Shipping"><dir name="Model"><dir name="Carrier"><file name="Service.php" hash="1499ae366ebd44d49356230248fea53e"/><file name="ShippingMethod.php" hash="2077ad47048b3db79e61dd5ef20e3be2"/></dir></dir><dir name="etc"><file name="config.xml" hash="05bd86d2b0d072417c0bcefdd2c08399"/><file name="system.xml" hash="4f787402d22f2d6330225f291f3bf8e2"/></dir></dir></dir></target></contents>
|
| 31 |
<compatible/>
|
| 32 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package><extension><name>Core</name><min></min><max></max></extension></required></dependencies>
|
| 33 |
</package>
|
