flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-shipping-extensions
/
src
/
ShippingExtensions
/
WooCommerceSuggestions.php
flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-shipping-extensions
/
src
/
ShippingExtensions
Last commit date
Plugin
1 week ago
Promo
1 week ago
Tracker
1 week ago
views
1 week ago
AdminPage.php
1 week ago
Assets.php
1 week ago
DateRange.php
1 week ago
Page.php
1 week ago
PageViewTracker.php
1 week ago
PluginLinks.php
1 week ago
ShippingExtensions.php
1 week ago
TimedUpdate.php
1 week ago
TimedUpdates.php
1 week ago
WooCommerceSuggestions.php
1 week ago
WooCommerceSuggestions.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\Octolize\ShippingExtensions; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | class WooCommerceSuggestions implements Hookable |
| 7 | { |
| 8 | const SHIPPING_METHODS = ['dpd', 'dpd_uk', 'dhl', 'dpd_uk', 'enadawca', 'furgonetka', 'paczka_w_ruchu', 'paczkomaty_shipping_method', 'gls', 'gls-settings']; |
| 9 | const STYLE = '<style>.woocommerce-recommended-shipping-extensions { display: none; }</style>'; |
| 10 | public function hooks() |
| 11 | { |
| 12 | add_action('admin_head', [$this, 'add_css_on_octolize_pages']); |
| 13 | } |
| 14 | public function add_css_on_octolize_pages(): void |
| 15 | { |
| 16 | if ($this->is_octolize_page()) { |
| 17 | echo self::STYLE; |
| 18 | } |
| 19 | } |
| 20 | private function is_octolize_page(): bool |
| 21 | { |
| 22 | return isset($_GET['octolize']) || $this->is_octolize_shipping_method_page(); |
| 23 | } |
| 24 | private function is_octolize_shipping_method_page(): bool |
| 25 | { |
| 26 | return isset($_GET['page']) && 'wc-settings' === $_GET['page'] && isset($_GET['tab']) && 'shipping' === $_GET['tab'] && (isset($_GET['section']) && $this->is_octolize_shipping_method_settings($_GET['section']) || isset($_GET['instance_id']) && $this->is_octolize_shipping_method_instance_settings((int) $_GET['instance_id'])); |
| 27 | } |
| 28 | private function is_octolize_shipping_method_settings(string $section): bool |
| 29 | { |
| 30 | return in_array($section, self::SHIPPING_METHODS, \true) || strpos($section, 'flexible_shipping') === 0 || strpos($section, 'octolize') === 0; |
| 31 | } |
| 32 | private function is_octolize_shipping_method_instance_settings(int $instance_id): bool |
| 33 | { |
| 34 | $shipping_method = \WC_Shipping_Zones::get_shipping_method($instance_id); |
| 35 | return $shipping_method && $this->is_octolize_shipping_method_settings($shipping_method->id); |
| 36 | } |
| 37 | } |
| 38 |