Changeset 2854047
- Timestamp:
- 01/25/2023 05:29:40 AM (3 years ago)
- Location:
- delyvax/trunk
- Files:
-
- 3 edited
-
delyvax.php (modified) (2 diffs)
-
includes/delyvax-shipping.php (modified) (13 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
delyvax/trunk/delyvax.php
r2850327 r2854047 4 4 Plugin URI: https://delyva.com 5 5 description: The official Delyva plugin helps store owners to integrate WooCommerce with [Delyva](https://delyva.com) for seamless service comparison and order processing. 6 Version: 1.1.4 16 Version: 1.1.42 7 7 Author: Delyva 8 8 Author URI: https://delyva.com … … 13 13 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 14 14 define('DELYVAX_API_ENDPOINT', 'https://api.delyva.app/'); 15 define('DELYVAX_PLUGIN_VERSION', '1.1.4 1');15 define('DELYVAX_PLUGIN_VERSION', '1.1.42'); 16 16 17 17 require_once plugin_dir_path(__FILE__) . 'functions.php'; -
delyvax/trunk/includes/delyvax-shipping.php
r2833369 r2854047 5 5 6 6 class DelyvaX_Shipping_Method extends WC_Shipping_Method { 7 7 8 8 9 /** … … 26 27 $this->enabled = isset($this->settings['enabled']) ? $this->settings['enabled'] : 'yes'; 27 28 $this->title = isset($this->settings['title']) ? $this->settings['title'] : __('DelyvaX', 'delyvax'); 29 $this->control_discount = 0; 28 30 add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options')); 29 31 } … … 315 317 'description' => __( 'Formula, shipping cost = shipping price + % rate + flat rate' ), 316 318 ), 319 'rate_currency_conversion' => array( 320 'title' => __('Currency Conversion Rate', 'delyvax'), 321 'type' => 'text', 322 'default' => __('1', 'delyvax'), 323 'id' => 'delyvax_rate_rate_currency_conversion' 324 ), 317 325 'rate_adjustment_type' => array( 318 326 'title' => __('Rate Adjustment Type ("discount"/"markup")', 'delyvax'), … … 473 481 for ($i = 0; $i < $item["quantity"]; $i++) { 474 482 $items[] = array( 475 "actual_weight" => $this-> weightToKg($product->get_weight()),483 "actual_weight" => $this->defaultWeight($this->weightToKg($product->get_weight())), 476 484 "height" => $this->defaultDimension($this->dimensionToCm($product->get_height())), 477 485 "width" => $this->defaultDimension($this->dimensionToCm($product->get_width())), … … 482 490 ); 483 491 484 $total_weight = $total_weight + $ product->get_weight();492 $total_weight = $total_weight + $this->defaultWeight($this->weightToKg($product->get_weight())); 485 493 486 494 $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width())) … … 648 656 649 657 //calculate volumetric weight 650 $total_actual_weight = $this-> weightToKg($total_weight);658 $total_actual_weight = $this->defaultWeight($this->weightToKg($total_weight)); 651 659 $total_weight = $total_actual_weight; 652 660 … … 700 708 } 701 709 702 $services = $rates['services']; 703 704 if(isset($services)) 705 { 710 if(isset($rates['services'])) 711 { 712 $services = $rates['services']; 706 713 if(sizeof($services) > 0) 707 714 { … … 798 805 } 799 806 807 //convert currency 808 if($cost > 0) 809 { 810 $cost = $cost * $settings['rate_currency_conversion'] ?? 1; 811 } 812 800 813 $service_label = $shipper['service']['name']; 801 814 $service_label = str_replace('(DROP)', '', $service_label); … … 809 822 } 810 823 811 $service_code = $shipper['service']['serviceCompany']['companyCode'] ? $shipper['service']['serviceCompany']['companyCode'] : $shipper['service']['code']; 812 824 // $service_code = $shipper['service']['serviceCompany']['companyCode'] ? $shipper['service']['serviceCompany']['companyCode'] : $shipper['service']['code']; 825 826 $service_code = $shipper['service']['code']; 813 827 814 828 $rate = array( … … 844 858 { 845 859 $weight_unit = get_option('woocommerce_weight_unit'); 846 // convert other unit into kg 847 if ($weight_unit != 'kg') { 848 if ($weight_unit == 'g') { 849 return $weight * 0.001; 850 } else if ($weight_unit == 'lbs') { 851 return $weight * 0.453592; 852 } else if ($weight_unit == 'oz') { 853 return $weight * 0.0283495; 860 if($weight > 0) 861 { 862 // convert other unit into kg 863 if ($weight_unit != 'kg') { 864 if ($weight_unit == 'g') { 865 return $weight * 0.001; 866 } else if ($weight_unit == 'lbs') { 867 return $weight * 0.453592; 868 } else if ($weight_unit == 'oz') { 869 return $weight * 0.0283495; 870 } 854 871 } 855 872 } … … 861 878 { 862 879 $dimension_unit = get_option('woocommerce_dimension_unit'); 863 // convert other units into cm 864 if ($dimension_unit != 'cm') { 865 if ($dimension_unit == 'm') { 866 return $length * 100; 867 } else if ($dimension_unit == 'mm') { 868 return $length * 0.1; 869 } else if ($dimension_unit == 'in') { 870 return $length * 2.54; 871 } else if ($dimension_unit == 'yd') { 872 return $length * 91.44; 880 if($length > 0) 881 { 882 // convert other units into cm 883 if ($dimension_unit != 'cm') { 884 if ($dimension_unit == 'm') { 885 return $length * 100; 886 } else if ($dimension_unit == 'mm') { 887 return $length * 0.1; 888 } else if ($dimension_unit == 'in') { 889 return $length * 2.54; 890 } else if ($dimension_unit == 'yd') { 891 return $length * 91.44; 892 } 873 893 } 874 894 } … … 891 911 protected function setDiscountForItem($count) 892 912 { 893 $this->discount_for_item = $count; 913 if($this->control_discount && $count > 0) 914 { 915 $this->discount_for_item = $count; 916 } 894 917 } 895 918 896 919 protected function getDiscountForItem() 897 920 { 898 return $this->discount_for_item; 921 if($this->control_discount) 922 { 923 return $this->discount_for_item; 924 } 899 925 } 900 926 901 927 protected function addControlDiscount($val) 902 928 { 903 $this->control_discount += $val; 929 if($this->control_discount && $val > 0) 930 { 931 $this->control_discount += $val; 932 }else { 933 return 0; 934 } 904 935 } 905 936 … … 911 942 return $price; 912 943 } 913 }944 } 914 945 } -
delyvax/trunk/readme.txt
r2850327 r2854047 4 4 Requires at least: 5.4 5 5 Tested up to: 6.1 6 Stable tag: 1.1. 396 Stable tag: 1.1.42 7 7 Requires PHP: 7.2 8 8 License: GPLv3 … … 32 32 33 33 == Changelog == 34 35 = 1.1.42 = 36 *Release Date - 19th January 2023* 37 38 * Add currency conversion rate for live checkout shipping rates. 34 39 35 40 = 1.1.41 =
Note: See TracChangeset
for help on using the changeset viewer.