Skip to content

Commit 9beb599

Browse files
authored
Merge pull request #135 from Hlavtox/fix-returns
Fix automated tests
2 parents 2d46d02 + ff15bdf commit 9beb599

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

classes/Hook/HookActionProductCancel.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Context;
2525
use OrderDetail;
2626
use Ps_Googleanalytics;
27+
use Validate;
2728

2829
class HookActionProductCancel implements HookInterface
2930
{
@@ -57,6 +58,12 @@ public function run()
5758
// Display GA refund product
5859
$orderDetail = new OrderDetail($this->params['id_order_detail']);
5960

61+
// Check if the hook provided us with a valid existing ID of order detail.
62+
// An example are automatic tests, which do not provide it unfortunately.
63+
if (!Validate::isLoadedObject($orderDetail)) {
64+
return;
65+
}
66+
6067
$idProduct = empty($orderDetail->product_attribute_id) ? $orderDetail->product_id : $orderDetail->product_id . '-' . $orderDetail->product_attribute_id;
6168
if ((bool) Configuration::get('GA_V4_ENABLED')) {
6269
$js = $this->getGoogleAnalytics4(

0 commit comments

Comments
 (0)