FlexibleShippingMethodsChecker.php
1 week ago
ShippingMethod.php
1 week ago
WooSettingsPageChecker.php
1 week ago
FlexibleShippingMethodsChecker.php
35 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class FlexibleShippingMethodsChecker |
| 4 | * |
| 5 | * @package WPDesk\FS\Helpers |
| 6 | */ |
| 7 | |
| 8 | namespace WPDesk\FS\Helpers; |
| 9 | |
| 10 | use WPDesk\FS\TableRate\DefaultRulesSettings; |
| 11 | |
| 12 | /** |
| 13 | * Checker for FS Methods. |
| 14 | */ |
| 15 | class FlexibleShippingMethodsChecker { |
| 16 | /** |
| 17 | * @return bool |
| 18 | */ |
| 19 | public function is_new_shipping_method(): bool { |
| 20 | $shipping_methods = flexible_shipping_get_all_shipping_methods(); |
| 21 | |
| 22 | if ( ! isset( $shipping_methods['flexible_shipping'] ) ) { |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | $flexible_shipping_rates = array_values( $shipping_methods['flexible_shipping']->get_all_rates() ); |
| 27 | |
| 28 | if ( empty( $flexible_shipping_rates ) || count( $flexible_shipping_rates ) > 1 ) { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | return isset( $flexible_shipping_rates[0]['method_rules'][0][ DefaultRulesSettings::NEW_FIELD ] ); |
| 33 | } |
| 34 | } |
| 35 |