PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
← All changes | src/Admin/ProductPage/AdvanceOptionsForVariableProduct.php +38 -5 6.5.0 → 8.0.2 View file →
@@ -59,9 +59,9 @@
59 59 </option>
60 60 <?php endif; ?>
61 61 </select>
62 62 </p>
63 - <div style="padding: 0 20px 0px 162px;
63 + <div style="padding: 0 20px 0 162px;
64 64 margin-bottom: 10px;
65 65 color: #666;
66 66 margin-top: -10px;
67 67 font-size: 12px;">
@@ -78,8 +78,31 @@
78 78 'label' => __( 'Variations share pricing', 'tier-pricing-table' ),
79 79 'description' => __( 'Use the default variation\'s pricing for all variations to prevent reloading the pricing table.',
80 80 'tier-pricing-table' ),
81 81 ) );
82 +
83 + woocommerce_wp_select( array(
84 + 'id' => '_tiered_price_mix_and_match_minimum',
85 + 'value' => get_post_meta( $productId, '_tiered_price_mix_and_match_minimum', true ),
86 + 'options' => array(
87 + '' => __( 'Global Settings', 'tier-pricing-table' ),
88 + 'no' => __( 'Individual variation', 'tier-pricing-table' ),
89 + 'yes' => __( 'Variable product total (Mix & match)', 'tier-pricing-table' ),
90 + ),
91 + 'label' => __( 'Calculate minimum quantity by', 'tier-pricing-table' ),
92 + ) );
93 + ?>
94 + <div style="padding: 0 20px 0 162px;
95 + margin-bottom: 10px;
96 + color: #666;
97 + margin-top: -10px;
98 + font-size: 12px;">
99 + <?php
100 + esc_html_e( 'Determine whether the minimum quantity requirement applies to each variation separately, or to the combined total of all variations in the cart.',
101 + 'tier-pricing-table' );
102 + ?>
103 + </div>
104 + <?php
82 105 } );
83 106 }
84 107
85 108 /**
@@ -97,13 +120,23 @@
97 120 $data = $_POST;
98 121
99 122 $defaultVariation = ! empty( $data['_tiered_pricing_default_variation_id'] ) ? intval( $data['_tiered_pricing_default_variation_id'] ) : null;
100 123 $samePrices = ! empty( $data['_tiered_pricing_variable_product_same_prices'] );
124 + $mixAndMatch = isset( $data['_tiered_price_mix_and_match_minimum'] ) ? sanitize_text_field( $data['_tiered_price_mix_and_match_minimum'] ) : '';
101 125
102 126 self::updateDefaultVariation( $productId, $defaultVariation );
103 127 self::updateVariableProductSamePrices( $productId, $samePrices );
128 + self::updateMixAndMatchMinimum( $productId, $mixAndMatch );
104 129 }
105 130
131 + public static function updateMixAndMatchMinimum( $productId, $mixAndMatch ) {
132 + if ( in_array( $mixAndMatch, array( 'yes', 'no' ) ) ) {
133 + update_post_meta( $productId, '_tiered_price_mix_and_match_minimum', $mixAndMatch );
134 + } else {
135 + delete_post_meta( $productId, '_tiered_price_mix_and_match_minimum' );
136 + }
137 + }
138 +
106 139 public static function isVariableProductSamePrices( $productId ): bool {
107 140 return 'yes' === get_post_meta( $productId, '_tiered_pricing_variable_product_same_prices', true );
108 141 }
109 142
@@ -155,9 +188,9 @@
155 188 $term = (string) wc_clean( wp_unslash( $_GET['term'] ) );
156 189 }
157 190
158 191 if ( empty( $term ) ) {
159 - return wp_send_json( array() );
192 + wp_send_json( array() );
160 193 }
161 194
162 195 $limit = 30;
163 196 $include = ! empty( $_GET['include'] ) ? intval( $_GET['include'] ) : false;
@@ -162,15 +195,15 @@
162 195 $limit = 30;
163 196 $include = ! empty( $_GET['include'] ) ? intval( $_GET['include'] ) : false;
164 197
165 198 if ( ! $include ) {
166 - return wp_send_json( array() );
199 + wp_send_json( array() );
167 200 }
168 201
169 202 $product = wc_get_product( $include );
170 203
171 204 if ( ! TierPricingTablePlugin::isVariableProductSupported( $product ) ) {
172 - return wp_send_json( array() );
205 + wp_send_json( array() );
173 206 }
174 207
175 208 $results = array();
176 209
@@ -204,7 +237,7 @@
204 237 $results[ str_replace( '_', '', $key ) ] = $rawVariations[ $key ];
205 238 }
206 239 }
207 240
208 - return wp_send_json( $results );
241 + wp_send_json( $results );
209 242 }
210 243 }