Tracker
2 weeks ago
Assets.php
2 weeks ago
FreeShippingNotice.php
2 weeks ago
FreeShippingNoticeData.php
2 weeks ago
FreeShippingNoticeGenerator.php
2 weeks ago
FreeShippingNoticeRenderer.php
2 weeks ago
LffsNoticeTextFormatValidator.php
2 weeks ago
NoticeTextSettings.php
2 weeks ago
ProgressBarSettings.php
2 weeks ago
Tracker.php
2 weeks ago
ProgressBarSettings.php
54 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 ProgressBarSettings implements Hookable { |
| 11 | |
| 12 | const FIELD_NAME = 'method_free_shipping_progress_bar'; |
| 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 === NoticeTextSettings::FIELD_NAME ) { |
| 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 progress bar', 'flexible-shipping' ), |
| 42 | 'type' => 'checkbox', |
| 43 | 'default' => 'no', |
| 44 | 'label' => __( 'Display the \'Left for free shipping\' progress bar', 'flexible-shipping' ), |
| 45 | 'desc_tip' => sprintf( |
| 46 | __( 'Tick this checkbox to display an additional progress bar to your customers showing the amount left to qualify for free shipping.', 'flexible-shipping' ), |
| 47 | '<b>', |
| 48 | '</b>' |
| 49 | ), |
| 50 | ]; |
| 51 | } |
| 52 | |
| 53 | } |
| 54 |