Skip to content

Commit 7909f3b

Browse files
committed
3.2.3
0 parents  commit 7909f3b

File tree

66 files changed

+16339
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+16339
-0
lines changed

admin/admin-init.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
// Options page caps
4+
add_filter( 'option_page_capability__s_membership_pricing_rules', 'woocommerce_pricing_options_page_caps' );
5+
add_filter( 'option_page_capability__a_category_pricing_rules', 'woocommerce_pricing_options_page_caps' );
6+
add_filter( 'option_page_capability__s_category_pricing_rules', 'woocommerce_pricing_options_page_caps' );
7+
add_filter( 'option_page_capability__a_totals_pricing_rules', 'woocommerce_pricing_options_page_caps' );
8+
9+
add_filter( 'option_page_capability__a_taxonomy_product_brand_pricing_rules', 'woocommerce_pricing_options_page_caps' );
10+
add_filter( 'option_page_capability__s_taxonomy_product_brand_pricing_rules', 'woocommerce_pricing_options_page_caps' );
11+
12+
13+
function woocommerce_pricing_options_page_caps( $capability ) {
14+
return 'manage_woocommerce';
15+
}
16+
17+
require 'classes/product_pricing_rules_admin.class.php';
18+
require 'classes/category_pricing_rules_admin.class.php';
19+
require 'classes/membership_pricing_rules_admin.class.php';
20+
require 'classes/totals_pricing_rules_admin.class.php';
21+
require 'classes/store_pricing_rules_admin.class.php';
22+
require 'classes/group_pricing_rules_admin.class.php';
23+
require 'classes/taxonomy_pricing_rules_admin.class.php';
24+
25+
global $wc_store_pricing_admin;
26+
$wc_store_pricing_admin = new woocommerce_store_pricing_rules_admin();
27+
28+
global $wc_product_pricing_admin;
29+
$wc_product_pricing_admin = new woocommerce_product_pricing_rules_admin();
30+
31+
function woocommerce_pricing_product_admin_create_empty_ruleset() {
32+
global $wc_product_pricing_admin;
33+
$wc_product_pricing_admin->create_empty_ruleset( uniqid( 'set_' ) );
34+
die();
35+
}
36+
37+
function woocommerce_pricing_category_admin_create_empty_ruleset() {
38+
global $wc_store_pricing_admin;
39+
$wc_store_pricing_admin->category_admin->create_empty_ruleset( uniqid( 'set_' ) );
40+
die();
41+
}
42+
43+
function woocommerce_pricing_taxonomy_admin_create_empty_ruleset() {
44+
global $wc_store_pricing_admin;
45+
$wc_store_pricing_admin->taxonomy_admins[ $_POST['taxonomy'] ]->create_empty_ruleset( uniqid( 'set_' ) );
46+
die();
47+
}
48+
49+
function woocommerce_pricing_totals_admin_create_empty_ruleset() {
50+
global $wc_store_pricing_admin;
51+
$wc_store_pricing_admin->totals_admin->create_empty_ruleset( uniqid( 'set_' ) );
52+
die();
53+
}
54+
55+
add_action( 'wp_ajax_create_empty_ruleset', 'woocommerce_pricing_product_admin_create_empty_ruleset' );
56+
add_action( 'wp_ajax_create_empty_category_ruleset', 'woocommerce_pricing_category_admin_create_empty_ruleset' );
57+
add_action( 'wp_ajax_create_empty_totals_ruleset', 'woocommerce_pricing_totals_admin_create_empty_ruleset' );
58+
59+
add_action( 'wp_ajax_create_empty_taxonomy_ruleset', 'woocommerce_pricing_taxonomy_admin_create_empty_ruleset' );
60+

admin/classes/category_pricing_rules_admin.class.php

