|
| 1 | +<?php |
| 2 | + |
| 3 | +class Woocommerce_Custom_Availability_Section { |
| 4 | + |
| 5 | + public function __construct() { |
| 6 | + add_filter( 'woocommerce_get_sections_products', array( $this, 'wcslider_add_section' ) ); |
| 7 | + add_filter( 'woocommerce_get_settings_products', array( $this, 'wcslider_all_settings' ), 10, 2 ); |
| 8 | + } |
| 9 | + |
| 10 | + /** |
| 11 | + * Create the section beneath the products tab |
| 12 | + **/ |
| 13 | + public function wcslider_add_section( $sections ) { |
| 14 | + $sections['custom_availability'] = __( 'Custom Availability', 'woocommerce-custom-availability' ); |
| 15 | + return $sections; |
| 16 | + } |
| 17 | + |
| 18 | + /** |
| 19 | + * Add settings to the specific section we created before |
| 20 | + */ |
| 21 | + public function wcslider_all_settings( $settings, $current_section ) { |
| 22 | + if ( $current_section === 'custom_availability' ) { |
| 23 | + $settings_slider = array(); |
| 24 | + // Add Title to the Settings |
| 25 | + $settings_slider[] = array( |
| 26 | + 'name' => __( 'Custom Availability Settings', 'woocommerce-custom-availability' ), |
| 27 | + 'type' => 'title', |
| 28 | + 'id' => 'custom_availability', |
| 29 | + ); |
| 30 | + |
| 31 | + $settings_slider[] = array( |
| 32 | + 'name' => __( 'Include Woocommerce Default Availability', 'woocommerce-custom-availability' ), |
| 33 | + 'desc_tip' => __( |
| 34 | + 'This will add default woocommerce availability |
| 35 | + message with our custom availability message.', |
| 36 | + 'woocommerce-custom-availability' |
| 37 | + ), |
| 38 | + 'id' => '_wca_include_woocommerce_availability', |
| 39 | + 'type' => 'checkbox', |
| 40 | + 'css' => 'min-width:300px;', |
| 41 | + 'desc' => __( 'Include Woocommerce Default Availability', 'woocommerce-custom-availability' ), |
| 42 | + ); |
| 43 | + |
| 44 | + $settings_slider[] = array( |
| 45 | + 'type' => 'sectionend', |
| 46 | + 'id' => 'custom_availability', |
| 47 | + ); |
| 48 | + return $settings_slider; |
| 49 | + } else { |
| 50 | + return $settings; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | +} |
| 55 | + |
| 56 | +$woocommerce_custom_availability_section = new Woocommerce_Custom_Availability_Section(); |
0 commit comments