Closed aleksa-andersinnovation closed 5 years ago
Hey Shipperhq/module-Shipper,
Thanks for reaching out, I just want to let you know that we've got this! The next email you'll get is from one of our engineers. Sit tight, we're in office from 3:30 AM - 6:00 PM CST.
In the meantime, don't forget to check out all the great information in our Knowledge base https://docs.shipperhq.com/.
For any live site outages, please contact us at (512) 215-4900 ext 2 {#HS:952746045-225321#}
This issue is related to the shipping_method name mismatch, all methods are renamed shqname_of_the_method and can't be retrieved there: vendor/magento/module-quote/Model/Quote/Address.php:904
Here is my workaround :
public function afterGetShippingRateByCode(\Magento\Quote\Model\Quote\Address $subject, $result, $code)
{
if($result == false && substr($code, 0, 3) !== 'shq'){
return $subject->getShippingRateByCode('shq' . $code);
}
return $result;
}
Hi @matiaso , thanks for suggestion but this is not the same issue. I believe problem is created by assuming:
$shippingAddress->getShippingRateByCode($order->getShippingMethod());
will always return shipping rate, and in case of downloadable product that's not true.
Indeed @aleksa-andersinnovation , I ended up overriding the whole class since all functions are private.
Here is the modified function:
/**
* @param $order
* @return array
*/
private function getExistingRateForOrder($order)
{
if(!$order->getShippingMethod()){
return [
"carrier_title" => 'None',
"method_title" => 'no_method',
"price" => 0.00
];
}
$quoteId = $order->getQuoteId();
$quote = $this->quoteRepository->get($quoteId, [$order->getStoreId()]);
$shippingAddress = $quote->getShippingAddress();
$shippingRate = $shippingAddress->getShippingRateByCode($order->getShippingMethod());
return [
"carrier_title" => $shippingRate->getCarrierTitle(),
"method_title" => $shippingRate->getMethodTitle(),
"price" => $shippingRate->getPrice()
];
}
We've now deployed a fix for this issue; the latest version will allow the viewing of orders as normal. Also, if you encountered this bug and rolled back to a previous version which works fine for you, you can choose to either stay on that version or upgrade, as the latest changes do not alter existing functionality.
Hi, I've noticed error produced by shipperhq module after installing latest version, though change that introduced this code was added with version 20.29.0
When viewing order in admin panel following error is thrown:
Fatal error: Uncaught Error: Call to a member function getCarrierTitle() on boolean in /home/aleksaz/projects/magelatest/vendor/shipperhq/module-shipper/src/ViewModel/Listing.php:191 Stack trace: #0 /home/aleksaz/projects/magelatest/vendor/shipperhq/module-shipper/src/ViewModel/Listing.php(167): ShipperHQ\Shipper\ViewModel\Listing->getExistingRateForOrder(Object(Magento\Sales\Model\Order\Interceptor)) #1 /home/aleksaz/projects/magelatest/vendor/shipperhq/module-shipper/src/ViewModel/Listing.php(104): ShipperHQ\Shipper\ViewModel\Listing->initializeConfig() #2 /home/aleksaz/projects/magelatest/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(116): ShipperHQ\Shipper\ViewModel\Listing->__construct(Object(Magento\Catalog\Helper\Image), Object(Magento\Catalog\Model\ProductRepository\Interceptor), Object(Magento\Framework\Registry), Object(ShipperHQ\Shipper\Helper\Integration), Object(Magento\Store\Model\StoreManager), Object(Magento\Framework\App\ReinitableConfig), Object(ShipperHQ\Shipper\Helper\CarrierGroup) in /home/aleksaz/projects/magelatest/vendor/shipperhq/module-shipper/src/ViewModel/Listing.php on line 191
This was noticed on Magento 2.3.1 with luma theme and sample data but I believe same will happen on newer/older versions too.
In order to reproduce it, just order a downloadable product, for payment method I used check/money order, and then try viewing order in admin panel.
This happens because there is no shipping address in
quote_address
table for that order and one method in recently introduced code try's fetching that.Inside src/ViewModel/Listing.php
private function getExistingRateForOrder($order) { $quoteId = $order->getQuoteId(); $quote = $this->quoteRepository->get($quoteId, [$order->getStoreId()]); $shippingAddress = $quote->getShippingAddress(); $shippingRate = $shippingAddress->getShippingRateByCode($order->getShippingMethod()); return [ "carrier_title" => $shippingRate->getCarrierTitle(), "method_title" => $shippingRate->getMethodTitle(), "price" => $shippingRate->getPrice() ]; }