+807
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
class woocommerce_group_pricing_rules_admin {
4+
5+
public function __construct() {
6+
7+
}
8+
9+
public function on_init() {
10+
11+
}
12+
13+
public function basic_meta_box() {
14+
?>
15+
<div id="poststuff" class="woocommerce-roles-wrap">
16+
<?php settings_errors(); ?>
17+
<form method="post" action="options.php">
18+
<?php settings_fields( '_s_group_pricing_rules' ); ?>
19+
<?php $pricing_rules = get_option( '_s_group_pricing_rules' ); ?>
20+
21+
<table class="widefat">
22+
<thead>
23+
<th>Enabled</th>
24+
<th>
25+
Group
26+
</th>
27+
<th style="display:none;">Free Shipping?</th>
28+
<th>
29+
Type
30+
</th>
31+
<th>
32+
Amount
33+
</th>
34+
35+
</thead>
36+
<tbody>
37+
<?php
38+
$results = wc_dynamic_pricing_groups_get_all_groups();
39+
if ( !empty( $results ) && !is_wp_error( $results ) ):
40+
?>
41+
<?php $default = array('type' => 'percent', 'direction' => '+', 'amount' => '', 'free_shipping' => 'no'); ?>
42+
<?php $set_index = 0; ?>
43+
<?php foreach ( $results as $group ) : ?>
44+
<?php
45+
$group_id = $group['group_id'];
46+
47+
$set_index++;
48+
$name = 'set_' . $set_index;
49+
50+
$condition_index = 0;
51+
$index = 0;
52+
53+
$rule_set = $pricing_rules[$name];
54+
$rule = isset( $pricing_rules[$name] ) && isset( $pricing_rules[$name]['rules'][0] ) ? $pricing_rules[$name]['rules'][0] : array();
55+
$rule = array_merge( $default, $rule );
56+
?>
57+
<?php $checked = isset( $rule_set['conditions'][0]['args']['groups'] ) && in_array( $group_id, $rule_set['conditions'][0]['args']['groups'] ) ? 'checked="checked"' : ''; ?>
58+
<tr>
59+
<td>
60+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions_type]" value="all" />
61+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][type]" value="apply_to" />
62+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][args][applies_to]" value="groups" />
63+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][collector][type]" value="always" />
64+
<input class="checkbox" <?php echo $checked; ?> type="checkbox" id="group_<?php echo $group_id; ?>" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][args][groups][]" value="<?php echo $group_id; ?>" />
65+
</td>
66+
<td>
67+
<strong><?php echo $group['name']; ?></strong>
68+
</td>
69+
<td style="display:none;">
70+
71+
<input <?php checked( 'yes', $rule['free_shipping'] ); ?> type="checkbox" name="pricing_rules[<?php echo $name; ?>][rules][<?php echo $index; ?>][free_shipping]" value="yes" />
72+
73+
</td>
74+
<td>
75+
<select id="pricing_rule_type_value_<?php echo $name . '_' . $index; ?>" name="pricing_rules[<?php echo $name; ?>][rules][<?php echo $index; ?>][type]">
76+
<option <?php $this->selected( 'true', empty( $checked ) ); ?>></option>
77+
<option <?php $this->selected( 'fixed_product', $rule['type'] ); ?> value="fixed_product">Price Discount</option>
78+
<option <?php $this->selected( 'percent_product', $rule['type'] ); ?> value="percent_product">Percentage Discount</option>
79+
</select>
80+
</td>
81+
<td>
82+
<input type="text" name="pricing_rules[<?php echo $name; ?>][rules][<?php echo $index; ?>][amount]" value="<?php echo esc_attr( $rule['amount'] ); ?>" />
83+
</td>
84+
</tr>
85+
<?php endforeach; ?>
86+
<?php endif; ?>
87+
</tbody>
88+
</table>
89+
<p class="submit">
90+
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'woocommerce-dynamic-pricing' ); ?>" />
91+
</p>
92+
</form>
93+
</div>
94+
<?php
95+
}
96+
97+
private function selected( $value, $compare, $arg = true ) {
98+
if ( !$arg ) {
99+
echo '';
100+
} else if ( (string) $value == (string) $compare ) {
101+
echo 'selected="selected"';
102+
}
103+
}
104+
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
class woocommerce_membership_pricing_rules_admin {
4+
5+
public function __construct() {
6+
7+
}
8+
9+
public function on_init() {
10+
11+
}
12+
13+
public function basic_meta_box() {
14+
global $wp_roles;
15+
?>
16+
<div id="poststuff" class="woocommerce-roles-wrap">
17+
<?php settings_errors(); ?>
18+
<form method="post" action="options.php">
19+
<?php settings_fields( '_s_membership_pricing_rules' ); ?>
20+
<?php $pricing_rules = get_option( '_s_membership_pricing_rules' ); ?>
21+
22+
<table class="widefat">
23+
<thead>
24+
<th><?php _e( 'Enabled', 'woocommerce-dynamic-pricing' ); ?></th>
25+
<th>
26+
<?php _e( 'Role', 'woocommerce-dynamic-pricing' ); ?>
27+
</th>
28+
<th>
29+
<?php _e( 'Type', 'woocommerce-dynamic-pricing' ); ?>
30+
</th>
31+
<th>
32+
<?php _e( 'Amount', 'woocommerce-dynamic-pricing' ); ?>
33+
</th>
34+
35+
</thead>
36+
<tbody>
37+
<?php
38+
if ( ! isset( $wp_roles ) ) {
39+
$wp_roles = new WP_Roles();
40+
}
41+
$all_roles = $wp_roles->roles;
42+
?>
43+
<?php $default = array(
44+
'type' => 'percent',
45+
'direction' => '+',
46+
'amount' => '',
47+
'free_shipping' => 'no'
48+
); ?>
49+
<?php $set_index = 0; ?>
50+
<?php foreach ( $all_roles as $role_id => $role ) : ?>
51+
<?php
52+
$set_index ++;
53+
$name = 'set_' . $set_index;
54+
55+
$condition_index = 0;
56+
$index = 0;
57+
58+
$rule_set = $pricing_rules[ $name ];
59+
$rule = isset( $pricing_rules[ $name ] ) && isset( $pricing_rules[ $name ]['rules'][0] ) ? $pricing_rules[ $name ]['rules'][0] : array();
60+
$rule = array_merge( $default, $rule );
61+
?>
62+
<?php $checked = isset( $rule_set['conditions'][0]['args']['roles'] ) && in_array( $role_id, $rule_set['conditions'][0]['args']['roles'] ) ? 'checked="checked"' : ''; ?>
63+
<tr>
64+
<td>
65+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions_type]" value="all"/>
66+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][type]" value="apply_to"/>
67+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][args][applies_to]" value="roles"/>
68+
<input type="hidden" name="pricing_rules[<?php echo $name; ?>][collector][type]" value="always"/>
69+
<input class="checkbox" <?php echo $checked; ?> type="checkbox" id="role_<?php echo $role_id; ?>" name="pricing_rules[<?php echo $name; ?>][conditions][<?php echo $condition_index; ?>][args][roles][]" value="<?php echo $role_id; ?>"/>
70+
</td>
71+
<td>
72+
<strong><?php echo $role['name']; ?></strong>
73+
</td>
74+
<td>
75+
<select id="pricing_rule_type_value_<?php echo $name . '_' . $index; ?>" name="pricing_rules[<?php echo $name; ?>][rules][<?php echo $index; ?>][type]">
76+
<option <?php $this->selected( 'true', empty( $checked ) ); ?>></option>
77+
<option <?php $this->selected( 'fixed_product', $rule['type'] ); ?> value="fixed_product"><?php _e( 'Price Discount', 'woocommerce-dynamic-pricing' ); ?></option>
78+
<option <?php $this->selected( 'percent_product', $rule['type'] ); ?> value="percent_product"><?php _e( 'Percentage Discount', 'woocommerce-dynamic-pricing' ) ?></option>
79+
</select>
80+
</td>
81+
<td>
82+
<input type="text" name="pricing_rules[<?php echo $name; ?>][rules][<?php echo $index; ?>][amount]" value="<?php echo esc_attr( $rule['amount'] ); ?>"/>
83+
</td>
84+
</tr>
85+
<?php endforeach; ?>
86+
</tbody>
87+
</table>
88+
<p class="submit">
89+
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'woocommerce-dynamic-pricing' ); ?>"/>
90+
</p>
91+
</form>
92+
</div>
93+
<?php
94+
}
95+
96+
private function selected( $value, $compare, $arg = true ) {
97+
if ( ! $arg ) {
98+
echo '';
99+
} else if ( (string) $value == (string) $compare ) {
100+
echo 'selected="selected"';
101+
}
102+
}
103+
104+
}

0 commit comments

Comments
 (0)