BlockEditing
3 days ago
Convert
3 days ago
Duplicate
3 days ago
Management
3 days ago
Timestamps
3 days ago
Tracker
3 days ago
views
3 days ago
CommonMethodSettings.php
3 days ago
FreeShippingCalculator.php
3 days ago
FreeShippingThresholdRuleValidator.php
3 days ago
MethodDescription.php
3 days ago
MethodLogo.php
3 days ago
MethodLogoCheckoutBlocksAssets.php
3 days ago
MethodLogoSettingsField.php
3 days ago
MethodSettings.php
3 days ago
MethodTitle.php
3 days ago
RateCalculator.php
3 days ago
RateCalculatorFactory.php
3 days ago
SettingsDisplayPreparer.php
3 days ago
SettingsProcessor.php
3 days ago
SingleMethodSettings.php
3 days ago
MethodTitle.php
46 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class MethodTitle |
| 4 | * |
| 5 | * @package WPDesk\FS\TableRate\ShippingMethod |
| 6 | */ |
| 7 | |
| 8 | namespace WPDesk\FS\TableRate\ShippingMethod; |
| 9 | |
| 10 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 11 | use WC_Shipping_Method; |
| 12 | use WPDesk\FS\TableRate\ShippingMethodSingle; |
| 13 | |
| 14 | /** |
| 15 | * Can change method title. |
| 16 | */ |
| 17 | class MethodTitle implements Hookable { |
| 18 | /** |
| 19 | * Hooks. |
| 20 | */ |
| 21 | public function hooks() { |
| 22 | add_action( 'woocommerce_settings_shipping', array( $this, 'add_hook_on_settings_page' ), 10, 2 ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * . |
| 27 | */ |
| 28 | public function add_hook_on_settings_page() { |
| 29 | add_filter( 'woocommerce_shipping_method_title', array( $this, 'modify_shipping_method_title' ), 10, 2 ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @param string $title . |
| 34 | * @param WC_Shipping_Method $shipping_method . |
| 35 | * |
| 36 | * @return string |
| 37 | */ |
| 38 | public function modify_shipping_method_title( $title, $shipping_method ) { |
| 39 | if ( $shipping_method instanceof ShippingMethodSingle ) { |
| 40 | return $shipping_method->get_instance_option( 'method_title' ); |
| 41 | } |
| 42 | |
| 43 | return $title; |
| 44 | } |
| 45 | } |
| 46 |