Changeset 3388342
- Timestamp:
- 11/02/2025 11:42:23 AM (5 months ago)
- Location:
- woo-additional-fees-on-checkout-wordpress/trunk
- Files:
-
- 8 edited
-
assets/css/admin-style.css (modified) (5 diffs)
-
assets/js/wps-ext-cst.js (modified) (2 diffs)
-
classes/wps-ext-cst-admin-settings.php (modified) (32 diffs)
-
classes/wps-ext-cst-admin.php (modified) (15 diffs)
-
classes/wps-ext-cst-extra-fees-frontend.php (modified) (8 diffs)
-
classes/wps-ext-cst-frontend.php (modified) (7 diffs)
-
classes/wps-ext-cst-main.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-additional-fees-on-checkout-wordpress/trunk/assets/css/admin-style.css
r3232191 r3388342 3 3 font-family: raleway; 4 4 } 5 .wps-afoc-main-wrap p{6 font-family: raleway;7 }8 .wps-afoc-main-wrap p a{9 text-decoration: none;10 }11 5 .wps-afoc-main-wrap p, .select2-selection__choice__display, .wps_wafc_multiselect, .select2-results__option--selectable, .select2-search__field{ 12 font-family: raleway !important;6 font-family: raleway !important; 13 7 } 14 8 .select2-container--default{ … … 16 10 } 17 11 .wps-afoc-main-wrap p a{ 18 text-decoration: none;12 text-decoration: none; 19 13 } 20 14 .wps-afoc-main-wrap .error{ … … 30 24 31 25 .wps-afoc-main-wrap .wps-ext-cst-fees h3{ 32 width: 97%;26 width: 100%; 33 27 border-bottom: 1px solid #DDD; 34 28 font-family: raleway; … … 65 59 .wps-afoc-main-wrap{ 66 60 background: white; 61 display: inline-block; 67 62 padding: 15px; 63 margin: 15px; 68 64 position:relative; 69 65 width: 70%; … … 162 158 width: 99% !important; 163 159 } 160 .wps-afoc-main-wrap .form-table td{ 161 width: 100%; 162 } 163 .wps-afoc-main-wrap .form-table td p{ 164 font-size: 12px; 165 font-style: italic; 166 display: inline-block; 167 } 168 .wps-feat-not{ 169 170 font-size: 10px; 171 font-weight: 600; 172 color: #e7000087; 173 174 } -
woo-additional-fees-on-checkout-wordpress/trunk/assets/js/wps-ext-cst.js
r2891885 r3388342 8 8 var id = $('#ext_cst_apply_cndtn').val(); 9 9 $("#"+id).show(); 10 10 11 } 11 12 function show_hide_cndtn_extra(s_id){ 12 13 $(".cndtn_mode_extra"+s_id).hide(); 14 13 15 var id = $('#ext_cst_apply_cndtn_extra'+s_id).val(); 14 16 $("#"+id+s_id).show(); 15 17 } 16 18 function remove_fees( id ){ 19 console.log(id) 17 20 var numberCount = $('#current_number_fees').val(); 18 21 var r = confirm("Are you want to delete?"); … … 66 69 var data_id = $(this).attr("data-id"); 67 70 $("input[type='number']").css('border','1px solid #DDD'); 68 69 71 //console.log(data_id); 70 72 if( data_id == 1 ){ -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-admin-settings.php
r3232191 r3388342 3 3 { 4 4 public static function register_admin_settings(){ 5 add_settings_section("wps-ext-cst-option-section", "Additional Fees Settings <p class='error'>You are using Basic, Free version, get the Premium, Exclusive version @ <b>19 USD</b> only, for limited time.</p>", null, "wps-ext-cst-options");5 add_settings_section("wps-ext-cst-option-section", "Additional Fees Settings", null, "wps-ext-cst-options"); 6 6 7 7 register_setting("wps-ext-cst-option-section", "ext_cst_status"); … … 17 17 register_setting("wps-ext-cst-option-section", "cart_no_product_max"); 18 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"); 19 21 register_setting("wps-ext-cst-option-section", "ext_cst_is_required"); 20 22 register_setting("wps-ext-cst-option-section", "ext_cst_label_css"); 21 23 register_setting("wps-ext-cst-option-section", "ext_cst_inc_ship_costs"); 22 24 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"); 23 27 24 28 … … 33 37 <div class="wps-afoc-main-wrap"> 34 38 <form method="post" action="options.php"> 39 35 40 <?php 41 36 42 settings_fields("wps-ext-cst-option-section"); 37 43 do_settings_sections("wps-ext-cst-options"); … … 42 48 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 43 49 $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'; 44 61 $ext_cst_label_css = (get_option('ext_cst_label_css')) ? get_option('ext_cst_label_css') : ''; 62 $ext_cst_inc_ship_costs = (get_option('ext_cst_inc_ship_costs')) ? get_option('ext_cst_inc_ship_costs') : 'no'; 63 $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 45 67 $extra_options = get_option('ext_cst_extra'); 46 68 ?> 47 <p>Before you start, please check <a href="https://www.wpsuperiors.com/woo-additional-fees-on-checkout/" target="_blank"><i>User Guide</i></a>. Have Fun :)</p>69 <p>Before start, let's take a look at <a href="https://www.wpsuperiors.com/woo-additional-fees-on-checkout/" target="_blank">The Documentation Page</a>. </p> 48 70 <?php settings_errors(); ?> 49 <table class="form-table" style="width: 63%; margin-left: auto; margin-right: auto;">71 <table class="form-table" style="width: 50%; margin-left: auto; margin-right: auto;"> 50 72 <tbody> 51 73 <tr> … … 83 105 <td> 84 106 <select name="ext_cst_inc_tax" id="ext_cst_inc_tax"> 85 <option>Yes</option> 86 <option>No</option> 87 </select> 88 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 107 <option value="yes" <?php if($ext_cst_inc_tax=='yes'){echo 'selected';} ?>>Yes</option> 108 <option value="no" <?php if($ext_cst_inc_tax=='no'){echo 'selected';} ?>>No</option> 109 </select> 89 110 </td> 90 111 </tr> … … 93 114 <td> 94 115 <select name="ext_cst_inc_ship_costs" id="ext_cst_inc_ship_costs"> 95 <option value="yes">Yes</option> 96 <option value="no">No</option> 97 </select> 98 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 116 <option value="yes" <?php if($ext_cst_inc_ship_costs=='yes'){echo 'selected';} ?>>Yes</option> 117 <option value="no" <?php if($ext_cst_inc_ship_costs=='no'){echo 'selected';} ?>>No</option> 118 </select> 99 119 </td> 100 120 </tr> … … 108 128 <th scope="row"><label><?php _e( 'Apply Condition'); ?></label></th> 109 129 <td> 110 <select data-id="1" class="ext_cst_cndtn_dropdown"> 111 <option value="one_time">One Time Only</option> 112 <option value="multiply">Multiplied By Product Quantity</option> 113 </select> 114 <p style="font-size:12px; font-style: italic;">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> 115 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 116 </td> 117 </tr> 118 <tr> 119 <th scope="row"><label><?php _e( 'Auto-checked/Auto-applied the fees'); ?></label></th> 130 <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> 133 </select> 134 <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> 135 </td> 136 </tr> 137 <tr> 138 <th scope="row"> 139 <label><?php _e( 'Auto-checked/Auto-applied the fees'); ?></label> 140 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 141 </th> 120 142 <td> 121 143 <select name="ext_cst_auto_checked" id="ext_cst_auto_checked"> 122 <option value="enable">Enable</option> 123 <option value="disable">Disable</option> 124 </select> 125 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 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> 126 147 </td> 127 148 </tr> … … 130 151 <td> 131 152 <select data-id="1" class="ext_cst_cndtn_dropdown" name="ext_cst_apply_cndtn" id="ext_cst_apply_cndtn" onchange="show_hide_cndtn()"> 132 <option >All</option>133 <option value="cart_total_amount" >Cart Total Amount</option>134 <option value="cart_no_product" >Number of Product on Cart</option>135 <option value="selected_product" >Selected Product</option>136 <option value="selected_category" >Selected Category</option>137 <option value="selected_pr_type" >Selected Product Type</option>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> 138 159 </select> 139 160 </td> … … 147 168 <label>Maximum</label> 148 169 <input type="number" name="cart_total_amount_max" class="small-text" id="cart_total_amount_max" value="<?php echo $cart_total_amount_max; ?>"/> 149 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>150 170 </td> 151 171 </tr> … … 158 178 <label>Maximum</label> 159 179 <input type="number" name="cart_no_product_max" class="small-text" id="cart_no_product_max" value="<?php echo $cart_no_product_max; ?>"/> 160 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>161 180 </td> 162 181 </tr> … … 166 185 <select name="selected_product_id[]" id="selected_product_id" multiple="multiple" class="wps_wafc_multiselect"> 167 186 <?php 187 $selected_product_id = (is_array($selected_product_id)) ? $selected_product_id : array($selected_product_id); 168 188 $args = array( 169 189 'post_type' => 'product', … … 173 193 if ( $loop->have_posts() ) { 174 194 while ( $loop->have_posts() ) : $loop->the_post();?> 175 <option ><?php echo get_the_title(); ?></option>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> 176 196 <?php 177 197 endwhile; … … 182 202 ?> 183 203 </select> 184 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>185 204 </td> 186 205 </tr> … … 199 218 if ( $categories ) { 200 219 foreach( $categories as $category ) :?> 201 <option ><?php echo $category->name.' ('.$category->count.')'; ?></option>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> 202 221 <?php 203 222 endforeach; … … 207 226 ?> 208 227 </select> 209 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>210 228 </td> 211 229 </tr> … … 217 235 $pr_types = array('simple','grouped','variable','external_affiliate'); 218 236 foreach ( $pr_types as $types ) :?> 219 <option ><?php echo str_replace("_"," / ",ucwords($types)); ?></option>237 <option value="<?php echo $types; ?>" <?php if(in_array($types,$selected_pr_type)){echo 'selected';} ?>><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 220 238 <?php 221 239 endforeach; 222 240 ?> 223 241 </select> 224 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 225 </td> 226 </tr> 227 <tr> 228 <th scope="row"><label><?php _e( 'Required Field'); ?></label></th> 242 </td> 243 </tr> 244 245 <tr> 246 <th scope="row"> 247 <label><?php _e( 'Required Field'); ?></label> 248 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 249 </th> 229 250 <td> 230 251 <select name="ext_cst_is_required" id="ext_cst_is_required"> 231 <option value="no">No</option> 232 <option value="yes">Yes</option> 233 </select> 234 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 235 </td> 236 </tr> 237 <tr> 238 <th scope="row"><label><?php _e( 'Hide Option At Checkout'); ?></label></th> 239 <td> 240 <select> 241 <option value="no">No</option> 242 <option value="yes">Yes</option> 243 </select> 244 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 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> 255 </td> 256 </tr> 257 <tr> 258 <th scope="row"> 259 <label><?php _e( 'Hide Option At Checkout'); ?></label> 260 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 261 </th> 262 <td> 263 <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> 245 267 </td> 246 268 </tr> … … 251 273 </td> 252 274 </tr> 275 253 276 </tbody> 254 277 </table> 255 <div id="wps_custom_fees_add_more" style="width: 64%; margin-left: auto; margin-right: auto;">278 <div id="wps_custom_fees_add_more" style="width: 50%; margin-left: auto; margin-right: auto;"> 256 279 <?php 257 280 … … 260 283 261 284 foreach ($extra_options as $option => $value) { 285 $selected_cat_id_extra = isset($value['selected_cat_id_extra']) ? $value['selected_cat_id_extra'] : array(); 286 $selected_product_id_extra = isset($value['selected_product_id_extra']) ? $value['selected_product_id_extra'] : array(); 287 $selected_pr_type_extra = isset($value['selected_pr_type_extra']) ? $value['selected_pr_type_extra'] : array(); 288 //echo '<pre>'; print_r($value['selected_product_id_extra']); echo "</pre>"; 262 289 ?> 263 290 <div class="wps-ext-cst-fees" id="fees<?php echo $option; ?>"> … … 301 328 <th scope="row"><label><?php _e( 'Calculate fees including TAX'); ?></label></th> 302 329 <td> 303 <select> 304 <option value="yes">Yes</option> 305 <option value="no">No</option> 306 </select> 307 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 330 <select name="ext_cst_extra[<?php echo $option; ?>][inc_tax]" id="ext_cst_inc_tax_extra"> 331 <option value="yes" <?php if(isset($value['inc_tax']) && $value['inc_tax']=='yes'){echo 'selected';} ?>>Yes</option> 332 <option value="no" <?php if(isset($value['inc_tax']) && $value['inc_tax']=='no'){echo 'selected';} ?>>No</option> 333 </select> 308 334 </td> 309 335 </tr> … … 311 337 <th scope="row"><label><?php _e( 'Calculate fees including Shipping Costs'); ?></label></th> 312 338 <td> 313 <select> 314 <option value="yes">Yes</option> 315 <option value="no">No</option> 316 </select> 317 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 339 <select name="ext_cst_extra[<?php echo $option; ?>][inc_ship_costs]" id="ext_cst_inc_ship_costs_extra"> 340 <option value="yes" <?php if(isset($value['inc_ship_costs']) && $value['inc_ship_costs']=='yes'){echo 'selected';} ?>>Yes</option> 341 <option value="no" <?php if(isset($value['inc_ship_costs']) && $value['inc_ship_costs']=='no'){echo 'selected';} ?>>No</option> 342 </select> 318 343 </td> 319 344 </tr> … … 328 353 <td> 329 354 <select name="ext_cst_extra[<?php echo $option; ?>][apply_type]" id="ext_cst_apply_type<?php echo $option; ?>"> 330 <option >One Time Only</option>331 <option >Multiplied By Product Quantity</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> 332 357 </select> 333 358 <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> 334 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 335 </td> 336 </tr> 337 <tr> 338 <th scope="row"><label><?php _e( 'Auto-checked/Auto-applied the fees'); ?><label></th> 339 <td> 340 <select> 341 <option value="enable">Enable</option> 342 <option value="disable">Disable</option> 343 </select> 344 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 359 </td> 360 </tr> 361 <tr> 362 <th scope="row"> 363 <label><?php _e( 'Auto-checked/Auto-applied the fees'); ?><label> 364 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 365 </th> 366 <td> 367 <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> 345 371 </td> 346 372 </tr> … … 348 374 <th scope="row"><label><?php _e( 'Condition'); ?><label></th> 349 375 <td> 350 <select name="ext_cst_extra[<?php echo $option; ?>][apply_cndtn]" id="ext_cst_apply_cndtn_extra<?php echo $option; ?>" class="ext_cst_cndtn_dropdown" onchange="show_hide_cndtn_extra(<?php echo $option; ?>)"> 351 <option value="all">All</option> 352 <option value="cart_total_amount">Cart Total Amount</option> 353 <option value="cart_no_product">Number of Product on Cart</option> 354 <option value="selected_product">Selected Product</option> 355 <option value="selected_category">Selected Category</option> 356 <option value="selected_pr_type">Selected Product Type</option> 357 </select> 358 376 <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> 359 384 </td> 360 385 </tr> … … 363 388 <td> 364 389 <label>Minimum</label> 365 <input type="number" class="small-text"/>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']; ?>"/> 366 391 367 392 <label>Maximum</label> 368 <input type="number" class="small-text" /> 369 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 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']; ?>"/> 370 394 </td> 371 395 </tr> … … 374 398 <td> 375 399 <label>Minimum</label> 376 <input type="number" class="small-text"/>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']; ?>"/> 377 401 378 402 <label>Maximum</label> 379 <input type="number" class="small-text" value=""/> 380 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 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']; ?>"/> 381 404 </td> 382 405 </tr> … … 393 416 if ( $loop->have_posts() ) { 394 417 while ( $loop->have_posts() ) : $loop->the_post();?> 395 <option value="<?php echo get_the_ID(); ?>"><?php echo get_the_title(); ?></option>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> 396 419 <?php 397 420 endwhile; … … 402 425 ?> 403 426 </select> 404 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>405 427 </td> 406 428 </tr> … … 419 441 if ( $categories ) { 420 442 foreach( $categories as $category ) :?> 421 <option value="<?php echo $category->term_id; ?>" ><?php echo $category->name.' ('.$category->count.')'; ?></option>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> 422 444 <?php 423 445 endforeach; … … 426 448 } 427 449 ?> 428 </select> 429 < p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>450 451 </select> 430 452 </td> 431 453 </tr> … … 437 459 $pr_types = array('simple','grouped','variable','external_affiliate'); 438 460 foreach ( $pr_types as $types ) :?> 439 <option value="<?php echo $types; ?>" ><?php echo str_replace("_"," / ",ucwords($types)); ?></option>461 <option value="<?php echo $types; ?>" <?php if(in_array($types,$selected_pr_type_extra)){echo 'selected';} ?>><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 440 462 <?php 441 463 endforeach; 442 464 ?> 443 465 </select> 444 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 445 </td> 446 </tr> 447 <tr> 448 <th scope="row"><label><?php _e( 'Required Field'); ?></labe></td> 449 <td> 450 <select> 451 <option value="no">No</option> 452 <option value="yes">Yes</option> 453 </select> 454 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 455 </td> 456 </tr> 457 <tr> 458 <th scope="row"><label><?php _e( 'Hide Option At Checkout'); ?></label></th> 459 <td> 460 <select> 461 <option value="no">No</option> 462 <option value="yes">Yes</option> 463 </select> 464 <p class="error">Available with premium version @ <b>19 USD only</b>, for limited time.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 466 </td> 467 </tr> 468 <tr> 469 <th scope="row"> 470 <label><?php _e( 'Required Field'); ?></labe> 471 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 472 </th> 473 <td> 474 <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> 478 </td> 479 </tr> 480 <tr> 481 <th scope="row"> 482 <label><?php _e( 'Hide Option At Checkout'); ?></label> 483 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 484 </th> 485 <td> 486 <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> 465 490 </td> 466 491 </tr> … … 472 497 function show_hide_cndtn_extra(s_id){ 473 498 jQuery(".cndtn_mode_extra"+s_id).hide(); 499 474 500 var id = jQuery('#ext_cst_apply_cndtn_extra'+s_id).val(); 475 501 jQuery("#"+id+s_id).show(); … … 483 509 jQuery('#incShipCosts-<?php echo $option; ?>').hide(); 484 510 } 511 485 512 486 513 </script> … … 528 555 } 529 556 </script> 530 531 <p style="width:100%; float:left; display:inline-block; margin-top:30px; font-size:12px;">After activate this plugin checkout page design looks bad? Send a scrrenshot and checkout URL at <a style="text-decoration:none;" href="mailto:[email protected]">[email protected]</a>, it will be solved for sure. 532 <p style="margin-top:30px; font-size:12px;">Still Confused? Need our help? Feel free to write on us <a style="text-decoration:none;" href="mailto:[email protected]">[email protected]</a> OR visit <a style="text-decoration:none;" href="http://www.wpsuperiors.com/contact-us/" target="_blank">Contact Us</a></p> 557 <p style="margin-top:30px; font-size:12px;">For any query, feel free to write on us <a style="text-decoration:none;" href="mailto:[email protected]">[email protected]</a> OR visit <a style="text-decoration:none;" href="http://www.wpsuperiors.com/contact-us/" target="_blank">Contact Us</a></p> 533 558 <p>Like this plugin? Leave 534 559 <span style="font-size:200%;color:yellow;">★</span> -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-admin.php
r3232191 r3388342 1 1 <?php 2 3 2 class WPS_EXT_CST_Admin 4 3 { … … 6 5 { 7 6 add_action( 'wp_ajax_wps_generate_new_fees', array($this,'wps_generate_new_fees' )); 8 add_action( 'admin_notices', array($this,'show_premium_buy_notice' )); 9 add_action( 'admin_init', array($this,'show_premium_buy_notice_dismissed' )); 10 } 11 public function show_premium_buy_notice() { 12 $user_id = get_current_user_id(); 13 if ( !get_user_meta( $user_id, 'wps_premium_buy_notice' ) ){ 14 echo '<div class="notice notice-success is-dismissible" style="display:flex;"> 15 <img src="https://wpsuperiors-media.s3.amazonaws.com/wp-content/uploads/2025/01/30163651/limited.png" /> 16 <span style="padding-top:4%; font-size:20px;">WooCommerce Additional Fees On Checkout PREMIUM plugin at <b style="font-weight:700;">19 USD</b> only. 17 <a class="button button-primary" href="?wps-dismissed" style="margin-top:-5px;">Click To Grab</a></span> 18 </div>'; 19 } 20 } 21 22 public function show_premium_buy_notice_dismissed() { 23 $user_id = get_current_user_id(); 24 if ( isset( $_GET['wps-dismissed'] ) ){ 25 add_user_meta( $user_id, 'wps_premium_buy_notice', 'true', true ); 26 wp_redirect( "https://www.wpsuperiors.com/shop/woo-additional-fees-on-checkout/", 301 ); 27 exit(); 28 } 29 } 30 7 } 31 8 public static function init(){ 32 9 add_action( 'admin_menu', array( 'WPS_EXT_CST_Admin', 'add_menu_extra_fee_option' ) ); … … 40 17 } 41 18 public static function selectively_enqueue_admin_script(){ 19 42 20 wp_register_style( 'WPS_EXT_CST_SELECT2_ADMIN_CSS', WPS_EXT_CST_CSS . '/wafc-select2.min.css', false, '1.0.0' ); 43 21 wp_enqueue_style( 'WPS_EXT_CST_SELECT2_ADMIN_CSS' ); 44 22 45 23 wp_register_style( 'WPS_EXT_CST_ADMIN_CSS', WPS_EXT_CST_CSS . '/admin-style.css', false, '1.0.0' ); 46 24 wp_enqueue_style( 'WPS_EXT_CST_ADMIN_CSS' ); 47 25 } 48 26 public static function wps_generate_new_fees(){ 49 $fees_number = (int)$_POST['number'];50 27 ?> 51 28 52 <div class="wps-ext-cst-fees" id="fees<?php echo $ fees_number;?>">29 <div class="wps-ext-cst-fees" id="fees<?php echo $_POST['number'];?>"> 53 30 <h3 style="border-bottom: 1px solid black;"> 54 31 <span class="fees-title">Unlabelled Fees</span> 55 <span style="float:right; color:red; cursor: pointer;" class="dashicons dashicons-trash" onclick="remove_fees(<?php echo $ fees_number;?>)"></span>32 <span style="float:right; color:red; cursor: pointer;" class="dashicons dashicons-trash" onclick="remove_fees(<?php echo $_POST['number'];?>)"></span> 56 33 </h3> 57 34 <table class="form-table"> … … 60 37 <th scope="row"><label><?php _e( 'Status'); ?><label></th> 61 38 <td> 62 <select name="ext_cst_extra[<?php echo $ fees_number;?>][status]" id="ext_cst_status_extra">39 <select name="ext_cst_extra[<?php echo $_POST['number'];?>][status]" id="ext_cst_status_extra"> 63 40 <option value="enable">Enable</option> 64 41 <option value="disable">Disable</option> … … 69 46 <th scope="row"><label><?php _e( 'Label'); ?></labe></td> 70 47 <td> 71 <input type="text" name="ext_cst_extra[<?php echo $ fees_number;?>][label]" class="regular-text code" id="ext_cst_label_extra" value="<?php echo 'Unlabelled Fees #'.$fees_number;?>"/>48 <input type="text" name="ext_cst_extra[<?php echo $_POST['number'];?>][label]" class="regular-text code" id="ext_cst_label_extra" value="<?php echo 'Unlabelled Fees #'.$_POST['number'];?>"/> 72 49 </td> 73 50 </tr> … … 75 52 <th scope="row"><label><?php _e( 'Label for Billing'); ?></labe></td> 76 53 <td> 77 <input type="text" name="ext_cst_extra[<?php echo $ fees_number;?>][label_billing]" class="regular-text code" id="ext_cst_label_billing_extra" value="Unlabelled Fees #<?php echo $fees_number;?>"/>54 <input type="text" name="ext_cst_extra[<?php echo $_POST['number'];?>][label_billing]" class="regular-text code" id="ext_cst_label_billing_extra" value="Unlabelled Fees #<?php echo $_POST['number'];?>"/> 78 55 </td> 79 56 </tr> … … 81 58 <th scope="row"><label><?php _e( 'Type'); ?><label></th> 82 59 <td> 83 <select name="ext_cst_extra[<?php echo $ fees_number;?>][amount_type]" id="ext_cst_amount_type_extra" onchange="showHideTaxShipping(this,<?php echo $fees_number;?>)">60 <select name="ext_cst_extra[<?php echo $_POST['number'];?>][amount_type]" id="ext_cst_amount_type_extra" onchange="showHideTaxShipping(this,<?php echo $_POST['number'];?>)"> 84 61 <option value="fixed">Fixed</option> 85 62 <option value="percent">Percentage</option> 86 63 </select> 87 88 </td> 89 </tr> 90 <tr id="incTax-<?php echo $fees_number; ?>" class="incTax" style="display:none;"> 64 </td> 65 </tr> 66 <tr id="incTax-<?php echo $_POST['number']; ?>" class="incTax" style="display:none;"> 91 67 <th scope="row"><label><?php _e( 'Calculate fees including TAX'); ?></label></th> 92 68 <td> 93 <select> 94 <option value="no">No</option> 95 <option value="yes">Yes</option> 96 </select> 97 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 98 </td> 99 </tr> 100 <tr id="incShipCosts-<?php echo $fees_number; ?>" class="incShipCosts" style="display:none;"> 69 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][inc_tax]" id="ext_cst_inc_tax_extra"> 70 <option value="no">No</option> 71 <option value="yes">Yes</option> 72 </select> 73 </td> 74 </tr> 75 <tr id="incShipCosts-<?php echo $_POST['number']; ?>" class="incShipCosts" style="display:none;"> 101 76 <th scope="row"><label><?php _e( 'Calculate fees including Shipping Costs'); ?></label></th> 102 77 <td> 103 <select> 104 <option value="no">No</option> 105 <option value="yes">Yes</option> 106 </select> 107 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 78 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][inc_ship_costs]" id="ext_cst_inc_ship_costs_extra"> 79 <option value="no">No</option> 80 <option value="yes">Yes</option> 81 </select> 108 82 </td> 109 83 </tr> … … 112 86 <th scope="row"><label><?php _e( 'Amount'); ?></labe></td> 113 87 <td> 114 <input type="number" step="any" name="ext_cst_extra[<?php echo $ fees_number;?>][amount]" class="fees_amount regular-text code" id="ext_cst_amount_extra<?php echo $fees_number;?>" value="1"/>88 <input type="number" step="any" name="ext_cst_extra[<?php echo $_POST['number'];?>][amount]" class="fees_amount regular-text code" id="ext_cst_amount_extra<?php echo $_POST['number'];?>" value="1"/> 115 89 </td> 116 90 </tr> … … 118 92 <th scope="row"><label><?php _e( 'Apply Condition'); ?></label></th> 119 93 <td> 120 <select name="ext_cst_extra[<?php echo $ fees_number; ?>][apply_type]" id="ext_cst_apply_type<?php echo $fees_number; ?>">94 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][apply_type]" id="ext_cst_apply_type<?php echo $_POST['number']; ?>"> 121 95 <option value="one_time">One Time Only</option> 122 96 <option value="multiply">Multiplied By Product Quantity</option> 123 97 </select> 124 98 <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> 125 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 126 </td> 127 </tr> 128 <tr> 129 <th scope="row"><label><?php _e( 'Auto-checked/Auto-applied the fees' ); ?><label></th> 130 <td> 131 <select> 99 </td> 100 </tr> 101 <tr> 102 <th scope="row"> 103 <label><?php _e( 'Auto-checked/Auto-applied the fees' ); ?><label> 104 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 105 </th> 106 <td> 107 <select name="ext_cst_extra[<?php echo $_POST['number'];?>][auto_checked]" id="ext_cst_auto_checked_extra"> 132 108 <option value="disable">Disable</option> 133 109 <option value="enable">Enable</option> 134 110 </select> 135 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p>136 111 </td> 137 112 </tr> … … 139 114 <th scope="row"><label><?php _e( 'Condition'); ?><label></th> 140 115 <td> 141 <select data-id="<?php echo $ fees_number;?>" name="ext_cst_extra_apply_cndtn<?php echo $fees_number;?>" id="ext_cst_apply_cndtn_extra<?php echo $fees_number;?>" class="ext_cst_cndtn_dropdown" onchange="show_hide_cndtn_extra(<?php echo $fees_number;?>)">116 <select data-id="<?php echo $_POST['number'];?>" name="ext_cst_extra[<?php echo $_POST['number'];?>][apply_cndtn]" id="ext_cst_apply_cndtn_extra<?php echo $_POST['number'];?>" class="ext_cst_cndtn_dropdown" onchange="show_hide_cndtn_extra(<?php echo $_POST['number'];?>)"> 142 117 <option value="all">All</option> 143 118 <option value="cart_total_amount">Cart Total Amount</option> … … 149 124 </td> 150 125 </tr> 151 <tr id="cart_total_amount<?php echo $ fees_number;?>" class="cndtn_mode_extra<?php echo $fees_number;?>" style="display: none;">126 <tr id="cart_total_amount<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 152 127 <th scope="row"><label><?php _e( 'Cart Amount'); ?></labe></td> 153 128 <td> 154 129 <label>Minimum</label> 155 <input type="number" class="small-text" id="cart_total_amount_min_extra" value=""/>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=""/> 156 131 157 132 <label>Maximum</label> 158 <input type="number" class="small-text" id="cart_total_amount_max_extra" value=""/> 159 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 160 </td> 161 </tr> 162 <tr id="cart_no_product<?php echo $fees_number;?>" class="cndtn_mode_extra<?php echo $fees_number;?>" style="display: none;"> 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;"> 163 137 <th scope="row"><label><?php _e( 'No. Of Product on Cart'); ?></labe></td> 164 138 <td> 165 139 <label>Minimum</label> 166 <input type="number" class="small-text" id="cart_no_product_min_extra" value=""/>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=""/> 167 141 168 142 <label>Maximum</label> 169 <input type="number" class="small-text" id="cart_no_product_max_extra" value=""/> 170 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 171 </td> 172 </tr> 173 <tr id="selected_product<?php echo $fees_number;?>" class="cndtn_mode_extra<?php echo $fees_number;?>" style="display: none;"> 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;"> 174 147 <th scope="row"><label><?php _e( 'Selected Product'); ?><label></th> 175 148 <td> 176 <select name="ext_cst_extra _selected_product_id_extra" id="ext_cst_extra_selected_product_id_extra" class="wps_wafc_multiselect" multiple="multiple">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"> 177 150 <?php 178 151 $args = array( … … 183 156 if ( $loop->have_posts() ) { 184 157 while ( $loop->have_posts() ) : $loop->the_post();?> 185 <option ><?php echo get_the_title(); ?></option>158 <option value="<?php echo get_the_ID(); ?>"><?php echo get_the_title(); ?></option> 186 159 <?php 187 160 endwhile; … … 192 165 ?> 193 166 </select> 194 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 195 </td> 196 </tr> 197 <tr id="selected_category<?php echo $fees_number;?>" class="cndtn_mode_extra<?php echo $fees_number;?>" style="display: none;"> 167 </td> 168 </tr> 169 <tr id="selected_category<?php echo $_POST['number'];?>" class="cndtn_mode_extra<?php echo $_POST['number'];?>" style="display: none;"> 198 170 <th scope="row"><label><?php _e( 'Selected Product Category'); ?><label></th> 199 171 <td> 200 <select name="ext_cst_extra _selected_cat_id_extra" id="ext_cst_extra_selected_cat_id_extra" class="wps_wafc_multiselect" multiple="multiple">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"> 201 173 <?php 202 174 $args = array( … … 209 181 if ( $categories ) { 210 182 foreach( $categories as $category ) :?> 211 <option >183 <option value="<?php echo $category->term_id; ?>"> 212 184 <?php echo $category->name.' ('.$category->count.')'; ?> 213 185 </option> … … 219 191 ?> 220 192 </select> 221 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 222 </td> 223 </tr> 224 <tr id="selected_pr_type<?php echo $fees_number;?>" class="cndtn_mode_extra<?php echo $fees_number;?>" style="display: none;"> 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;"> 225 196 <th scope="row"><label><?php _e( 'Selected Product Type'); ?><label></th> 226 197 <td> 227 <select name="ext_cst_extra _selected_pr_type_extra" id="ext_cst_extra_selected_pr_type_extra" class="wps_wafc_multiselect" multiple="multiple">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"> 228 199 <?php 229 200 $pr_types = array('simple','grouped','variable','external_affiliate'); 230 201 foreach ( $pr_types as $types ) :?> 231 <option ><?php echo str_replace("_"," / ",ucwords($types)); ?></option>202 <option value="<?php echo $types; ?>"><?php echo str_replace("_"," / ",ucwords($types)); ?></option> 232 203 <?php 233 204 endforeach; 234 205 ?> 235 206 </select> 236 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 237 </td> 238 </tr> 239 <tr> 240 <th scope="row"><label><?php _e( 'Required Field'); ?></labe></td> 241 <td> 242 <select> 243 <option value="no">No</option> 244 <option value="yes">Yes</option> 245 </select> 246 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 247 </td> 248 </tr> 249 <tr> 250 <th scope="row"><label><?php _e( 'Hide Option At Checkout'); ?></label></th> 251 <td> 252 <select name="ext_cst_extra_hide_on_frontend" id="ext_cst_extra_hide_on_frontend"> 253 <option value="no">No</option> 254 <option value="yes">Yes</option> 255 </select> 256 <p class="error">Available with premium version.<a target="_blank;" href="https://www.wpsuperiors.com/woocommerce-additional-fees-on-checkout/"><br/>Buy Now</a>.</p> 207 </td> 208 </tr> 209 <tr> 210 <th scope="row"> 211 <label><?php _e( 'Required Field'); ?></label> 212 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 213 </th> 214 <td> 215 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][ext_cst_is_required_extra]" name="" id="ext_cst_is_required_extra"> 216 <option value="no">No</option> 217 <option value="yes">Yes</option> 218 </select> 219 </td> 220 </tr> 221 <tr> 222 <th scope="row"> 223 <label><?php _e( 'Hide Option At Checkout'); ?></label> 224 <p class="wps-feat-not">This feature will not work for WooCommerce Checkout Blocks.</p> 225 </th> 226 <td> 227 <select name="ext_cst_extra[<?php echo $_POST['number']; ?>][hide_on_frontend]" id="ext_cst_hide_on_frontend<?php echo $_POST['number']; ?>"> 228 <option value="no">No</option> 229 <option value="yes">Yes</option> 230 </select> 257 231 </td> 258 232 </tr> -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-extra-fees-frontend.php
r2811248 r3388342 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')); 14 15 break; 15 16 } … … 33 34 break; 34 35 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 default: 36 116 return true; … … 44 124 foreach ($extra_options as $option => $value) { 45 125 $status = $value['status'] ? $value['status'] : 'enable'; 126 $auto_checked = $value['auto_checked'] ? $value['auto_checked'] : 'disable'; 127 46 128 if( $status == 'enable' && !is_admin() ){ 47 129 $key = 'wps_ext_cst_label_extra_'.$option; … … 55 137 </script> 56 138 <?php 139 if( $auto_checked == 'enable' ){ 140 ?> 141 <script type="text/javascript">jQuery('#<?php echo $key; ?>').trigger('click');</script> 142 <?php 143 } 57 144 } 58 145 … … 74 161 $field_id = 'wps_ext_cst_extra_field_'.$option; 75 162 $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 } 76 170 $extra_final_cost = WPS_EXT_CST_Extra_Fees_Frontend::calculate_final_cost_extra($value); 77 171 78 79 echo '<div id="'.$field_id.'">'; 172 echo '<div id="'.$field_id.'" class="'.$wps_exts_custom_cls.'">'; 80 173 woocommerce_form_field( $key, array( 81 174 'type' => 'checkbox', 82 175 'class' => array('wps_ext_cst_label_extra_option form-row-wide'), 83 176 'label' => $label, 84 'required' => false,177 'required' => $is_required_extra, 85 178 'placeholder' => __('') 86 179 ), $checkout->get_value( $key )); … … 93 186 public static function calculate_final_cost_extra( $fees ){ 94 187 global $woocommerce; 95 96 $ext_ext_cst_amount_type = ($fees['amount_type']) ? $fees['amount_type'] : 'fixed'; 97 $ext_ext_cst_amount = ($fees['amount']) ? $fees['amount'] : 1; 98 $ext_ext_cst_apply_cndtn = ($fees['apply_cndtn']) ? $fees['apply_cndtn'] : 'all'; 99 100 $cost = $ext_ext_cst_amount; 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 } 193 $ext_ext_cst_amount_type = (isset($fees['amount_type'])) ? $fees['amount_type'] : 'fixed'; 194 $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 } 101 216 102 217 switch ($ext_ext_cst_amount_type) { … … 105 220 break; 106 221 case 'percent': 107 $extracost = ( $woocommerce->cart->cart_contents_total ) * $cost; 222 $ext_cst_inc_ship_costs = ($fees['inc_ship_costs']) ? $fees['inc_ship_costs'] : 'no'; 223 $ext_cst_inc_tax = ($fees['inc_tax']) ? $fees['inc_tax'] : 'no'; 224 225 $total_tax = 0; 226 $shipping_cost = 0; 227 if( $ext_cst_inc_tax == 'yes' ){ 228 foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : 229 $total_tax = $total_tax + $tax->amount; 230 endforeach; 231 } 232 233 if( $ext_cst_inc_ship_costs == 'yes' ){ 234 $shipping_cost = $woocommerce->cart->get_shipping_total(); 235 } 236 237 $extracost = ( $woocommerce->cart->cart_contents_total + $total_tax + $shipping_cost ) * $cost; 108 238 $extracost = ( $extracost )/100; 109 239 break; … … 116 246 117 247 } 118 119 public static function calculate_extra_costs( $cart ){ 120 if ( ! $_POST || ( is_admin() && ! is_ajax() ) ) { 121 return; 122 } 123 124 if ( isset( $_POST['post_data'] ) ) { 125 parse_str( $_POST['post_data'], $post_data ); 126 } else { 127 $post_data = $_POST; 128 } 129 130 $extra_options = get_option('ext_cst_extra'); 248 public static function check_required_fees_extra(){ 249 $extra_options = get_option('ext_cst_extra'); 131 250 if(is_array($extra_options) && !empty($extra_options)){ 132 251 foreach ($extra_options as $option => $value) { 133 252 $status = $value['status'] ? $value['status'] : 'enable'; 134 135 if( $status == 'enable' ){ 253 $get_cndtn = WPS_EXT_CST_Extra_Fees_Frontend::get_extra_condition($value); 254 $is_required = ($value['ext_cst_is_required_extra']=='yes') ? true : false; 255 if( $status == 'enable' && !is_admin() && $get_cndtn && $is_required){ 136 256 $key = 'wps_ext_cst_label_extra_'.$option; 137 if( array_key_exists($key,$post_data) ){ 257 $label = $value['label'] ? $value['label'] : 'Unlabelled Fees'; 258 if ( ! $_POST[$key] ){ 259 wc_add_notice( __( '<b>'.$label.'</b> is a required field.' ), 'error' ); 260 } 261 } 262 } 263 } 264 265 } 266 267 public static function calculate_extra_costs( $cart ){ 268 269 if( WC_Blocks_Utils::has_block_in_page( wc_get_page_id('checkout'), 'woocommerce/checkout' ) ){ 270 $extra_options = get_option('ext_cst_extra'); 271 if(is_array($extra_options) && !empty($extra_options)){ 272 foreach ($extra_options as $option => $value) { 273 //echo '<pre>'; print_r($value); echo '</pre>'; 274 $status = $value['status'] ? $value['status'] : 'enable'; 275 276 if( $status == 'enable' ){ 138 277 $billing_label = $value['label_billing'] ? $value['label_billing'] : 'Unlabelled Fees'; 139 $cost_key = 'cost_amount_hidden_'.$key; 140 $extracost = $post_data[$cost_key]; 141 WC()->cart->add_fee( $billing_label, $extracost ); 278 $final_cost = WPS_EXT_CST_Extra_Fees_Frontend::calculate_final_cost_extra($value); 279 280 $get_cndtn = WPS_EXT_CST_Extra_Fees_Frontend::get_extra_condition($value); 281 282 if( $get_cndtn){ 283 WC()->cart->add_fee( $billing_label, $final_cost ); 284 } 285 } 286 } 287 } 288 }else{ 289 290 if ( ! $_POST || ( is_admin() && ! is_ajax() ) ) { 291 return; 292 } 293 294 if ( isset( $_POST['post_data'] ) ) { 295 parse_str( $_POST['post_data'], $post_data ); 296 } else { 297 $post_data = $_POST; 298 } 299 300 $extra_options = get_option('ext_cst_extra'); 301 if(is_array($extra_options) && !empty($extra_options)){ 302 foreach ($extra_options as $option => $value) { 303 $status = $value['status'] ? $value['status'] : 'enable'; 304 305 if( $status == 'enable' ){ 306 $key = 'wps_ext_cst_label_extra_'.$option; 307 if( array_key_exists($key,$post_data) ){ 308 $billing_label = $value['label_billing'] ? $value['label_billing'] : 'Unlabelled Fees'; 309 310 $cost_key = 'cost_amount_hidden_'.$key; 311 $extracost = $post_data[$cost_key]; 312 WC()->cart->add_fee( $billing_label, $extracost ); 313 } 142 314 } 143 315 } -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-frontend.php
r2811247 r3388342 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 13 11 14 } 12 15 } … … 23 26 return true; 24 27 break; 28 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 25 120 26 121 default: … … 31 126 public static function add_option_to_checkout( $checkout ){ 32 127 global $woocommerce; 33 $ext_cst_apply_cndtn = 'all'; 128 129 130 131 $ext_cst_apply_cndtn = (get_option('ext_cst_apply_cndtn')) ? get_option('ext_cst_apply_cndtn') : 'all'; 34 132 35 133 $get_cndtn = WPS_EXT_CST_Frontend::get_condition($ext_cst_apply_cndtn); 134 36 135 if($get_cndtn){ 136 $is_required = (get_option('ext_cst_is_required')=='yes') ? true : false; 37 137 $ext_cst_label = (get_option('ext_cst_label')) ? get_option('ext_cst_label') : 'Unlabelled Fees'; 38 138 39 139 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 40 140 $ext_cst_amount = (get_option('ext_cst_amount')) ? get_option('ext_cst_amount') : 1; 41 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_apply_cndtn,$ext_cst_amount,$ext_cst_amount_type); 42 43 echo '<div id="wp_ext_cst_field">'; 141 $ext_cst_hide_option = (get_option('ext_cst_hide_option')) ? get_option('ext_cst_hide_option') : 'no'; 142 143 $ext_cst_apply_type = (get_option('ext_cst_apply_type')) ? get_option('ext_cst_apply_type') : 'multiply'; 144 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); 151 152 echo '<div id="wp_ext_cst_field" class ="'.$wps_custom_cls.'">'; 44 153 woocommerce_form_field( 'wps_ext_cst_label', array( 45 154 'type' => 'checkbox', 46 155 'class' => array('wps_ext_cst_label form-row-wide'), 47 156 'label' => $ext_cst_label, 48 'required' => false, 157 'required' => $is_required, 158 'value' => 158, 49 159 'placeholder' => __('') 50 160 ), $checkout->get_value( 'wps_ext_cst_label' )); … … 55 165 } 56 166 57 public static function calculate_final_cost( $cndtn, $amount, $type ){167 public static function calculate_final_cost( $cndtn, $amount, $type, $apply_type ){ 58 168 global $woocommerce; 59 $cost = $amount; 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 } 60 194 61 195 switch ($type) { … … 64 198 break; 65 199 case 'percent': 66 67 $extracost = ( $woocommerce->cart->cart_contents_total ) * $cost; 200 $ext_cst_inc_ship_costs = (get_option('ext_cst_inc_ship_costs')) ? get_option('ext_cst_inc_ship_costs') : 'no'; 201 $ext_cst_inc_tax = (get_option('ext_cst_inc_tax')) ? get_option('ext_cst_inc_tax') : 'no'; 202 203 $total_tax = 0; 204 $shipping_cost = 0; 205 if( $ext_cst_inc_tax == 'yes' ){ 206 foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : 207 $total_tax = $total_tax + $tax->amount; 208 endforeach; 209 } 210 211 if( $ext_cst_inc_ship_costs == 'yes' ){ 212 $shipping_cost = $woocommerce->cart->get_shipping_total(); 213 } 214 215 $extracost = ( $woocommerce->cart->cart_contents_total + $total_tax + $shipping_cost ) * $cost; 68 216 $extracost = ( $extracost )/100; 69 217 break; … … 76 224 } 77 225 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 78 238 public static function add_script_on_checkout(){ 79 239 if (is_checkout()) { 80 240 $ext_cst_label_css = (get_option('ext_cst_label_css')) ? get_option('ext_cst_label_css') : ''; 241 $ext_cst_auto_checked = (get_option('ext_cst_auto_checked')) ? get_option('ext_cst_auto_checked') : 'disable'; 81 242 ?> 82 243 <script type="text/javascript"> … … 89 250 <style> 90 251 <?php echo $ext_cst_label_css; ?> 252 .wps_hide_me{ display: none !important; } 91 253 </style> 92 254 <?php 93 255 } 94 256 if( $ext_cst_auto_checked == 'enable' ){ 257 ?> 258 <script type="text/javascript">jQuery('#wps_ext_cst_label').trigger('click');</script> 259 <?php 260 } 95 261 } 96 262 97 263 public static function apply_the_cost_to_cart( $cart ){ 264 265 266 98 267 $ext_cst_label_billing = (get_option('ext_cst_label_billing')) ? get_option('ext_cst_label_billing') : 'Unlabelled Fees'; 99 268 100 269 global $woocommerce; 101 270 102 if ( ! $_POST || ( is_admin() && ! is_ajax() ) ) { 103 return; 104 } 105 106 if ( isset( $_POST['post_data'] ) ) { 107 parse_str( $_POST['post_data'], $post_data ); 108 } else { 109 $post_data = $_POST; 110 } 111 // echo "<pre>"; print_r($post_data); echo "</pre>"; 112 if (isset($post_data['wps_ext_cst_label']) && isset($post_data['extra_cost_amount'])) { 113 global $woocommerce; 114 $extracost = $post_data['extra_cost_amount']; 115 WC()->cart->add_fee( $ext_cst_label_billing, $extracost ); 116 } 271 if( WC_Blocks_Utils::has_block_in_page( wc_get_page_id('checkout'), 'woocommerce/checkout' ) ){ 272 273 $ext_cst_amount_type = (get_option('ext_cst_amount_type')) ? get_option('ext_cst_amount_type') : 'fixed'; 274 $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'; 277 278 $final_cost = WPS_EXT_CST_Frontend::calculate_final_cost($ext_cst_apply_cndtn,$ext_cst_amount,$ext_cst_amount_type,$ext_cst_apply_type); 279 280 $get_cndtn = WPS_EXT_CST_Frontend::get_condition($ext_cst_apply_cndtn); 281 282 if($get_cndtn){ 283 WC()->cart->add_fee( $ext_cst_label_billing, $final_cost ); 284 } 285 }else{ 286 287 if ( ! $_POST || ( is_admin() && ! is_ajax() ) ) { 288 return; 289 } 290 291 if ( isset( $_POST['post_data'] ) ) { 292 parse_str( $_POST['post_data'], $post_data ); 293 } else { 294 $post_data = $_POST; 295 } 296 // echo "<pre>"; print_r($post_data); echo "</pre>"; 297 if (isset($post_data['wps_ext_cst_label']) && isset($post_data['extra_cost_amount'])) { 298 global $woocommerce; 299 $extracost = $post_data['extra_cost_amount']; 300 WC()->cart->add_fee( $ext_cst_label_billing, $extracost ); 301 } 302 } 303 304 117 305 } 118 306 -
woo-additional-fees-on-checkout-wordpress/trunk/classes/wps-ext-cst-main.php
r2891885 r3388342 11 11 if( $hook != 'woocommerce_page_wps-ext-cst-option') 12 12 return; 13 14 13 wp_register_script('WPS_EXT_CST_SELECT2_ADMIN_JS', WPS_EXT_CST_JS.'/wafc-select2.min.js', array('jquery'),'1.1', true); 15 14 wp_enqueue_script('WPS_EXT_CST_SELECT2_ADMIN_JS'); 16 15 17 16 wp_register_script('WPS_EXT_CST_ADMIN_JS', WPS_EXT_CST_JS.'/wps-ext-cst.js', array('jquery'),'1.1', true); 18 17 wp_enqueue_script('WPS_EXT_CST_ADMIN_JS'); -
woo-additional-fees-on-checkout-wordpress/trunk/readme.txt
r3367371 r3388342 11 11 12 12 == Description == 13 Formerly know as WooCommerce additional Fees On Checkout. Additional Fees For WooCommerce Checkout plugin allows to create required or non-required multiple fees on checkout page to apply an fixed or percentage cost upon cart total quantity, Individual product, Cart total amount, Product category, Product type.13 Formerly known as WooCommerce additional Fees On Checkout,allows to create required or non-required multiple fees on checkout page to apply an fixed or percentage cost upon cart total quantity, Individual product, Cart total amount, Product category, Product type. This plugin supports WooCommerce Block Checkout. 14 14 15 15 = Introduction = … … 18 18 19 19 In one words, Additional Fees For WooCommerce Checkout plugin makes it very simple. 20 21 It supports WooCommerce Block Checkout. 20 22 21 23 Additional Fees For WooCommerce Checkout plugin built to integrate seamlessly with WordPress WooCommerce, that gives store owners complete control to adjust Labels, amount, percentage or fixed price calculation etc. … … 119 121 120 122 == Changelog == 123 = 1.5.1 - 02nd Nov, 2025 = 124 *WooCommerce Block Checkout support* 125 *Compatibility support* 126 121 127 = 1.4.9 - 30th Jan, 2025 = 122 128 *WooCommerce & WordPress compatiability update*
Note: See TracChangeset
for help on using the changeset viewer.