Tracker
1 day ago
Assets.php
1 day ago
FreeShippingNotice.php
1 day ago
FreeShippingNoticeData.php
1 day ago
FreeShippingNoticeGenerator.php
1 day ago
FreeShippingNoticeRenderer.php
1 day ago
LffsNoticeTextFormatValidator.php
1 day ago
NoticeTextSettings.php
1 day ago
ProgressBarSettings.php
1 day ago
Tracker.php
1 day ago
NoticeTextSettings.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\TableRate\FreeShipping; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | |
| 7 | /** |
| 8 | * Can add settings field. |
| 9 | */ |
| 10 | class NoticeTextSettings implements Hookable { |
| 11 | |
| 12 | const FIELD_NAME = 'method_free_shipping_notice_text'; |
| 13 | |
| 14 | public function hooks() { |
| 15 | add_filter( 'flexible-shipping/settings/common-method-settings', [ $this, 'add_field_to_settings' ] ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @param array $settings |
| 20 | * |
| 21 | * @return array |
| 22 | */ |
| 23 | public function add_field_to_settings( $settings ) { |
| 24 | if ( ! is_array( $settings ) ) { |
| 25 | return $settings; |
| 26 | } |
| 27 | |
| 28 | $new_settings = []; |
| 29 | foreach ( $settings as $field_name => $field ) { |
| 30 | $new_settings[ $field_name ] = $field; |
| 31 | if ( $field_name === \WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ) { |
| 32 | $new_settings[ self::FIELD_NAME ] = $this->get_settings_field(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $new_settings; |
| 37 | } |
| 38 | |
| 39 | private function get_settings_field() { |
| 40 | return [ |
| 41 | 'title' => __( 'LFFS notice text', 'flexible-shipping' ), |
| 42 | 'type' => 'textarea', |
| 43 | // Translators: amount with currency. |
| 44 | 'placeholder' => __( 'You only need %1$s more to get free shipping!', 'flexible-shipping' ), |
| 45 | 'label' => __( 'Display the notice with the amount left for free shipping', 'flexible-shipping' ), |
| 46 | 'desc_tip' => sprintf( |
| 47 | // Translators: bold. |
| 48 | __( 'Enter your own custom text to be used for \'Left for free shipping\' notice in your shop. Please mind that inserting the %1$s%%1$s%2$s placeholder in the notice content is required to display the numeric value of the amount left for free shipping.', 'flexible-shipping' ), |
| 49 | '<b>', |
| 50 | '</b>' |
| 51 | ), |
| 52 | 'default' => '', |
| 53 | // Translators: bold. |
| 54 | 'description' => sprintf( __( 'The %1$s%%1$s%2$s placeholder displays the numeric value of the amount left for free shipping.', 'flexible-shipping' ), '<b>', '</b>' ), |
| 55 | ]; |
| 56 | } |
| 57 | |
| 58 | } |
| 59 |