Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgo-magento-extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgo-magento-extension
Commits
ff3e9382
Commit
ff3e9382
authored
10 months ago
by
Christel Loftus
Browse files
Options
Downloads
Patches
Plain Diff
Add logging for rates at checkout
parent
9be7ff11
No related branches found
No related tags found
1 merge request
!6
Rates at checkout
Pipeline
#64959
passed
10 months ago
Stage: tagged_release
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Model/Carrier/BobGo.php
+18
-7
18 additions, 7 deletions
Model/Carrier/BobGo.php
with
18 additions
and
7 deletions
Model/Carrier/BobGo.php
+
18
−
7
View file @
ff3e9382
...
@@ -1179,6 +1179,7 @@
...
@@ -1179,6 +1179,7 @@
//}
//}
<?
php
namespace
BobGroup\BobGo\Model\Carrier
;
namespace
BobGroup\BobGo\Model\Carrier
;
use
Magento\Framework\App\Config\ScopeConfigInterface
;
use
Magento\Framework\App\Config\ScopeConfigInterface
;
...
@@ -1204,8 +1205,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1204,8 +1205,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
LoggerInterface
$logger
,
LoggerInterface
$logger
,
ZendClientFactory
$httpClientFactory
,
ZendClientFactory
$httpClientFactory
,
array
$data
=
[]
array
$data
=
[]
)
)
{
{
$this
->
scopeConfig
=
$scopeConfig
;
$this
->
scopeConfig
=
$scopeConfig
;
$this
->
httpClientFactory
=
$httpClientFactory
;
$this
->
httpClientFactory
=
$httpClientFactory
;
$this
->
logger
=
$logger
;
$this
->
logger
=
$logger
;
...
@@ -1214,10 +1214,15 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1214,10 +1214,15 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
public
function
collectRates
(
RateRequest
$request
)
public
function
collectRates
(
RateRequest
$request
)
{
{
$this
->
logger
->
info
(
'BobGo collectRates method called'
);
if
(
!
$this
->
getConfigFlag
(
'active'
))
{
if
(
!
$this
->
getConfigFlag
(
'active'
))
{
$this
->
logger
->
info
(
'BobGo is not active'
);
return
false
;
return
false
;
}
}
$this
->
logger
->
info
(
'BobGo is active, proceeding with rate collection'
);
$result
=
$this
->
_rateFactory
->
create
();
$result
=
$this
->
_rateFactory
->
create
();
// Prepare request data for API call
// Prepare request data for API call
...
@@ -1230,8 +1235,12 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1230,8 +1235,12 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
'package_qty'
=>
$request
->
getPackageQty
(),
'package_qty'
=>
$request
->
getPackageQty
(),
];
];
$this
->
logger
->
info
(
'Request parameters: '
.
json_encode
(
$params
));
try
{
try
{
$apiResponse
=
$this
->
_fetchRatesFromApi
(
$params
);
$apiResponse
=
$this
->
_fetchRatesFromApi
(
$params
);
$this
->
logger
->
info
(
'API response: '
.
json_encode
(
$apiResponse
));
if
(
$apiResponse
&&
isset
(
$apiResponse
[
'rates'
])
&&
!
empty
(
$apiResponse
[
'rates'
]))
{
if
(
$apiResponse
&&
isset
(
$apiResponse
[
'rates'
])
&&
!
empty
(
$apiResponse
[
'rates'
]))
{
foreach
(
$apiResponse
[
'rates'
]
as
$rateData
)
{
foreach
(
$apiResponse
[
'rates'
]
as
$rateData
)
{
$rate
=
$this
->
_rateMethodFactory
->
create
();
$rate
=
$this
->
_rateMethodFactory
->
create
();
...
@@ -1244,6 +1253,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1244,6 +1253,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
$result
->
append
(
$rate
);
$result
->
append
(
$rate
);
}
}
}
else
{
}
else
{
$this
->
logger
->
info
(
'No rates returned from API'
);
$error
=
$this
->
_rateErrorFactory
->
create
();
$error
=
$this
->
_rateErrorFactory
->
create
();
$error
->
setCarrier
(
$this
->
_code
);
$error
->
setCarrier
(
$this
->
_code
);
$error
->
setCarrierTitle
(
$this
->
getConfigData
(
'title'
));
$error
->
setCarrierTitle
(
$this
->
getConfigData
(
'title'
));
...
@@ -1251,7 +1261,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1251,7 +1261,7 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
return
$error
;
return
$error
;
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$this
->
logger
->
error
(
$e
->
getMessage
());
$this
->
logger
->
error
(
'Error fetching rates from API: '
.
$e
->
getMessage
());
$error
=
$this
->
_rateErrorFactory
->
create
();
$error
=
$this
->
_rateErrorFactory
->
create
();
$error
->
setCarrier
(
$this
->
_code
);
$error
->
setCarrier
(
$this
->
_code
);
$error
->
setCarrierTitle
(
$this
->
getConfigData
(
'title'
));
$error
->
setCarrierTitle
(
$this
->
getConfigData
(
'title'
));
...
@@ -1291,3 +1301,4 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
...
@@ -1291,3 +1301,4 @@ class BobGo extends AbstractCarrierOnline implements CarrierInterface
return
[
$this
->
_code
=>
$this
->
getConfigData
(
'name'
)];
return
[
$this
->
_code
=>
$this
->
getConfigData
(
'name'
)];
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment