Changeset 3440105
- Timestamp:
- 01/15/2026 08:02:07 AM (2 months ago)
- Location:
- woot-ro
- Files:
-
- 6 deleted
- 9 edited
- 20 copied
-
tags/2.1.3 (copied) (copied from woot-ro/trunk)
-
tags/2.1.3/README.txt (copied) (copied from woot-ro/trunk/README.txt) (3 diffs)
-
tags/2.1.3/includes/admin (copied) (copied from woot-ro/trunk/includes/admin)
-
tags/2.1.3/includes/api (copied) (copied from woot-ro/trunk/includes/api)
-
tags/2.1.3/includes/checkout (copied) (copied from woot-ro/trunk/includes/checkout)
-
tags/2.1.3/includes/checkout/class-woot-checkout.php (modified) (1 diff)
-
tags/2.1.3/includes/class-woot-i18n.php (copied) (copied from woot-ro/trunk/includes/class-woot-i18n.php)
-
tags/2.1.3/includes/class-woot-woocommerce-couriers.php (deleted)
-
tags/2.1.3/includes/class-woot-woocommerce-locations.php (deleted)
-
tags/2.1.3/includes/class-woot-woocommerce.php (copied) (copied from woot-ro/trunk/includes/class-woot-woocommerce.php)
-
tags/2.1.3/includes/class-woot.php (copied) (copied from woot-ro/trunk/includes/class-woot.php)
-
tags/2.1.3/includes/shipping (copied) (copied from woot-ro/trunk/includes/shipping)
-
tags/2.1.3/includes/shipping/class-woot-shipping-services.php (modified) (13 diffs)
-
tags/2.1.3/languages/woot-ro-ro_RO.mo (copied) (copied from woot-ro/trunk/languages/woot-ro-ro_RO.mo)
-
tags/2.1.3/languages/woot-ro-ro_RO.po (copied) (copied from woot-ro/trunk/languages/woot-ro-ro_RO.po) (2 diffs)
-
tags/2.1.3/languages/woot-ro.pot (copied) (copied from woot-ro/trunk/languages/woot-ro.pot) (2 diffs)
-
tags/2.1.3/languages/woot-ro_RO.mo (deleted)
-
tags/2.1.3/languages/woot-ro_RO.po (deleted)
-
tags/2.1.3/languages/woot.pot (deleted)
-
tags/2.1.3/public/class-woot-public.php (copied) (copied from woot-ro/trunk/public/class-woot-public.php)
-
tags/2.1.3/public/css/woot-public.css (copied) (copied from woot-ro/trunk/public/css/woot-public.css)
-
tags/2.1.3/public/css/woot-public.min.css (copied) (copied from woot-ro/trunk/public/css/woot-public.min.css)
-
tags/2.1.3/public/js/woot-city.js (copied) (copied from woot-ro/trunk/public/js/woot-city.js)
-
tags/2.1.3/public/js/woot-city.min.js (deleted)
-
tags/2.1.3/public/js/woot-locations.js (copied) (copied from woot-ro/trunk/public/js/woot-locations.js)
-
tags/2.1.3/public/js/woot-locations.min.js (copied) (copied from woot-ro/trunk/public/js/woot-locations.min.js)
-
tags/2.1.3/public/js/woot-services.js (copied) (copied from woot-ro/trunk/public/js/woot-services.js)
-
tags/2.1.3/woot.php (copied) (copied from woot-ro/trunk/woot.php) (2 diffs)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/includes/checkout/class-woot-checkout.php (modified) (1 diff)
-
trunk/includes/shipping/class-woot-shipping-services.php (modified) (13 diffs)
-
trunk/languages/woot-ro-ro_RO.mo (modified) (previous)
-
trunk/languages/woot-ro-ro_RO.po (modified) (2 diffs)
-
trunk/languages/woot-ro.pot (modified) (2 diffs)
-
trunk/woot.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woot-ro/tags/2.1.3/README.txt
r3438930 r3440105 4 4 Requires at least: 4.0 5 5 Tested up to: 6.9 6 Stable tag: 2.1. 26 Stable tag: 2.1.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 78 78 79 79 == Changelog == 80 81 = 2.1.3 = 82 * New: Markup (adaos) fields for shipping services - percentage and/or fixed amount 83 * New: Markup (adaos) fields for payment methods - percentage from order total and/or fixed amount 84 * New: Visual highlight for enabled services in the settings table 85 * New: Help tooltips on table column headers explaining each field 86 * Improvement: Markup fields only visible when price type is "Quotation" 87 * Improvement: Dynamic UI updates when toggling service checkbox or price type 80 88 81 89 = 2.1.2 = … … 151 159 == Upgrade Notice == 152 160 161 = 2.1.3 = 162 * New markup (adaos) fields for services and payment methods. Add percentage and/or fixed amount to shipping prices and payment fees. 163 153 164 = 2.1.2 = 154 165 * New unified shipping method (Woot PRO - Services) with API keys authentication and quotation pricing. Legacy methods deprecated but still functional. -
woot-ro/tags/2.1.3/includes/checkout/class-woot-checkout.php
r3438930 r3440105 262 262 $settings = get_option('woocommerce_woot_services_' . $instance_id . '_settings'); 263 263 264 if (!empty($settings[$payment_id . '_fee'])) { 264 $fee_percent = isset($settings[$payment_id . '_fee_percent']) ? floatval($settings[$payment_id . '_fee_percent']) : 0; 265 $fee_fixed = isset($settings[$payment_id . '_fee_fixed']) ? floatval($settings[$payment_id . '_fee_fixed']) : 0; 266 267 if ($fee_percent > 0 || $fee_fixed > 0) { 265 268 $gateways = WC_Payment_Gateways::instance(); 266 269 $payment = isset($gateways->payment_gateways()[$payment_id]) ? $gateways->payment_gateways()[$payment_id] : null; 267 270 268 271 if ($payment) { 269 $cart->add_fee($payment->title, floatval($settings[$payment_id . '_fee']), !empty($cart->get_shipping_tax())); 272 $order_total = $cart->get_subtotal() + $cart->get_shipping_total(); 273 $fee = 0; 274 275 // Apply percentage first (from order total) 276 if ($fee_percent > 0) { 277 $fee = $order_total * ($fee_percent / 100); 278 } 279 280 // Then add fixed 281 if ($fee_fixed > 0) { 282 $fee += $fee_fixed; 283 } 284 285 if ($fee > 0) { 286 $cart->add_fee($payment->title, $fee, !empty($cart->get_shipping_tax())); 287 } 270 288 } 271 289 } -
woot-ro/tags/2.1.3/includes/shipping/class-woot-shipping-services.php
r3438930 r3440105 247 247 'default' => '' 248 248 ); 249 250 $fields[$key . '_markup_percent'] = array( 251 'type' => 'number', 252 'default' => '' 253 ); 254 255 $fields[$key . '_markup_fixed'] = array( 256 'type' => 'number', 257 'default' => '' 258 ); 249 259 } 250 260 … … 254 264 255 265 if ($gateways && $this->is_accessing_settings()) { 256 $fields['payment_fees _title'] = array(266 $fields['payment_fees'] = array( 257 267 'title' => __('Payment Method Fees', 'woot-ro'), 258 'type' => ' title',268 'type' => 'payment_fees_table', 259 269 'description' => __('Extra charges for specific payment methods (applies to all services)', 'woot-ro'), 260 270 ); … … 264 274 foreach ($gateways as $gateway) { 265 275 if ($gateway->enabled == 'yes') { 266 $fields[$gateway->id . '_fee'] = array( 267 'title' => $this->is_accessing_settings() ? $gateway->title : '', 276 $fields[$gateway->id . '_fee_percent'] = array( 268 277 'type' => 'number', 269 'default' => '', 270 'placeholder' => '0.00', 271 'desc_tip' => $gateway->method_description, 272 'custom_attributes' => array( 273 'min' => '0', 274 'step' => '0.01' 275 ) 278 'default' => '' 279 ); 280 281 $fields[$gateway->id . '_fee_fixed'] = array( 282 'type' => 'number', 283 'default' => '' 276 284 ); 277 285 } … … 312 320 <th style="width: 40px;"></th> 313 321 <th><?php esc_html_e('Service', 'woot-ro'); ?></th> 314 <th style="width: 200px;"><?php esc_html_e('Custom Name', 'woot-ro'); ?></th> 315 <th style="width: 250px;"><?php esc_html_e('Description', 'woot-ro'); ?></th> 316 <th style="width: 120px;"><?php esc_html_e('Price Type', 'woot-ro'); ?></th> 317 <th style="width: 100px;"><?php esc_html_e('Price', 'woot-ro'); ?></th> 322 <th style="width: 200px;"><?php esc_html_e('Custom Name', 'woot-ro'); ?> <?php echo wc_help_tip(__('Custom name displayed to customers at checkout', 'woot-ro')); ?></th> 323 <th style="width: 250px;"><?php esc_html_e('Description', 'woot-ro'); ?> <?php echo wc_help_tip(__('Optional description shown below the service name', 'woot-ro')); ?></th> 324 <th style="width: 120px;"><?php esc_html_e('Price Type', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed: use the price you set. Quotation: get real-time price from API', 'woot-ro')); ?></th> 325 <th style="width: 100px;"><?php esc_html_e('Price', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed price or fallback price if quotation fails', 'woot-ro')); ?></th> 326 <th style="width: 100px; white-space: nowrap;"><?php esc_html_e('Adaos %', 'woot-ro'); ?> <?php echo wc_help_tip(__('Percentage markup added to the shipping price', 'woot-ro')); ?></th> 327 <th style="width: 100px; white-space: nowrap;"><?php esc_html_e('Adaos Fix', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed amount added to the shipping price', 'woot-ro')); ?></th> 318 328 </tr> 319 329 </thead> … … 321 331 <?php if (empty($services)) : ?> 322 332 <tr> 323 <td colspan=" 6" style="text-align: center; padding: 20px;">333 <td colspan="8" style="text-align: center; padding: 20px;"> 324 334 <?php esc_html_e('No services available.', 'woot-ro'); ?> 325 335 </td> … … 334 344 $price_type = isset($this->instance_settings[$service_key . '_price_type']) ? $this->instance_settings[$service_key . '_price_type'] : 'fixed'; 335 345 $price = isset($this->instance_settings[$service_key . '_price']) ? $this->instance_settings[$service_key . '_price'] : ''; 346 $markup_percent = isset($this->instance_settings[$service_key . '_markup_percent']) ? $this->instance_settings[$service_key . '_markup_percent'] : ''; 347 $markup_fixed = isset($this->instance_settings[$service_key . '_markup_fixed']) ? $this->instance_settings[$service_key . '_markup_fixed'] : ''; 336 348 $pickup_type = isset($service['pickup']) ? $service['pickup'] : 'door'; 349 $row_style = $enabled ? 'background-color: #e7f5e9;' : ''; 337 350 ?> 338 <tr >351 <tr style="<?php echo esc_attr($row_style); ?>" class="woot-service-row <?php echo $enabled ? 'woot-service-enabled' : ''; ?>"> 339 352 <td style="text-align: center; vertical-align: middle;"> 340 353 <input type="checkbox" … … 388 401 style="width: 100%;" /> 389 402 </td> 403 <td> 404 <input type="number" 405 name="<?php echo esc_attr($this->get_field_key($service_key . '_markup_percent')); ?>" 406 id="<?php echo esc_attr($this->get_field_key($service_key . '_markup_percent')); ?>" 407 class="woot-markup-input" 408 data-service="<?php echo esc_attr($service_key); ?>" 409 value="<?php echo esc_attr($markup_percent); ?>" 410 placeholder="0" 411 min="0" 412 step="0.01" 413 style="width: 100%;<?php echo $price_type !== 'quotation' ? ' display: none;' : ''; ?>" /> 414 </td> 415 <td> 416 <input type="number" 417 name="<?php echo esc_attr($this->get_field_key($service_key . '_markup_fixed')); ?>" 418 id="<?php echo esc_attr($this->get_field_key($service_key . '_markup_fixed')); ?>" 419 class="woot-markup-input" 420 data-service="<?php echo esc_attr($service_key); ?>" 421 value="<?php echo esc_attr($markup_fixed); ?>" 422 placeholder="0.00" 423 min="0" 424 step="0.01" 425 style="width: 100%;<?php echo $price_type !== 'quotation' ? ' display: none;' : ''; ?>" /> 426 </td> 390 427 </tr> 391 428 <?php endforeach; ?> 392 429 <?php endif; ?> 430 </tbody> 431 </table> 432 <script> 433 jQuery(function($) { 434 // Toggle row highlight on checkbox change 435 $('.woot-services-table input[type="checkbox"]').on('change', function() { 436 var $row = $(this).closest('tr'); 437 if ($(this).is(':checked')) { 438 $row.css('background-color', '#e7f5e9').addClass('woot-service-enabled'); 439 } else { 440 $row.css('background-color', '').removeClass('woot-service-enabled'); 441 } 442 }); 443 444 // Toggle markup fields visibility based on price type 445 $('.woot-price-type-select').on('change', function() { 446 var serviceKey = $(this).data('service'); 447 var $markupInputs = $('.woot-markup-input[data-service="' + serviceKey + '"]'); 448 if ($(this).val() === 'quotation') { 449 $markupInputs.show(); 450 } else { 451 $markupInputs.hide(); 452 } 453 }); 454 }); 455 </script> 456 </td> 457 </tr> 458 <?php 459 return ob_get_clean(); 460 } 461 462 /** 463 * Validate services table field 464 * 465 * @param string $key 466 * @param mixed $value 467 * @return mixed 468 */ 469 public function validate_services_table_field($key, $value) 470 { 471 return ''; 472 } 473 474 /** 475 * Generate payment fees table HTML 476 * 477 * @param string $key 478 * @param array $data 479 * @return string 480 */ 481 public function generate_payment_fees_table_html($key, $data) 482 { 483 $gateways = WC()->payment_gateways()->payment_gateways(); 484 485 ob_start(); 486 ?> 487 <tr valign="top"> 488 <th scope="row" class="titledesc"> 489 <label><?php echo esc_html($data['title']); ?></label> 490 <?php if (!empty($data['description'])) : ?> 491 <p class="description"><?php echo esc_html($data['description']); ?></p> 492 <?php endif; ?> 493 </th> 494 <td class="forminp"> 495 <table class="woot-payment-fees-table widefat striped"> 496 <thead> 497 <tr> 498 <th style="padding: 8px;"><?php esc_html_e('Payment Method', 'woot-ro'); ?></th> 499 <th style="width: 120px; padding: 8px; white-space: nowrap;"><?php esc_html_e('Adaos %', 'woot-ro'); ?> <?php echo wc_help_tip(__('Percentage markup from order total (subtotal + shipping)', 'woot-ro')); ?></th> 500 <th style="width: 120px; padding: 8px; white-space: nowrap;"><?php esc_html_e('Adaos Fix', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed amount added to the order', 'woot-ro')); ?></th> 501 </tr> 502 </thead> 503 <tbody> 504 <?php foreach ($gateways as $gateway) : 505 if ($gateway->enabled !== 'yes') continue; 506 $fee_percent = isset($this->instance_settings[$gateway->id . '_fee_percent']) ? $this->instance_settings[$gateway->id . '_fee_percent'] : ''; 507 $fee_fixed = isset($this->instance_settings[$gateway->id . '_fee_fixed']) ? $this->instance_settings[$gateway->id . '_fee_fixed'] : ''; 508 ?> 509 <tr> 510 <td style="vertical-align: middle; padding: 8px;"> 511 <strong><?php echo esc_html($gateway->title); ?></strong> 512 </td> 513 <td style="vertical-align: middle; padding: 8px;"> 514 <input type="number" 515 name="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_percent')); ?>" 516 id="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_percent')); ?>" 517 value="<?php echo esc_attr($fee_percent); ?>" 518 placeholder="0" 519 min="0" 520 step="0.01" 521 style="width: 100%;" /> 522 </td> 523 <td style="vertical-align: middle; padding: 8px;"> 524 <input type="number" 525 name="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_fixed')); ?>" 526 id="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_fixed')); ?>" 527 value="<?php echo esc_attr($fee_fixed); ?>" 528 placeholder="0.00" 529 min="0" 530 step="0.01" 531 style="width: 100%;" /> 532 </td> 533 </tr> 534 <?php endforeach; ?> 393 535 </tbody> 394 536 </table> … … 400 542 401 543 /** 402 * Validate services table field544 * Validate payment fees table field 403 545 * 404 546 * @param string $key … … 406 548 * @return mixed 407 549 */ 408 public function validate_ services_table_field($key, $value)550 public function validate_payment_fees_table_field($key, $value) 409 551 { 410 552 return ''; … … 438 580 public function generate_text_html($key, $data) 439 581 { 440 // Hide service-specific text fields (rendered in table) 441 if (strpos($key, 'service_') === 0 && (strpos($key, '_name') !== false || strpos($key, '_price') !== false)) { 582 // Hide service-specific text/number fields (rendered in table) 583 if (strpos($key, 'service_') === 0 && ( 584 strpos($key, '_name') !== false || 585 strpos($key, '_price') !== false || 586 strpos($key, '_markup_percent') !== false || 587 strpos($key, '_markup_fixed') !== false 588 )) { 442 589 return ''; 443 590 } 591 592 // Hide payment method fee fields (rendered in table) 593 if (strpos($key, '_fee_percent') !== false || strpos($key, '_fee_fixed') !== false) { 594 return ''; 595 } 596 444 597 return parent::generate_text_html($key, $data); 445 598 } … … 630 783 $fallback_price = isset($this->instance_settings[$key . '_price']) 631 784 ? floatval($this->instance_settings[$key . '_price']) 785 : 0; 786 787 $markup_percent = isset($this->instance_settings[$key . '_markup_percent']) 788 ? floatval($this->instance_settings[$key . '_markup_percent']) 789 : 0; 790 791 $markup_fixed = isset($this->instance_settings[$key . '_markup_fixed']) 792 ? floatval($this->instance_settings[$key . '_markup_fixed']) 632 793 : 0; 633 794 … … 651 812 } 652 813 814 // Apply markup only for quotation pricing (percentage first, then fixed) 815 if (!$is_free && $cost > 0 && $price_type === 'quotation') { 816 if ($markup_percent > 0) { 817 $cost = $cost * (1 + $markup_percent / 100); 818 } 819 if ($markup_fixed > 0) { 820 $cost = $cost + $markup_fixed; 821 } 822 } 823 653 824 // Add rate with service metadata 654 825 $this->add_rate(array( … … 963 1134 * 964 1135 * @param string $payment_method_id 1136 * @param float $order_total Order total to calculate percentage from 965 1137 * @return float 966 1138 */ 967 public function get_payment_fee($payment_method_id) 968 { 969 $key = $payment_method_id . '_fee'; 970 return isset($this->instance_settings[$key]) ? floatval($this->instance_settings[$key]) : 0; 1139 public function get_payment_fee($payment_method_id, $order_total = 0) 1140 { 1141 $fee_percent = isset($this->instance_settings[$payment_method_id . '_fee_percent']) 1142 ? floatval($this->instance_settings[$payment_method_id . '_fee_percent']) 1143 : 0; 1144 1145 $fee_fixed = isset($this->instance_settings[$payment_method_id . '_fee_fixed']) 1146 ? floatval($this->instance_settings[$payment_method_id . '_fee_fixed']) 1147 : 0; 1148 1149 $fee = 0; 1150 1151 // Apply percentage first 1152 if ($fee_percent > 0 && $order_total > 0) { 1153 $fee = $order_total * ($fee_percent / 100); 1154 } 1155 1156 // Then add fixed 1157 if ($fee_fixed > 0) { 1158 $fee += $fee_fixed; 1159 } 1160 1161 return $fee; 971 1162 } 972 1163 } -
woot-ro/tags/2.1.3/languages/woot-ro-ro_RO.po
r3438930 r3440105 4 4 msgid "" 5 5 msgstr "" 6 "Project-Id-Version: Woot.ro 2.1. 2\n"6 "Project-Id-Version: Woot.ro 2.1.3\n" 7 7 "Report-Msgid-Bugs-To: https://woot.ro\n" 8 8 "POT-Creation-Date: 2025-01-13 00:00:00+00:00\n" … … 399 399 msgid "Invalid API keys." 400 400 msgstr "Chei API invalide." 401 402 msgid "Adaos %" 403 msgstr "Adaos %" 404 405 msgid "Adaos Fix" 406 msgstr "Adaos Fix" 407 408 msgid "Payment Method" 409 msgstr "Metodă de plată" 410 411 msgid "Custom name displayed to customers at checkout" 412 msgstr "Nume personalizat afișat clienților la checkout" 413 414 msgid "Optional description shown below the service name" 415 msgstr "Descriere opțională afișată sub numele serviciului" 416 417 msgid "Fixed: use the price you set. Quotation: get real-time price from API" 418 msgstr "Fix: folosește prețul setat. Cotație: obține prețul în timp real din API" 419 420 msgid "Fixed price or fallback price if quotation fails" 421 msgstr "Preț fix sau preț de rezervă dacă cotația eșuează" 422 423 msgid "Percentage markup added to the shipping price" 424 msgstr "Adaos procentual adăugat la prețul de livrare" 425 426 msgid "Fixed amount added to the shipping price" 427 msgstr "Sumă fixă adăugată la prețul de livrare" 428 429 msgid "Percentage markup from order total (subtotal + shipping)" 430 msgstr "Adaos procentual din totalul comenzii (subtotal + livrare)" 431 432 msgid "Fixed amount added to the order" 433 msgstr "Sumă fixă adăugată la comandă" -
woot-ro/tags/2.1.3/languages/woot-ro.pot
r3438930 r3440105 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Woot.ro 2.1. 2\n"5 "Project-Id-Version: Woot.ro 2.1.3\n" 6 6 "Report-Msgid-Bugs-To: https://woot.ro\n" 7 7 "POT-Creation-Date: 2025-01-13 00:00:00+00:00\n" … … 230 230 msgid "Drop-off at door" 231 231 msgstr "" 232 233 #: includes/shipping/class-woot-shipping-services.php 234 msgid "Adaos %" 235 msgstr "" 236 237 #: includes/shipping/class-woot-shipping-services.php 238 msgid "Adaos Fix" 239 msgstr "" 240 241 #: includes/shipping/class-woot-shipping-services.php 242 msgid "Payment Method" 243 msgstr "" 244 245 #: includes/shipping/class-woot-shipping-services.php 246 msgid "Custom name displayed to customers at checkout" 247 msgstr "" 248 249 #: includes/shipping/class-woot-shipping-services.php 250 msgid "Optional description shown below the service name" 251 msgstr "" 252 253 #: includes/shipping/class-woot-shipping-services.php 254 msgid "Fixed: use the price you set. Quotation: get real-time price from API" 255 msgstr "" 256 257 #: includes/shipping/class-woot-shipping-services.php 258 msgid "Fixed price or fallback price if quotation fails" 259 msgstr "" 260 261 #: includes/shipping/class-woot-shipping-services.php 262 msgid "Percentage markup added to the shipping price" 263 msgstr "" 264 265 #: includes/shipping/class-woot-shipping-services.php 266 msgid "Fixed amount added to the shipping price" 267 msgstr "" 268 269 #: includes/shipping/class-woot-shipping-services.php 270 msgid "Percentage markup from order total (subtotal + shipping)" 271 msgstr "" 272 273 #: includes/shipping/class-woot-shipping-services.php 274 msgid "Fixed amount added to the order" 275 msgstr "" -
woot-ro/tags/2.1.3/woot.php
r3438930 r3440105 17 17 * Plugin URI: https://woot.ro 18 18 * Description: Integrates all popular couriers in Romania, providing a one-stop solution for all your delivery needs 19 * Version: 2.1. 219 * Version: 2.1.3 20 20 * Author: Woot.ro 21 21 * Author URI: https://woot.ro … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('WOOT_VERSION', '2.1. 2');38 define('WOOT_VERSION', '2.1.3'); 39 39 40 40 /** -
woot-ro/trunk/README.txt
r3438930 r3440105 4 4 Requires at least: 4.0 5 5 Tested up to: 6.9 6 Stable tag: 2.1. 26 Stable tag: 2.1.3 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 78 78 79 79 == Changelog == 80 81 = 2.1.3 = 82 * New: Markup (adaos) fields for shipping services - percentage and/or fixed amount 83 * New: Markup (adaos) fields for payment methods - percentage from order total and/or fixed amount 84 * New: Visual highlight for enabled services in the settings table 85 * New: Help tooltips on table column headers explaining each field 86 * Improvement: Markup fields only visible when price type is "Quotation" 87 * Improvement: Dynamic UI updates when toggling service checkbox or price type 80 88 81 89 = 2.1.2 = … … 151 159 == Upgrade Notice == 152 160 161 = 2.1.3 = 162 * New markup (adaos) fields for services and payment methods. Add percentage and/or fixed amount to shipping prices and payment fees. 163 153 164 = 2.1.2 = 154 165 * New unified shipping method (Woot PRO - Services) with API keys authentication and quotation pricing. Legacy methods deprecated but still functional. -
woot-ro/trunk/includes/checkout/class-woot-checkout.php
r3438930 r3440105 262 262 $settings = get_option('woocommerce_woot_services_' . $instance_id . '_settings'); 263 263 264 if (!empty($settings[$payment_id . '_fee'])) { 264 $fee_percent = isset($settings[$payment_id . '_fee_percent']) ? floatval($settings[$payment_id . '_fee_percent']) : 0; 265 $fee_fixed = isset($settings[$payment_id . '_fee_fixed']) ? floatval($settings[$payment_id . '_fee_fixed']) : 0; 266 267 if ($fee_percent > 0 || $fee_fixed > 0) { 265 268 $gateways = WC_Payment_Gateways::instance(); 266 269 $payment = isset($gateways->payment_gateways()[$payment_id]) ? $gateways->payment_gateways()[$payment_id] : null; 267 270 268 271 if ($payment) { 269 $cart->add_fee($payment->title, floatval($settings[$payment_id . '_fee']), !empty($cart->get_shipping_tax())); 272 $order_total = $cart->get_subtotal() + $cart->get_shipping_total(); 273 $fee = 0; 274 275 // Apply percentage first (from order total) 276 if ($fee_percent > 0) { 277 $fee = $order_total * ($fee_percent / 100); 278 } 279 280 // Then add fixed 281 if ($fee_fixed > 0) { 282 $fee += $fee_fixed; 283 } 284 285 if ($fee > 0) { 286 $cart->add_fee($payment->title, $fee, !empty($cart->get_shipping_tax())); 287 } 270 288 } 271 289 } -
woot-ro/trunk/includes/shipping/class-woot-shipping-services.php
r3438930 r3440105 247 247 'default' => '' 248 248 ); 249 250 $fields[$key . '_markup_percent'] = array( 251 'type' => 'number', 252 'default' => '' 253 ); 254 255 $fields[$key . '_markup_fixed'] = array( 256 'type' => 'number', 257 'default' => '' 258 ); 249 259 } 250 260 … … 254 264 255 265 if ($gateways && $this->is_accessing_settings()) { 256 $fields['payment_fees _title'] = array(266 $fields['payment_fees'] = array( 257 267 'title' => __('Payment Method Fees', 'woot-ro'), 258 'type' => ' title',268 'type' => 'payment_fees_table', 259 269 'description' => __('Extra charges for specific payment methods (applies to all services)', 'woot-ro'), 260 270 ); … … 264 274 foreach ($gateways as $gateway) { 265 275 if ($gateway->enabled == 'yes') { 266 $fields[$gateway->id . '_fee'] = array( 267 'title' => $this->is_accessing_settings() ? $gateway->title : '', 276 $fields[$gateway->id . '_fee_percent'] = array( 268 277 'type' => 'number', 269 'default' => '', 270 'placeholder' => '0.00', 271 'desc_tip' => $gateway->method_description, 272 'custom_attributes' => array( 273 'min' => '0', 274 'step' => '0.01' 275 ) 278 'default' => '' 279 ); 280 281 $fields[$gateway->id . '_fee_fixed'] = array( 282 'type' => 'number', 283 'default' => '' 276 284 ); 277 285 } … … 312 320 <th style="width: 40px;"></th> 313 321 <th><?php esc_html_e('Service', 'woot-ro'); ?></th> 314 <th style="width: 200px;"><?php esc_html_e('Custom Name', 'woot-ro'); ?></th> 315 <th style="width: 250px;"><?php esc_html_e('Description', 'woot-ro'); ?></th> 316 <th style="width: 120px;"><?php esc_html_e('Price Type', 'woot-ro'); ?></th> 317 <th style="width: 100px;"><?php esc_html_e('Price', 'woot-ro'); ?></th> 322 <th style="width: 200px;"><?php esc_html_e('Custom Name', 'woot-ro'); ?> <?php echo wc_help_tip(__('Custom name displayed to customers at checkout', 'woot-ro')); ?></th> 323 <th style="width: 250px;"><?php esc_html_e('Description', 'woot-ro'); ?> <?php echo wc_help_tip(__('Optional description shown below the service name', 'woot-ro')); ?></th> 324 <th style="width: 120px;"><?php esc_html_e('Price Type', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed: use the price you set. Quotation: get real-time price from API', 'woot-ro')); ?></th> 325 <th style="width: 100px;"><?php esc_html_e('Price', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed price or fallback price if quotation fails', 'woot-ro')); ?></th> 326 <th style="width: 100px; white-space: nowrap;"><?php esc_html_e('Adaos %', 'woot-ro'); ?> <?php echo wc_help_tip(__('Percentage markup added to the shipping price', 'woot-ro')); ?></th> 327 <th style="width: 100px; white-space: nowrap;"><?php esc_html_e('Adaos Fix', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed amount added to the shipping price', 'woot-ro')); ?></th> 318 328 </tr> 319 329 </thead> … … 321 331 <?php if (empty($services)) : ?> 322 332 <tr> 323 <td colspan=" 6" style="text-align: center; padding: 20px;">333 <td colspan="8" style="text-align: center; padding: 20px;"> 324 334 <?php esc_html_e('No services available.', 'woot-ro'); ?> 325 335 </td> … … 334 344 $price_type = isset($this->instance_settings[$service_key . '_price_type']) ? $this->instance_settings[$service_key . '_price_type'] : 'fixed'; 335 345 $price = isset($this->instance_settings[$service_key . '_price']) ? $this->instance_settings[$service_key . '_price'] : ''; 346 $markup_percent = isset($this->instance_settings[$service_key . '_markup_percent']) ? $this->instance_settings[$service_key . '_markup_percent'] : ''; 347 $markup_fixed = isset($this->instance_settings[$service_key . '_markup_fixed']) ? $this->instance_settings[$service_key . '_markup_fixed'] : ''; 336 348 $pickup_type = isset($service['pickup']) ? $service['pickup'] : 'door'; 349 $row_style = $enabled ? 'background-color: #e7f5e9;' : ''; 337 350 ?> 338 <tr >351 <tr style="<?php echo esc_attr($row_style); ?>" class="woot-service-row <?php echo $enabled ? 'woot-service-enabled' : ''; ?>"> 339 352 <td style="text-align: center; vertical-align: middle;"> 340 353 <input type="checkbox" … … 388 401 style="width: 100%;" /> 389 402 </td> 403 <td> 404 <input type="number" 405 name="<?php echo esc_attr($this->get_field_key($service_key . '_markup_percent')); ?>" 406 id="<?php echo esc_attr($this->get_field_key($service_key . '_markup_percent')); ?>" 407 class="woot-markup-input" 408 data-service="<?php echo esc_attr($service_key); ?>" 409 value="<?php echo esc_attr($markup_percent); ?>" 410 placeholder="0" 411 min="0" 412 step="0.01" 413 style="width: 100%;<?php echo $price_type !== 'quotation' ? ' display: none;' : ''; ?>" /> 414 </td> 415 <td> 416 <input type="number" 417 name="<?php echo esc_attr($this->get_field_key($service_key . '_markup_fixed')); ?>" 418 id="<?php echo esc_attr($this->get_field_key($service_key . '_markup_fixed')); ?>" 419 class="woot-markup-input" 420 data-service="<?php echo esc_attr($service_key); ?>" 421 value="<?php echo esc_attr($markup_fixed); ?>" 422 placeholder="0.00" 423 min="0" 424 step="0.01" 425 style="width: 100%;<?php echo $price_type !== 'quotation' ? ' display: none;' : ''; ?>" /> 426 </td> 390 427 </tr> 391 428 <?php endforeach; ?> 392 429 <?php endif; ?> 430 </tbody> 431 </table> 432 <script> 433 jQuery(function($) { 434 // Toggle row highlight on checkbox change 435 $('.woot-services-table input[type="checkbox"]').on('change', function() { 436 var $row = $(this).closest('tr'); 437 if ($(this).is(':checked')) { 438 $row.css('background-color', '#e7f5e9').addClass('woot-service-enabled'); 439 } else { 440 $row.css('background-color', '').removeClass('woot-service-enabled'); 441 } 442 }); 443 444 // Toggle markup fields visibility based on price type 445 $('.woot-price-type-select').on('change', function() { 446 var serviceKey = $(this).data('service'); 447 var $markupInputs = $('.woot-markup-input[data-service="' + serviceKey + '"]'); 448 if ($(this).val() === 'quotation') { 449 $markupInputs.show(); 450 } else { 451 $markupInputs.hide(); 452 } 453 }); 454 }); 455 </script> 456 </td> 457 </tr> 458 <?php 459 return ob_get_clean(); 460 } 461 462 /** 463 * Validate services table field 464 * 465 * @param string $key 466 * @param mixed $value 467 * @return mixed 468 */ 469 public function validate_services_table_field($key, $value) 470 { 471 return ''; 472 } 473 474 /** 475 * Generate payment fees table HTML 476 * 477 * @param string $key 478 * @param array $data 479 * @return string 480 */ 481 public function generate_payment_fees_table_html($key, $data) 482 { 483 $gateways = WC()->payment_gateways()->payment_gateways(); 484 485 ob_start(); 486 ?> 487 <tr valign="top"> 488 <th scope="row" class="titledesc"> 489 <label><?php echo esc_html($data['title']); ?></label> 490 <?php if (!empty($data['description'])) : ?> 491 <p class="description"><?php echo esc_html($data['description']); ?></p> 492 <?php endif; ?> 493 </th> 494 <td class="forminp"> 495 <table class="woot-payment-fees-table widefat striped"> 496 <thead> 497 <tr> 498 <th style="padding: 8px;"><?php esc_html_e('Payment Method', 'woot-ro'); ?></th> 499 <th style="width: 120px; padding: 8px; white-space: nowrap;"><?php esc_html_e('Adaos %', 'woot-ro'); ?> <?php echo wc_help_tip(__('Percentage markup from order total (subtotal + shipping)', 'woot-ro')); ?></th> 500 <th style="width: 120px; padding: 8px; white-space: nowrap;"><?php esc_html_e('Adaos Fix', 'woot-ro'); ?> <?php echo wc_help_tip(__('Fixed amount added to the order', 'woot-ro')); ?></th> 501 </tr> 502 </thead> 503 <tbody> 504 <?php foreach ($gateways as $gateway) : 505 if ($gateway->enabled !== 'yes') continue; 506 $fee_percent = isset($this->instance_settings[$gateway->id . '_fee_percent']) ? $this->instance_settings[$gateway->id . '_fee_percent'] : ''; 507 $fee_fixed = isset($this->instance_settings[$gateway->id . '_fee_fixed']) ? $this->instance_settings[$gateway->id . '_fee_fixed'] : ''; 508 ?> 509 <tr> 510 <td style="vertical-align: middle; padding: 8px;"> 511 <strong><?php echo esc_html($gateway->title); ?></strong> 512 </td> 513 <td style="vertical-align: middle; padding: 8px;"> 514 <input type="number" 515 name="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_percent')); ?>" 516 id="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_percent')); ?>" 517 value="<?php echo esc_attr($fee_percent); ?>" 518 placeholder="0" 519 min="0" 520 step="0.01" 521 style="width: 100%;" /> 522 </td> 523 <td style="vertical-align: middle; padding: 8px;"> 524 <input type="number" 525 name="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_fixed')); ?>" 526 id="<?php echo esc_attr($this->get_field_key($gateway->id . '_fee_fixed')); ?>" 527 value="<?php echo esc_attr($fee_fixed); ?>" 528 placeholder="0.00" 529 min="0" 530 step="0.01" 531 style="width: 100%;" /> 532 </td> 533 </tr> 534 <?php endforeach; ?> 393 535 </tbody> 394 536 </table> … … 400 542 401 543 /** 402 * Validate services table field544 * Validate payment fees table field 403 545 * 404 546 * @param string $key … … 406 548 * @return mixed 407 549 */ 408 public function validate_ services_table_field($key, $value)550 public function validate_payment_fees_table_field($key, $value) 409 551 { 410 552 return ''; … … 438 580 public function generate_text_html($key, $data) 439 581 { 440 // Hide service-specific text fields (rendered in table) 441 if (strpos($key, 'service_') === 0 && (strpos($key, '_name') !== false || strpos($key, '_price') !== false)) { 582 // Hide service-specific text/number fields (rendered in table) 583 if (strpos($key, 'service_') === 0 && ( 584 strpos($key, '_name') !== false || 585 strpos($key, '_price') !== false || 586 strpos($key, '_markup_percent') !== false || 587 strpos($key, '_markup_fixed') !== false 588 )) { 442 589 return ''; 443 590 } 591 592 // Hide payment method fee fields (rendered in table) 593 if (strpos($key, '_fee_percent') !== false || strpos($key, '_fee_fixed') !== false) { 594 return ''; 595 } 596 444 597 return parent::generate_text_html($key, $data); 445 598 } … … 630 783 $fallback_price = isset($this->instance_settings[$key . '_price']) 631 784 ? floatval($this->instance_settings[$key . '_price']) 785 : 0; 786 787 $markup_percent = isset($this->instance_settings[$key . '_markup_percent']) 788 ? floatval($this->instance_settings[$key . '_markup_percent']) 789 : 0; 790 791 $markup_fixed = isset($this->instance_settings[$key . '_markup_fixed']) 792 ? floatval($this->instance_settings[$key . '_markup_fixed']) 632 793 : 0; 633 794 … … 651 812 } 652 813 814 // Apply markup only for quotation pricing (percentage first, then fixed) 815 if (!$is_free && $cost > 0 && $price_type === 'quotation') { 816 if ($markup_percent > 0) { 817 $cost = $cost * (1 + $markup_percent / 100); 818 } 819 if ($markup_fixed > 0) { 820 $cost = $cost + $markup_fixed; 821 } 822 } 823 653 824 // Add rate with service metadata 654 825 $this->add_rate(array( … … 963 1134 * 964 1135 * @param string $payment_method_id 1136 * @param float $order_total Order total to calculate percentage from 965 1137 * @return float 966 1138 */ 967 public function get_payment_fee($payment_method_id) 968 { 969 $key = $payment_method_id . '_fee'; 970 return isset($this->instance_settings[$key]) ? floatval($this->instance_settings[$key]) : 0; 1139 public function get_payment_fee($payment_method_id, $order_total = 0) 1140 { 1141 $fee_percent = isset($this->instance_settings[$payment_method_id . '_fee_percent']) 1142 ? floatval($this->instance_settings[$payment_method_id . '_fee_percent']) 1143 : 0; 1144 1145 $fee_fixed = isset($this->instance_settings[$payment_method_id . '_fee_fixed']) 1146 ? floatval($this->instance_settings[$payment_method_id . '_fee_fixed']) 1147 : 0; 1148 1149 $fee = 0; 1150 1151 // Apply percentage first 1152 if ($fee_percent > 0 && $order_total > 0) { 1153 $fee = $order_total * ($fee_percent / 100); 1154 } 1155 1156 // Then add fixed 1157 if ($fee_fixed > 0) { 1158 $fee += $fee_fixed; 1159 } 1160 1161 return $fee; 971 1162 } 972 1163 } -
woot-ro/trunk/languages/woot-ro-ro_RO.po
r3438930 r3440105 4 4 msgid "" 5 5 msgstr "" 6 "Project-Id-Version: Woot.ro 2.1. 2\n"6 "Project-Id-Version: Woot.ro 2.1.3\n" 7 7 "Report-Msgid-Bugs-To: https://woot.ro\n" 8 8 "POT-Creation-Date: 2025-01-13 00:00:00+00:00\n" … … 399 399 msgid "Invalid API keys." 400 400 msgstr "Chei API invalide." 401 402 msgid "Adaos %" 403 msgstr "Adaos %" 404 405 msgid "Adaos Fix" 406 msgstr "Adaos Fix" 407 408 msgid "Payment Method" 409 msgstr "Metodă de plată" 410 411 msgid "Custom name displayed to customers at checkout" 412 msgstr "Nume personalizat afișat clienților la checkout" 413 414 msgid "Optional description shown below the service name" 415 msgstr "Descriere opțională afișată sub numele serviciului" 416 417 msgid "Fixed: use the price you set. Quotation: get real-time price from API" 418 msgstr "Fix: folosește prețul setat. Cotație: obține prețul în timp real din API" 419 420 msgid "Fixed price or fallback price if quotation fails" 421 msgstr "Preț fix sau preț de rezervă dacă cotația eșuează" 422 423 msgid "Percentage markup added to the shipping price" 424 msgstr "Adaos procentual adăugat la prețul de livrare" 425 426 msgid "Fixed amount added to the shipping price" 427 msgstr "Sumă fixă adăugată la prețul de livrare" 428 429 msgid "Percentage markup from order total (subtotal + shipping)" 430 msgstr "Adaos procentual din totalul comenzii (subtotal + livrare)" 431 432 msgid "Fixed amount added to the order" 433 msgstr "Sumă fixă adăugată la comandă" -
woot-ro/trunk/languages/woot-ro.pot
r3438930 r3440105 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Woot.ro 2.1. 2\n"5 "Project-Id-Version: Woot.ro 2.1.3\n" 6 6 "Report-Msgid-Bugs-To: https://woot.ro\n" 7 7 "POT-Creation-Date: 2025-01-13 00:00:00+00:00\n" … … 230 230 msgid "Drop-off at door" 231 231 msgstr "" 232 233 #: includes/shipping/class-woot-shipping-services.php 234 msgid "Adaos %" 235 msgstr "" 236 237 #: includes/shipping/class-woot-shipping-services.php 238 msgid "Adaos Fix" 239 msgstr "" 240 241 #: includes/shipping/class-woot-shipping-services.php 242 msgid "Payment Method" 243 msgstr "" 244 245 #: includes/shipping/class-woot-shipping-services.php 246 msgid "Custom name displayed to customers at checkout" 247 msgstr "" 248 249 #: includes/shipping/class-woot-shipping-services.php 250 msgid "Optional description shown below the service name" 251 msgstr "" 252 253 #: includes/shipping/class-woot-shipping-services.php 254 msgid "Fixed: use the price you set. Quotation: get real-time price from API" 255 msgstr "" 256 257 #: includes/shipping/class-woot-shipping-services.php 258 msgid "Fixed price or fallback price if quotation fails" 259 msgstr "" 260 261 #: includes/shipping/class-woot-shipping-services.php 262 msgid "Percentage markup added to the shipping price" 263 msgstr "" 264 265 #: includes/shipping/class-woot-shipping-services.php 266 msgid "Fixed amount added to the shipping price" 267 msgstr "" 268 269 #: includes/shipping/class-woot-shipping-services.php 270 msgid "Percentage markup from order total (subtotal + shipping)" 271 msgstr "" 272 273 #: includes/shipping/class-woot-shipping-services.php 274 msgid "Fixed amount added to the order" 275 msgstr "" -
woot-ro/trunk/woot.php
r3438930 r3440105 17 17 * Plugin URI: https://woot.ro 18 18 * Description: Integrates all popular couriers in Romania, providing a one-stop solution for all your delivery needs 19 * Version: 2.1. 219 * Version: 2.1.3 20 20 * Author: Woot.ro 21 21 * Author URI: https://woot.ro … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('WOOT_VERSION', '2.1. 2');38 define('WOOT_VERSION', '2.1.3'); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.