Skip to content

Commit e963723

Browse files
Merge pull request #2 from anttiviljami/master
Update to v1.2.0
2 parents 174bcd3 + 013c88b commit e963723

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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();

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: Woocommerce, Custom, Availability
44
Donate link: https://github.com/anttiviljami
55
Requires at least: 4.3.1
66
Tested up to: 4.8.2
7-
Stable tag: 1.1.0
7+
Stable tag: 1.2.0
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
1010

woocommerce-custom-availability.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin name: WooCommerce Custom Availability
44
* Plugin URI: https://github.com/anttiviljami/woocommerce-custom-availability
55
* Description: Set custom availability for products
6-
* Version: 1.1.0
6+
* Version: 1.2.0
77
* Author: @anttiviljami
88
* Author: https://github.com/anttiviljami
99
* License: GPLv3
@@ -70,12 +70,13 @@ private function __construct() {
7070
public function includes() {
7171
require_once plugin_dir_path( __FILE__ ) . 'includes/class-woocommerce-custom-availability-list-table.php';
7272
require_once plugin_dir_path( __FILE__ ) . 'includes/class-woocommerce-custom-availability-page.php';
73+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-woocommerce-custom-availability-tab.php';
7374
}
7475

7576
/**
7677
* Load our textdomain
7778
*/
78-
function load_our_textdomain() {
79+
public function load_our_textdomain() {
7980
load_plugin_textdomain( 'woocommerce-custom-availability', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
8081
}
8182

@@ -161,7 +162,11 @@ public function custom_availability( $availability, $product ) {
161162

162163
if ( ! empty( $custom_availability ) ) {
163164
$availability['class'] = 'custom-availability';
164-
$availability['availability'] = esc_attr( $custom_availability );
165+
if ( get_option( '_wca_include_woocommerce_availability', 'no' ) === 'yes' ) {
166+
$availability['availability'] .= ' <span>' . esc_attr( $custom_availability ) . '</span>';
167+
} else {
168+
$availability['availability'] = esc_attr( $custom_availability );
169+
}
165170
}
166171
return $availability;
167172
}

0 commit comments

Comments
 (0)