Changeset 3418398
- Timestamp:
- 12/12/2025 03:35:48 PM (4 months ago)
- Location:
- woo-additional-fees-on-checkout-wordpress
- Files:
-
- 21 added
- 8 deleted
- 6 edited
-
tags/1.5.1/assets (deleted)
-
tags/1.5.1/classes (deleted)
-
tags/1.5.1/readme.txt (deleted)
-
tags/1.5.1/woo-additional-fees-checkout-free.php (deleted)
-
tags/1.5.1/woo-ext-cost-premium.php (deleted)
-
tags/1.5.1/woocommerce (deleted)
-
tags/1.5.2 (added)
-
tags/1.5.2/assets (added)
-
tags/1.5.2/assets/css (added)
-
tags/1.5.2/assets/css/admin-style.css (added)
-
tags/1.5.2/assets/css/style.css (added)
-
tags/1.5.2/assets/css/wafc-select2.min.css (added)
-
tags/1.5.2/assets/js (added)
-
tags/1.5.2/assets/js/wafc-select2.min.js (added)
-
tags/1.5.2/assets/js/wps-ext-cst.js (added)
-
tags/1.5.2/classes (added)
-
tags/1.5.2/classes/wps-ext-cst-admin-settings.php (added)
-
tags/1.5.2/classes/wps-ext-cst-admin.php (added)
-
tags/1.5.2/classes/wps-ext-cst-extra-fees-frontend.php (added)
-
tags/1.5.2/classes/wps-ext-cst-frontend.php (added)
-
tags/1.5.2/classes/wps-ext-cst-main.php (added)
-
tags/1.5.2/readme.txt (added)
-
tags/1.5.2/woo-additional-fees-checkout.php (added)
-
tags/1.5.2/woocommerce (added)
-
tags/1.5.2/woocommerce/checkout (added)
-
tags/1.5.2/woocommerce/checkout/review-order.php (added)
-
trunk/assets/css/admin-style.css (modified) (1 diff)
-
trunk/classes/wps-ext-cst-admin-settings.php (modified) (12 diffs)
-
trunk/classes/wps-ext-cst-admin.php (modified) (6 diffs)
-
trunk/classes/wps-ext-cst-extra-fees-frontend.php (modified) (5 diffs)
-
trunk/classes/wps-ext-cst-frontend.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woo-additional-fees-checkout-free.php (deleted)
-
trunk/woo-additional-fees-checkout.php (added)
-
trunk/woo-ext-cost-premium.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
woo-additional-fees-on-checkout-wordpress/trunk/assets/css/admin-style.css
r3388342 r3418398 166 166 display: inline-block; 167 167 } 168 .wps-feat-not{ 169 168 .wps-feat-not{ 170 169 font-size: 10px; 171 170 font-weight: 600; 172 171 color: #e7000087; 173 174 172 } 173 .wps-feat-prem{ 174 font-size: 10px; 175 font-weight: 600; 176 color: grey; 177 } -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-admin-settings.php
r3388342 r3418398 10 10 register_setting("wps-ext-cst-option-section", "ext_cst_amount_type"); 11 11 register_setting("wps-ext-cst-option-section", "ext_cst_amount"); 12 register_setting("wps-ext-cst-option-section", "ext_cst_auto_checked");13 register_setting("wps-ext-cst-option-section", "ext_cst_apply_cndtn");14 register_setting("wps-ext-cst-option-section", "cart_total_amount_min");15 register_setting("wps-ext-cst-option-section", "cart_total_amount_max");16 register_setting("wps-ext-cst-option-section", "cart_no_product_min");17 register_setting("wps-ext-cst-option-section", "cart_no_product_max");18 register_setting("wps-ext-cst-option-section", "selected_product_id");19 register_setting("wps-ext-cst-option-section", "selected_cat_id");20 register_setting("wps-ext-cst-option-section", "selected_pr_type");21 register_setting("wps-ext-cst-option-section", "ext_cst_is_required");22 12 register_setting("wps-ext-cst-option-section", "ext_cst_label_css"); 23 13 register_setting("wps-ext-cst-option-section", "ext_cst_inc_ship_costs"); 24 14 register_setting("wps-ext-cst-option-section", "ext_cst_inc_tax"); 25 register_setting("wps-ext-cst-option-section","ext_cst_hide_option");26 register_setting("wps-ext-cst-option-section","ext_cst_apply_type");27 15 28 16 … … 48 36 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 49 37 $ext_cst_amount = (get_option('ext_cst_amount')) ? get_option('ext_cst_amount') : 1; 50 $ext_cst_auto_checked = (get_option('ext_cst_auto_checked')) ? get_option('ext_cst_auto_checked') : 'disable';51 $ext_cst_apply_cndtn = (get_option('ext_cst_apply_cndtn')) ? get_option('ext_cst_apply_cndtn') : 'all';52 $cart_total_amount_min = (get_option('cart_total_amount_min')) ? get_option('cart_total_amount_min') : 1;53 $cart_total_amount_max = (get_option('cart_total_amount_max')) ? get_option('cart_total_amount_max') : 1;54 $cart_no_product_min = (get_option('cart_no_product_min')) ? get_option('cart_no_product_min') : 1;55 $cart_no_product_max = (get_option('cart_no_product_max')) ? get_option('cart_no_product_max') : 1;56 $selected_product_id = (get_option('selected_product_id')) ? get_option('selected_product_id') : array();57 $selected_cat_id = (get_option('selected_cat_id')) ? get_option('selected_cat_id') : array();58 $selected_pr_type = (get_option('selected_pr_type')) ? get_option('selected_pr_type') : array();59 60 $ext_cst_is_required = (get_option('ext_cst_is_required')) ? get_option('ext_cst_is_required') : 'no';61 38 $ext_cst_label_css = (get_option('ext_cst_label_css')) ? get_option('ext_cst_label_css') : ''; 62 39 $ext_cst_inc_ship_costs = (get_option('ext_cst_inc_ship_costs')) ? get_option('ext_cst_inc_ship_costs') : 'no'; 63 40 $ext_cst_inc_tax = (get_option('ext_cst_inc_tax')) ? get_option('ext_cst_inc_tax') : 'no'; 64 $ext_cst_hide_option = (get_option('ext_cst_hide_option')) ? get_option('ext_cst_hide_option') : 'no';65 $ext_cst_apply_type = (get_option('ext_cst_apply_type')) ? get_option('ext_cst_apply_type') : 'multiply';66 41 67 42 $extra_options = get_option('ext_cst_extra'); … … 129 104 <td> 130 105 <select data-id="1" class="ext_cst_cndtn_dropdown" name="ext_cst_apply_type" id="ext_cst_apply_type"> 131 <option value="one_time" <?php if($ext_cst_apply_type=='one_time'){echo 'selected';} ?>>One Time Only</option>132 <option value="multiply" <?php if($ext_cst_apply_type=='multiply'){echo 'selected';} ?>>Multiplied By Product Quantity</option>106 <option value="one_time">One Time Only</option> 107 <option value="multiply">Multiplied By Product Quantity</option> 133 108 </select> 134 109 <p>If you want to charge additional fees for each product quantity into cart then choose <b>Multiplied By Product Quantity.</b> otherwise choose One Time Only.</p> 110 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 135 111 </td> 136 112 </tr> … … 142 118 <td> 143 119 <select name="ext_cst_auto_checked" id="ext_cst_auto_checked"> 144 <option value="enable" <?php if($ext_cst_auto_checked=='enable'){echo 'selected';} ?>>Enable</option> 145 <option value="disable" <?php if($ext_cst_auto_checked=='disable'){echo 'selected';} ?>>Disable</option> 146 </select> 120 <option>Enable</option> 121 <option>Disable</option> 122 </select> 123 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 147 124 </td> 148 125 </tr> … … 151 128 <td> 152 129 <select data-id="1" class="ext_cst_cndtn_dropdown" name="ext_cst_apply_cndtn" id="ext_cst_apply_cndtn" onchange="show_hide_cndtn()"> 153 <option value="all" <?php if($ext_cst_apply_cndtn=='all'){echo 'selected';} ?>>All</option> 154 <option value="cart_total_amount" <?php if($ext_cst_apply_cndtn=='cart_total_amount'){echo 'selected';} ?>>Cart Total Amount</option> 155 <option value="cart_no_product" <?php if($ext_cst_apply_cndtn=='cart_no_product'){echo 'selected';} ?>>Number of Product on Cart</option> 156 <option value="selected_product" <?php if($ext_cst_apply_cndtn=='selected_product'){echo 'selected';} ?>>Selected Product</option> 157 <option value="selected_category" <?php if($ext_cst_apply_cndtn=='selected_category'){echo 'selected';} ?>>Selected Category</option> 158 <option value="selected_pr_type" <?php if($ext_cst_apply_cndtn=='selected_pr_type'){echo 'selected';} ?>>Selected Product Type</option> 159 </select> 160 </td> 161 </tr> 162 <tr id="cart_total_amount" class="cndtn_mode"> 163 <th scope="row"><label><?php _e( 'Cart Amount'); ?></label></th> 164 <td> 165 <label>Minimum</label> 166 <input type="number" name="cart_total_amount_min" class="small-text" id="cart_total_amount_min" value="<?php echo $cart_total_amount_min; ?>"/> 167 168 <label>Maximum</label> 169 <input type="number" name="cart_total_amount_max" class="small-text" id="cart_total_amount_max" value="<?php echo $cart_total_amount_max; ?>"/> 170 </td> 171 </tr> 172 <tr id="cart_no_product" class="cndtn_mode"> 173 <th scope="row"><label><?php _e( 'No. Of Product on Cart'); ?></label></th> 174 <td> 175 <label>Minimum</label> 176 <input type="number" name="cart_no_product_min" class="small-text" id="cart_no_product_min" value="<?php echo $cart_no_product_min; ?>"/> 177 178 <label>Maximum</label> 179 <input type="number" name="cart_no_product_max" class="small-text" id="cart_no_product_max" value="<?php echo $cart_no_product_max; ?>"/> 180 </td> 181 </tr> 182 <tr id="selected_product" class="cndtn_mode"> 183 <th scope="row"><label><?php _e( 'Select Product'); ?></label></th> 184 <td> 185 <select name="selected_product_id[]" id="selected_product_id" multiple="multiple" class="wps_wafc_multiselect"> 186 <?php 187 $selected_product_id = (is_array($selected_product_id)) ? $selected_product_id : array($selected_product_id); 188 $args = array( 189 'post_type' => 'product', 190 'posts_per_page' => -1 191 ); 192 $loop = new WP_Query( $args ); 193 if ( $loop->have_posts() ) { 194 while ( $loop->have_posts() ) : $loop->the_post();?> 195 <option value="<?php echo get_the_ID(); ?>" <?php if(in_array(get_the_ID(),$selected_product_id)){echo 'selected';} ?>><?php echo get_the_title(); ?></option> 196 <?php 197 endwhile; 198 } else { 199 echo '<option>No products found</option>'; 200 } 201 wp_reset_postdata(); 202 ?> 203 </select> 204 </td> 205 </tr> 206 <tr id="selected_category" class="cndtn_mode"> 207 <th scope="row"><label><?php _e( 'Select Product Category'); ?></label></th> 208 <td> 209 <select name="selected_cat_id[]" id="selected_cat_id" multiple="multiple" class="wps_wafc_multiselect"> 210 <?php 211 $args = array( 212 'taxonomy' => 'product_cat', 213 'orderby' => 'name', 214 'order' => 'ASC', 215 'hide_empty' => false 216 ); 217 $categories = get_categories( $args ); 218 if ( $categories ) { 219 foreach( $categories as $category ) :?> 220 <option value="<?php echo $category->term_id; ?>" <?php if(in_array($category->term_id,$selected_cat_id)){echo 'selected';} ?>><?php echo $category->name.' ('.$category->count.')'; ?></option> 221 <?php 222 endforeach; 223 } else { 224 echo '<option>No category found</option>'; 225 } 226 ?> 227 </select> 228 </td> 229 </tr> 230 <tr id="selected_pr_type" class="cndtn_mode"> 231 <th scope="row"><label><?php _e( 'Select Product Type'); ?></label></th> 232 <td> 233 <select name="selected_pr_type[]" id="selected_pr_type" multiple="multiple" class="wps_wafc_multiselect"> 234 <?php 235 $pr_types = array('simple','grouped','variable','external_affiliate'); 236 foreach ( $pr_types as $types ) :?> 237 <option value="<?php echo $types; ?>" <?php if(in_array($types,$selected_pr_type)){echo 'selected';} ?>><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 238 <?php 239 endforeach; 240 ?> 241 </select> 130 <option value="all">All</option> 131 <option>Cart Total Amount</option> 132 <option>Number of Product on Cart</option> 133 <option>Selected Product</option> 134 <option>Selected Category</option> 135 <option>Selected Product Type</option> 136 </select> 137 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 242 138 </td> 243 139 </tr> … … 250 146 <td> 251 147 <select name="ext_cst_is_required" id="ext_cst_is_required"> 252 <option value="no" <?php if($ext_cst_is_required=='no'){ echo 'selected';} ?>>No</option> 253 <option value="yes" <?php if($ext_cst_is_required=='yes'){ echo 'selected';} ?>>Yes</option> 254 </select> 148 <option value="no">No</option> 149 <option value="yes">Yes</option> 150 </select> 151 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 255 152 </td> 256 153 </tr> … … 262 159 <td> 263 160 <select name="ext_cst_hide_option" id="ext_cst_hide_option"> 264 <option value="no" <?php if($ext_cst_hide_option=='no'){echo 'selected';} ?>>No</option> 265 <option value="yes" <?php if($ext_cst_hide_option=='yes'){echo 'selected';} ?>>Yes</option> 266 </select> 161 <option value="no">No</option> 162 <option>Yes</option> 163 </select> 164 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 267 165 </td> 268 166 </tr> … … 353 251 <td> 354 252 <select name="ext_cst_extra[<?php echo $option; ?>][apply_type]" id="ext_cst_apply_type<?php echo $option; ?>"> 355 <option value="one_time" <?php if($value['apply_type']=='one_time'){echo 'selected';} ?>>One Time Only</option>356 <option value="multiply" <?php if($value['apply_type']=='multiply'){echo 'selected';} ?>>Multiplied By Product Quantity</option>253 <option value="one_time">One Time Only</option> 254 <option value="multiply">Multiplied By Product Quantity</option> 357 255 </select> 358 256 <p>If you want to charge additional fees for each product quantity into cart then choose <b>Multiplied By Product Quantity.</b> otherwise choose One Time Only.</p> 257 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 359 258 </td> 360 259 </tr> … … 366 265 <td> 367 266 <select name="ext_cst_extra[<?php echo $option; ?>][auto_checked]" id="ext_cst_auto_checked_extra"> 368 <option value="enable" <?php if(isset($value['auto_checked']) && $value['auto_checked']=='enable'){ echo 'selected=selected';} ?>>Enable</option> 369 <option value="disable" <?php if(isset($value['auto_checked']) && $value['auto_checked']=='disable'){ echo 'selected=selected';} ?>>Disable</option> 370 </select> 267 <option value="enable">Enable</option> 268 <option value="disable">Disable</option> 269 </select> 270 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 371 271 </td> 372 272 </tr> … … 375 275 <td> 376 276 <select data-id="<?php echo $option; ?>" class="ext_cst_cndtn_dropdown" name="ext_cst_extra[<?php echo $option; ?>][apply_cndtn]" id="ext_cst_apply_cndtn_extra<?php echo $option; ?>" onchange="show_hide_cndtn_extra(<?php echo $option; ?>)"> 377 <option value="all" <?php if($value['apply_cndtn']=='all'){ echo 'selected=selected';} ?>>All</option> 378 <option value="cart_total_amount" <?php if($value['apply_cndtn']=='cart_total_amount'){ echo 'selected=selected';} ?> >Cart Total Amount</option> 379 <option value="cart_no_product" <?php if($value['apply_cndtn']=='cart_no_product'){ echo 'selected=selected';} ?>>Number of Product on Cart</option> 380 <option value="selected_product" <?php if($value['apply_cndtn']=='selected_product'){ echo 'selected=selected';} ?>>Selected Product</option> 381 <option value="selected_category" <?php if($value['apply_cndtn']=='selected_category'){ echo 'selected=selected';} ?>>Selected Category</option> 382 <option value="selected_pr_type" <?php if($value['apply_cndtn']=='selected_pr_type'){ echo 'selected=selected';} ?>>Selected Product Type</option> 383 </select> 384 </td> 385 </tr> 386 <tr id="cart_total_amount<?php echo $option; ?>" class="cndtn_mode_extra<?php echo $option; ?>"> 387 <th scope="row"><label><?php _e( 'Cart Amount'); ?></labe></td> 388 <td> 389 <label>Minimum</label> 390 <input type="number" name="ext_cst_extra[<?php echo $option; ?>][cart_total_amount_min_extra]" class="small-text" id="cart_total_amount_min_extra" value="<?php echo $value['cart_total_amount_min_extra']; ?>"/> 391 392 <label>Maximum</label> 393 <input type="number" name="ext_cst_extra[<?php echo $option; ?>][cart_total_amount_max_extra]" class="small-text" id="cart_total_amount_max_extra" value="<?php echo $value['cart_total_amount_max_extra']; ?>"/> 394 </td> 395 </tr> 396 <tr id="cart_no_product<?php echo $option; ?>" class="cndtn_mode_extra<?php echo $option; ?>"> 397 <th scope="row"><label><?php _e( 'No. Of Product on Cart'); ?></labe></td> 398 <td> 399 <label>Minimum</label> 400 <input type="number" name="ext_cst_extra[<?php echo $option; ?>][cart_no_product_min_extra]" class="small-text" id="cart_no_product_min_extra" value="<?php echo $value['cart_no_product_min_extra']; ?>"/> 401 402 <label>Maximum</label> 403 <input type="number" name="ext_cst_extra[<?php echo $option; ?>][cart_no_product_max_extra]" class="small-text" id="cart_no_product_max_extra" value="<?php echo $value['cart_no_product_max_extra']; ?>"/> 404 </td> 405 </tr> 406 <tr id="selected_product<?php echo $option; ?>" class="cndtn_mode_extra<?php echo $option; ?>"> 407 <th scope="row"><label><?php _e( 'Selected Product'); ?><label></th> 408 <td> 409 <select name="ext_cst_extra[<?php echo $option; ?>][selected_product_id_extra][]" multiple="multiple" class="wps_wafc_multiselect"> 410 <?php 411 $args = array( 412 'post_type' => 'product', 413 'posts_per_page' => -1 414 ); 415 $loop = new WP_Query( $args ); 416 if ( $loop->have_posts() ) { 417 while ( $loop->have_posts() ) : $loop->the_post();?> 418 <option <?php if(in_array(get_the_ID(),$selected_product_id_extra)){ echo 'selected=selected';} ?> value="<?php echo get_the_ID(); ?>"><?php echo get_the_title(); ?></option> 419 <?php 420 endwhile; 421 } else { 422 echo '<option>No products found</option>'; 423 } 424 wp_reset_postdata(); 425 ?> 426 </select> 427 </td> 428 </tr> 429 <tr id="selected_category<?php echo $option; ?>" class="cndtn_mode_extra<?php echo $option; ?>"> 430 <th scope="row"><label><?php _e( 'Selected Product Category'); ?><label></th> 431 <td> 432 <select name="ext_cst_extra[<?php echo $option; ?>][selected_cat_id_extra][]" multiple="multiple" class="wps_wafc_multiselect"> 433 <?php 434 $args = array( 435 'taxonomy' => 'product_cat', 436 'orderby' => 'name', 437 'order' => 'ASC', 438 'hide_empty' => false 439 ); 440 $categories = get_categories( $args ); 441 if ( $categories ) { 442 foreach( $categories as $category ) :?> 443 <option value="<?php echo $category->term_id; ?>" <?php if(in_array($category->term_id,$selected_cat_id_extra)){echo 'selected';} ?>><?php echo $category->name.' ('.$category->count.')'; ?></option> 444 <?php 445 endforeach; 446 } else { 447 echo '<option>No category found</option>'; 448 } 449 ?> 450 451 </select> 452 </td> 453 </tr> 454 <tr id="selected_pr_type<?php echo $option; ?>" class="cndtn_mode_extra<?php echo $option; ?>"> 455 <th scope="row"><label><?php _e( 'Selected Product Type'); ?><label></th> 456 <td> 457 <select name="ext_cst_extra[<?php echo $option; ?>][selected_pr_type_extra][]" multiple="multiple" class="wps_wafc_multiselect"> 458 <?php 459 $pr_types = array('simple','grouped','variable','external_affiliate'); 460 foreach ( $pr_types as $types ) :?> 461 <option value="<?php echo $types; ?>" <?php if(in_array($types,$selected_pr_type_extra)){echo 'selected';} ?>><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 462 <?php 463 endforeach; 464 ?> 465 </select> 466 </td> 467 </tr> 277 <option value="all">All</option> 278 <option>Cart Total Amount</option> 279 <option>Number of Product on Cart</option> 280 <option>Selected Product</option> 281 <option>Selected Category</option> 282 <option>Selected Product Type</option> 283 </select> 284 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 285 </td> 286 </tr> 287 468 288 <tr> 469 289 <th scope="row"> … … 473 293 <td> 474 294 <select name="ext_cst_extra[<?php echo $option; ?>][ext_cst_is_required_extra]" name="" id="ext_cst_is_required_extra"> 475 <option value="no" <?php if(isset($value['ext_cst_is_required_extra']) && $value['ext_cst_is_required_extra']=='no'){ echo 'selected';} ?>>No</option> 476 <option value="yes" <?php if(isset($value['ext_cst_is_required_extra']) && $value['ext_cst_is_required_extra']=='yes'){ echo 'selected';} ?>>Yes</option> 477 </select> 295 <option value="no">No</option> 296 <option value="yes">Yes</option> 297 </select> 298 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 478 299 </td> 479 300 </tr> … … 485 306 <td> 486 307 <select name="ext_cst_extra[<?php echo $option; ?>][hide_on_frontend]" id="ext_cst_hide_on_frontend<?php echo $option; ?>"> 487 <option value="no" <?php if(isset($value['hide_on_frontend']) && $value['hide_on_frontend']=='no'){echo 'selected';} ?>>No</option> 488 <option value="yes" <?php if(isset($value['hide_on_frontend']) && $value['hide_on_frontend']=='yes'){echo 'selected';} ?>>Yes</option> 489 </select> 308 <option value="no">No</option> 309 <option value="yes">Yes</option> 310 </select> 311 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 490 312 </td> 491 313 </tr> -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-admin.php
r3388342 r3418398 82 82 </td> 83 83 </tr> 84 <?php /* To show fee after tax row, change woocommerce/includes/class-wcorder.php(2047) get_order_item_totals file */ ?>85 84 <tr> 86 85 <th scope="row"><label><?php _e( 'Amount'); ?></labe></td> … … 97 96 </select> 98 97 <p>If you want to charge additional fees for each product quantity into cart then choose <b>Multiplied By Product Quantity.</b> otherwise choose One Time Only.</p> 98 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 99 99 </td> 100 100 </tr> … … 109 109 <option value="enable">Enable</option> 110 110 </select> 111 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 111 112 </td> 112 113 </tr> … … 122 123 <option value="selected_pr_type">Selected Product Type</option> 123 124 </select> 125 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 124 126 </td> 125 127 </tr> 126 <tr id="cart_total_amount<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 127 <th scope="row"><label><?php _e( 'Cart Amount'); ?></labe></td> 128 <td> 129 <label>Minimum</label> 130 <input type="number" name="ext_cst_extra[<?php echo $_POST['number']; ?>][cart_total_amount_min_extra]" class="small-text" id="cart_total_amount_min_extra" value=""/> 131 132 <label>Maximum</label> 133 <input type="number" name="ext_cst_extra[<?php echo $_POST['number']; ?>][cart_total_amount_max_extra]" class="small-text" id="cart_total_amount_max_extra" value=""/> 134 </td> 135 </tr> 136 <tr id="cart_no_product<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 137 <th scope="row"><label><?php _e( 'No. Of Product on Cart'); ?></labe></td> 138 <td> 139 <label>Minimum</label> 140 <input type="number" name="ext_cst_extra[<?php echo $_POST['number']; ?>][cart_no_product_min_extra]" class="small-text" id="cart_no_product_min_extra" value=""/> 141 142 <label>Maximum</label> 143 <input type="number" name="ext_cst_extra[<?php echo $_POST['number']; ?>][cart_no_product_max_extra]" class="small-text" id="cart_no_product_max_extra" value=""/> 144 </td> 145 </tr> 146 <tr id="selected_product<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 147 <th scope="row"><label><?php _e( 'Selected Product'); ?><label></th> 148 <td> 149 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][selected_product_id_extra][]" id="selected_product_id_extra" class="wps_wafc_multiselect" multiple="multiple"> 150 <?php 151 $args = array( 152 'post_type' => 'product', 153 'posts_per_page' => -1 154 ); 155 $loop = new WP_Query( $args ); 156 if ( $loop->have_posts() ) { 157 while ( $loop->have_posts() ) : $loop->the_post();?> 158 <option value="<?php echo get_the_ID(); ?>"><?php echo get_the_title(); ?></option> 159 <?php 160 endwhile; 161 } else { 162 echo '<option>No products found</option>'; 163 } 164 wp_reset_postdata(); 165 ?> 166 </select> 167 </td> 168 </tr> 169 <tr id="selected_category<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 170 <th scope="row"><label><?php _e( 'Selected Product Category'); ?><label></th> 171 <td> 172 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][selected_cat_id_extra][]" id="selected_cat_id_extra" class="wps_wafc_multiselect" multiple="multiple"> 173 <?php 174 $args = array( 175 'taxonomy' => 'product_cat', 176 'orderby' => 'name', 177 'order' => 'ASC', 178 'hide_empty' => false 179 ); 180 $categories = get_categories( $args ); 181 if ( $categories ) { 182 foreach( $categories as $category ) :?> 183 <option value="<?php echo $category->term_id; ?>"> 184 <?php echo $category->name.' ('.$category->count.')'; ?> 185 </option> 186 <?php 187 endforeach; 188 } else { 189 echo '<option>No category found</option>'; 190 } 191 ?> 192 </select> 193 </td> 194 </tr> 195 <tr id="selected_pr_type<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 196 <th scope="row"><label><?php _e( 'Selected Product Type'); ?><label></th> 197 <td> 198 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][selected_pr_type_extra][]" id="selected_pr_type_extra" class="wps_wafc_multiselect" multiple="multiple"> 199 <?php 200 $pr_types = array('simple','grouped','variable','external_affiliate'); 201 foreach ( $pr_types as $types ) :?> 202 <option value="<?php echo $types; ?>"><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 203 <?php 204 endforeach; 205 ?> 206 </select> 207 </td> 208 </tr> 128 209 129 <tr> 210 130 <th scope="row"> … … 217 137 <option value="yes">Yes</option> 218 138 </select> 139 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 219 140 </td> 220 141 </tr> … … 229 150 <option value="yes">Yes</option> 230 151 </select> 152 <p class="wps-feat-prem">Available with <a href='https://www.wpsuperiors.com/additional-fees-for-woocommerce-checkout/'>Premium Version.</a></p> 231 153 </td> 232 154 </tr> -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-extra-fees-frontend.php
r3388342 r3418398 12 12 add_action( 'wp_footer', array($this,'add_extra_script_on_checkout_page' )); 13 13 add_action( 'woocommerce_cart_calculate_fees', array($this,'calculate_extra_costs' )); 14 add_action('woocommerce_checkout_process', array($this,'check_required_fees_extra'));15 14 break; 16 15 } … … 34 33 break; 35 34 36 case 'cart_total_amount':37 $cart_total = $woocommerce->cart->cart_contents_total;38 $cart_total_amount_min = ($extra_rule['cart_total_amount_min_extra']) ? $extra_rule['cart_total_amount_min_extra'] : 1;39 $cart_total_amount_max = ($extra_rule['cart_total_amount_max_extra']) ? $extra_rule['cart_total_amount_max_extra'] : 1;40 41 if($cart_total_amount_max>=0 && $cart_total_amount_min>=0){42 if ($cart_total_amount_max >= $cart_total && $cart_total_amount_min <= $cart_total ) {43 44 return true;45 }46 else{47 return false;48 }49 }50 51 break;52 53 case 'cart_no_product':54 $cart_total_product = WC()->cart->get_cart_contents_count();55 $cart_no_product_min = ($extra_rule['cart_no_product_min_extra']) ? $extra_rule['cart_no_product_min_extra'] : 1;56 $cart_no_product_max = ($extra_rule['cart_no_product_max_extra']) ? $extra_rule['cart_no_product_max_extra'] : 1;57 58 if($cart_no_product_max>=0 && $cart_no_product_min>=0){59 if ($cart_no_product_max >= $cart_total_product && $cart_no_product_min <= $cart_total_product ) {60 61 return true;62 }63 else{64 return false;65 }66 }67 68 69 break;70 71 case 'selected_product':72 $selected_product_id = ($extra_rule['selected_product_id_extra']) ? array_map('intval',$extra_rule['selected_product_id_extra']) : array();73 if(array_intersect($selected_product_id, $products_ids_array)){74 return true;75 }76 else{77 return false;78 }79 break;80 81 case 'selected_category':82 $selected_cat_ids = ($extra_rule['selected_cat_id_extra']) ? array_map('intval',$extra_rule['selected_cat_id_extra']) : array();83 $cat_ids = array();84 foreach ( wc()->cart->get_cart() as $cart_item_key => $cart_item ) {85 $cat_ids = array_merge(86 $cat_ids, $cart_item['data']->get_category_ids()87 );88 }89 90 if(array_intersect($selected_cat_ids, $cat_ids)){91 return true;92 }93 else{94 return false;95 }96 break;97 98 case 'selected_pr_type':99 $selected_pr_type_extra = isset($extra_rule['selected_pr_type_extra']) ? $extra_rule['selected_pr_type_extra'] : array();100 $types = array();101 foreach ( wc()->cart->get_cart() as $cart_item_key => $cart_item ) {102 array_push(103 $types, $cart_item['data']->get_type()104 );105 }106 107 if(array_intersect($selected_pr_type_extra, $types)){108 return true;109 }110 else{111 return false;112 }113 break;114 35 115 36 default: … … 137 58 </script> 138 59 <?php 139 if( $auto_checked == 'enable' ){ 140 ?> 141 <script type="text/javascript">jQuery('#<?php echo $key; ?>').trigger('click');</script> 142 <?php 143 } 60 144 61 } 145 62 … … 157 74 158 75 if( $status == 'enable' && !is_admin() && $get_cndtn){ 159 $is_required_extra = ($value['ext_cst_is_required_extra']=='yes') ? true : false;160 76 $key = 'wps_ext_cst_label_extra_'.$option; 161 77 $field_id = 'wps_ext_cst_extra_field_'.$option; 162 78 $label = $value['label'] ? $value['label'] : 'Unlabelled Fees'; 163 $hide_on_frontend = $value['hide_on_frontend'] ? $value['hide_on_frontend'] : 'no'; 164 165 if($hide_on_frontend == 'no' ){ 166 $wps_exts_custom_cls = 'wps_show_me'; 167 }else{ 168 $wps_exts_custom_cls = 'wps_hide_me'; 169 } 79 170 80 $extra_final_cost = WPS_EXT_CST_Extra_Fees_Frontend::calculate_final_cost_extra($value); 171 81 172 echo '<div id="'.$field_id.'" class="'.$wps_exts_custom_cls.'">';82 echo '<div id="'.$field_id.'">'; 173 83 woocommerce_form_field( $key, array( 174 84 'type' => 'checkbox', 175 85 'class' => array('wps_ext_cst_label_extra_option form-row-wide'), 176 86 'label' => $label, 177 'required' => $is_required_extra,178 87 'placeholder' => __('') 179 88 ), $checkout->get_value( $key )); … … 186 95 public static function calculate_final_cost_extra( $fees ){ 187 96 global $woocommerce; 188 $products_ids_array = array(); 189 $items = $woocommerce->cart->get_cart(); 190 foreach( $items as $item => $values ){ 191 $products_ids_array[] = $values['product_id']; 192 } 97 193 98 $ext_ext_cst_amount_type = (isset($fees['amount_type'])) ? $fees['amount_type'] : 'fixed'; 194 99 $ext_ext_cst_amount = (isset($fees['amount'])) ? $fees['amount'] : 1; 195 $ext_ext_cst_apply_cndtn = (isset($fees['apply_cndtn'])) ? $fees['apply_cndtn'] : 'all'; 196 $selected_product_id = (isset($fees['selected_product_id_extra'])) ? $fees['selected_product_id_extra'] : 0; 197 $apply_type = (isset($fees['apply_type'])) ? $fees['apply_type'] : 'one_time'; 198 $quantity = 0; 199 if( $apply_type == 'multiply' ){ 200 if( $ext_ext_cst_apply_cndtn == 'selected_product' ){ 201 202 foreach ( WC()->cart->get_cart() as $cart_item ) { 203 if( in_array($cart_item['product_id'], $selected_product_id )){ 204 $quantity = $cart_item['quantity'] + $quantity; 205 } 206 } 207 }else{ 208 foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { 209 $quantity = $cart_item['quantity'] + $quantity; 210 } 211 } 212 $cost = $ext_ext_cst_amount * $quantity; 213 }else{ 214 $cost = $ext_ext_cst_amount; 215 } 100 $ext_ext_cst_apply_cndtn = 'all'; 101 102 $cost = $ext_ext_cst_amount; 216 103 217 104 switch ($ext_ext_cst_amount_type) { -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-frontend.php
r3388342 r3418398 9 9 add_action( 'wp_footer', array($this,'add_script_on_checkout' )); 10 10 add_action( 'woocommerce_cart_calculate_fees', array($this,'apply_the_cost_to_cart' )); 11 add_action('woocommerce_checkout_process', array($this,'check_required_fees'));12 11 13 12 … … 27 26 break; 28 27 29 case 'cart_total_amount':30 $cart_total = $woocommerce->cart->cart_contents_total;31 $cart_total_amount_min = (get_option('cart_total_amount_min')) ? get_option('cart_total_amount_min') : 1;32 $cart_total_amount_max = (get_option('cart_total_amount_max')) ? get_option('cart_total_amount_max') : 1;33 if($cart_total_amount_max>=0 && $cart_total_amount_min>=0){34 35 if ($cart_total_amount_max >= $cart_total && $cart_total_amount_min <= $cart_total ) {36 return true;37 38 }39 else{40 return false;41 }42 }43 break;44 45 case 'cart_no_product':46 $cart_total_product = WC()->cart->get_cart_contents_count();47 $cart_no_product_min = (get_option('cart_no_product_min')) ? get_option('cart_no_product_min') : 1;48 $cart_no_product_max = (get_option('cart_no_product_max')) ? get_option('cart_no_product_max') : 1;49 50 if($cart_no_product_max>=0 && $cart_no_product_min>=0){51 if ($cart_no_product_max >= $cart_total_product && $cart_no_product_min <= $cart_total_product ) {52 53 return true;54 }55 else{56 return false;57 }58 }59 break;60 61 case 'selected_product':62 $selected_product_id = (get_option('selected_product_id')) ? get_option('selected_product_id') : 0;63 if(array_intersect($selected_product_id, $products_ids_array)){64 return true;65 }66 else{67 return false;68 }69 break;70 71 case 'selected_category':72 $selected_cat_id = (get_option('selected_cat_id')) ? get_option('selected_cat_id') : array();73 $cat_ids = array();74 foreach ( wc()->cart->get_cart() as $cart_item_key => $cart_item ) {75 $cat_ids = array_merge(76 $cat_ids, $cart_item['data']->get_category_ids()77 );78 }79 if(array_intersect($selected_cat_id, $cat_ids)){80 return true;81 }82 else{83 return false;84 }85 break;86 87 case 'selected_category':88 $selected_cat_id = (get_option('selected_cat_id')) ? get_option('selected_cat_id') : array();89 $cat_ids = array();90 foreach ( wc()->cart->get_cart() as $cart_item_key => $cart_item ) {91 $cat_ids = array_merge(92 $cat_ids, $cart_item['data']->get_category_ids()93 );94 }95 if(array_intersect($selected_cat_id, $cat_ids)){96 return true;97 }98 else{99 return false;100 }101 break;102 103 case 'selected_pr_type':104 $selected_pr_type = (get_option('selected_pr_type')) ? get_option('selected_pr_type') : array();105 $types = array();106 foreach ( wc()->cart->get_cart() as $cart_item_key => $cart_item ) {107 array_push(108 $types, $cart_item['data']->get_type()109 );110 }111 112 if(array_intersect($selected_pr_type, $types)){113 return true;114 }115 else{116 return false;117 }118 break;119 120 121 28 default: 122 29 return true; … … 129 36 130 37 131 $ext_cst_apply_cndtn = (get_option('ext_cst_apply_cndtn')) ? get_option('ext_cst_apply_cndtn') :'all';38 $ext_cst_apply_cndtn = 'all'; 132 39 133 40 $get_cndtn = WPS_EXT_CST_Frontend::get_condition($ext_cst_apply_cndtn); 134 41 135 42 if($get_cndtn){ 136 $is_required = (get_option('ext_cst_is_required')=='yes') ? true : false;137 43 $ext_cst_label = (get_option('ext_cst_label')) ? get_option('ext_cst_label') : 'Unlabelled Fees'; 138 44 139 45 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 140 46 $ext_cst_amount = (get_option('ext_cst_amount')) ? get_option('ext_cst_amount') : 1; 141 $ext_cst_hide_option = (get_option('ext_cst_hide_option')) ? get_option('ext_cst_hide_option') : 'no';142 47 143 $ext_cst_apply_type = (get_option('ext_cst_apply_type')) ? get_option('ext_cst_apply_type') : 'multiply';144 48 145 if($ext_cst_hide_option == 'no' ){ 146 $wps_custom_cls = 'wps_show_me'; 147 }else{ 148 $wps_custom_cls = 'wps_hide_me'; 149 } 150 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_apply_cndtn, $ext_cst_amount,$ext_cst_amount_type,$ext_cst_apply_type); 49 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_amount,$ext_cst_amount_type); 151 50 152 echo '<div id="wp_ext_cst_field" class ="'.$wps_custom_cls.'">';51 echo '<div id="wp_ext_cst_field">'; 153 52 woocommerce_form_field( 'wps_ext_cst_label', array( 154 53 'type' => 'checkbox', 155 54 'class' => array('wps_ext_cst_label form-row-wide'), 156 55 'label' => $ext_cst_label, 157 'required' => $is_required,158 56 'value' => 158, 159 57 'placeholder' => __('') … … 165 63 } 166 64 167 public static function calculate_final_cost( $cndtn, $amount, $type, $apply_type ){ 168 global $woocommerce; 169 $products_ids_array = array(); 170 $items = $woocommerce->cart->get_cart(); 171 foreach( $items as $item => $values ){ 172 $products_ids_array[] = $values['product_id']; 173 } 174 $quantity = 0; 175 if( $apply_type == 'multiply' ){ 176 if( $cndtn == 'selected_product' ){ 177 $selected_product_id = (get_option('selected_product_id')) ? get_option('selected_product_id') : 0; 178 179 foreach ( WC()->cart->get_cart() as $cart_item ) { 180 if( in_array($cart_item['product_id'], $selected_product_id )){ 181 $quantity = $cart_item['quantity'] + $quantity; 182 } 183 } 184 }else{ 185 foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { 186 $quantity = $cart_item['quantity'] + $quantity; 187 } 188 } 189 190 $cost = $amount * $quantity; 191 }else{ 192 $cost = $amount; 193 } 65 public static function calculate_final_cost($amount, $type){ 66 67 $cost = $amount; 194 68 195 69 switch ($type) { … … 224 98 } 225 99 226 public static function check_required_fees(){ 227 $ext_cst_label = (get_option('ext_cst_label')) ? get_option('ext_cst_label') : 'Unlabelled Fees'; 228 $is_required = (get_option('ext_cst_is_required')=='yes') ? true : false; 229 $ext_cst_apply_cndtn = (get_option('ext_cst_apply_cndtn')) ? get_option('ext_cst_apply_cndtn') : 'all'; 230 $get_cndtn = WPS_EXT_CST_Frontend::get_condition($ext_cst_apply_cndtn); 231 if($is_required && $get_cndtn){ 232 if ( ! $_POST['wps_ext_cst_label'] ){ 233 wc_add_notice( __( '<b>'.$ext_cst_label.'</b> is a required field.' ), 'error' ); 234 } 235 } 236 } 237 100 238 101 public static function add_script_on_checkout(){ 239 102 if (is_checkout()) { … … 254 117 <?php 255 118 } 256 if( $ext_cst_auto_checked == 'enable' ){ 257 ?> 258 <script type="text/javascript">jQuery('#wps_ext_cst_label').trigger('click');</script> 259 <?php 260 } 119 261 120 } 262 121 … … 273 132 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 274 133 $ext_cst_amount = (get_option('ext_cst_amount')) ? get_option('ext_cst_amount') : 1; 275 $ext_cst_apply_type = (get_option('ext_cst_apply_type')) ? get_option('ext_cst_apply_type') : 'one_time'; 276 $ext_cst_apply_cndtn = (get_option('ext_cst_apply_cndtn')) ? get_option('ext_cst_apply_cndtn') : 'all'; 134 $ext_cst_apply_cndtn = 'all'; 277 135 278 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_a pply_cndtn,$ext_cst_amount,$ext_cst_amount_type,$ext_cst_apply_type);136 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_amount,$ext_cst_amount_type); 279 137 280 138 $get_cndtn = WPS_EXT_CST_Frontend::get_condition($ext_cst_apply_cndtn); -
woo-additional-fees-on-checkout-wordpress/trunk/readme.txt
r3388710 r3418398 1 === Additional Fees For WooCommerce Checkout (Free)===1 === Additional Fees For WooCommerce Checkout === 2 2 Contributors: WPSuperiors, amitwpdeveloper 3 3 Tags: woocommerce extra cost, woocommerce additional cost, woocommerce checkout cost, woocommerce surcharge. 4 4 Requires at least: 3.0.1 5 5 Tested up to: 6.7 6 Stable tag: 1.5. 16 Stable tag: 1.5.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 122 122 123 123 == Changelog == 124 = 1.5.2 - 12th Dec, 2025 = 125 *Compatibility support with codebase upgrade* 126 124 127 = 1.5.1 - 02nd Nov, 2025 = 125 128 *WooCommerce Block Checkout support*
Note: See TracChangeset
for help on using the changeset viewer.