Skip to content

Commit

Permalink
SHQ16-636 record item level carrier group detail
Browse files Browse the repository at this point in the history
  • Loading branch information
wsagen committed Jul 5, 2016
2 parents 7ee1549 + aae6afa commit 82f6da4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- SHQ16-1066 - shipping method filtering in shopping cart promotions
- SHQ16-1031 - single carrier list shipping logic for admin orders
- SHQ16-1189 - carrier validation for all address fields
- SHQ16-1201 - Upgrade data script changes and attribute synch ignore empty value
- SHQ16-1201 - Upgrade data script changes and attribute synch ignore empty value

## [20.0.13] - 2016-07-05
### Added
- SHQ16-636 - record item level carrier group detail
6 changes: 3 additions & 3 deletions src/Helper/CarrierGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ public function saveCarrierGroupInformation($shippingAddress, $shippingMethod)
if(array_key_exists('carrierGroupId', $shipDetails)) {
$arrayofShipDetails = [];
$arrayofShipDetails[] = $shipDetails;

$encodedShipDetails = $this->shipperDataHelper->encode($arrayofShipDetails);
}
else {
$encodedShipDetails = $this->shipperDataHelper->encode($shipDetails);
$arrayofShipDetails = $shipDetails;
}
$encodedShipDetails = $this->shipperDataHelper->encode($arrayofShipDetails);

$shippingAddress
->setCarrierId($foundRate->getCarrierId())
Expand All @@ -96,6 +95,7 @@ public function saveCarrierGroupInformation($shippingAddress, $shippingMethod)
$carrierGroupDetail->setData($update);
$carrierGroupDetail->save();
//save selected shipping options to items
$this->shipperDataHelper->setShippingOnItems($arrayofShipDetails, $shippingAddress);
}
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions src/Observer/AbstractRecordOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ protected function recordOrder($order)
$shippingAddress = $quote->getShippingAddress();
$carrierType = $shippingAddress->getCarrierType();
$order->setCarrierType($carrierType);
$this->recordOrderItems($order, $quote);
if(strstr($order->getCarrierType(), 'shqshared_')) {
$original = $order->getCarrierType();
$carrierTypeArray = explode('_', $order->getCarrierType());
Expand Down Expand Up @@ -144,5 +145,20 @@ protected function recordOrder($order)
}
}
}

protected function recordOrderItems($order, $quote)
{
foreach($order->getAllItems() as $orderItem) {
foreach($quote->getAllItems() as $quoteItem) {
if($quoteItem->getId() == $orderItem->getQuoteItemId()) {
$orderItem->setCarriergroupId($quoteItem->getCarriergroupId());
$orderItem->setCarriergroup($quoteItem->getCarriergroup());
$orderItem->setCarriergroupShipping($quoteItem->getCarriergroupShipping());
$orderItem->save();
}
}

}
}
}

2 changes: 1 addition & 1 deletion src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
<ws_timeout>120</ws_timeout>
<use_cache>0</use_cache>
<extension_version>20.0.12</extension_version>
<extension_version>20.0.13</extension_version>
<allowed_methods></allowed_methods>
</shipper>
</carriers>
Expand Down
22 changes: 22 additions & 0 deletions src/etc/fieldset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,27 @@
<aspect name="to_quote_address" />
</field>
</fieldset>
<fieldset id="quote_convert_item">
<field name="carriergroup_id">
<aspect name="to_order_item" />
</field>
<field name="carriergroup">
<aspect name="to_order_item" />
</field>
<field name="carriergroup_shipping">
<aspect name="to_order_item" />
</field>
</fieldset>
<fieldset id="sales_convert_order_item">
<field name="carriergroup_id">
<aspect name="to_quote_item" />
</field>
<field name="carriergroup">
<aspect name="to_quote_item" />
</field>
<field name="carriergroup_shipping">
<aspect name="to_quote_item" />
</field>
</fieldset>
</scope>
</config>
2 changes: 1 addition & 1 deletion src/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="ShipperHQ_Shipper" setup_version="1.0.3" >
<module name="ShipperHQ_Shipper" setup_version="1.0.4" >
<sequence>
<module name="Magento_Config"/>
<module name="Magento_Store"/>
Expand Down

0 comments on commit 82f6da4

Please sign in to comment.