Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-show-decision
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-show-decision
Merge requests
!2
feature(conditions): additional
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
feature(conditions): additional
feature/conditions
into
master
Overview
0
Commits
1
Pipelines
1
Changes
21
Merged
Grzegorz Rola
requested to merge
feature/conditions
into
master
1 year ago
Overview
0
Commits
1
Pipelines
1
Changes
21
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
5e54f36b
1 commit,
1 year ago
21 files
+
451
−
178
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
21
src/WooCommerce/ShippingMethodInstanceStrategy.php
0 → 100644
+
46
−
0
View file @ 5e54f36b
Edit in single-file editor
Open in Web IDE
<?php
namespace
WPDesk\ShowDecision\WooCommerce
;
use
WPDesk\ShowDecision\ShouldShowStrategy
;
class
ShippingMethodInstanceStrategy
implements
ShouldShowStrategy
{
private
\WC_Shipping_Zones
$shipping_zones
;
private
string
$method_id
;
public
function
__construct
(
\WC_Shipping_Zones
$shipping_zones
,
string
$method_id
)
{
$this
->
shipping_zones
=
$shipping_zones
;
$this
->
method_id
=
$method_id
;
}
public
function
shouldDisplay
():
bool
{
if
(
$this
->
isInShippingSettings
())
{
if
(
isset
(
$_GET
[
'instance_id'
]))
{
$shipping_method
=
$this
->
shipping_zones
::
get_shipping_method
(
sanitize_key
(
$_GET
[
'instance_id'
]));
if
(
$shipping_method
instanceof
\WC_Shipping_Method
)
{
return
$shipping_method
->
id
===
$this
->
method_id
;
}
}
}
return
false
;
}
private
function
isInShippingSettings
()
:
bool
{
if
(
$this
->
isGetParameterWithValue
(
'page'
,
'wc-settings'
)
&&
$this
->
isGetParameterWithValue
(
'tab'
,
'shipping'
))
{
return
\true
;
}
return
\false
;
}
private
function
isGetParameterWithValue
(
string
$parameter
,
string
$value
)
:
bool
{
return
isset
(
$_GET
[
$parameter
])
&&
$_GET
[
$parameter
]
===
$value
;
}
}
Loading