Plugin Directory

Changeset 2854047


Ignore:
Timestamp:
01/25/2023 05:29:40 AM (3 years ago)
Author:
delyva
Message:

v1.1.42

Location:
delyvax/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • delyvax/trunk/delyvax.php

    r2850327 r2854047  
    44    Plugin URI: https://delyva.com
    55    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.41
     6    Version: 1.1.42
    77    Author: Delyva
    88    Author URI: https://delyva.com
     
    1313    defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    1414    define('DELYVAX_API_ENDPOINT', 'https://api.delyva.app/');
    15     define('DELYVAX_PLUGIN_VERSION', '1.1.41');
     15    define('DELYVAX_PLUGIN_VERSION', '1.1.42');
    1616
    1717    require_once plugin_dir_path(__FILE__) . 'functions.php';
  • delyvax/trunk/includes/delyvax-shipping.php

    r2833369 r2854047  
    55
    66  class DelyvaX_Shipping_Method extends WC_Shipping_Method {
     7
    78
    89      /**
     
    2627          $this->enabled = isset($this->settings['enabled']) ? $this->settings['enabled'] : 'yes';
    2728          $this->title = isset($this->settings['title']) ? $this->settings['title'] : __('DelyvaX', 'delyvax');
     29              $this->control_discount = 0;
    2830          add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
    2931      }
     
    315317                'description' => __( 'Formula, shipping cost = shipping price + % rate + flat rate' ),
    316318            ),
     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            ),
    317325            'rate_adjustment_type' => array(
    318326                'title' => __('Rate Adjustment Type ("discount"/"markup")', 'delyvax'),
     
    473481                for ($i = 0; $i < $item["quantity"]; $i++) {
    474482                    $items[] = array(
    475                         "actual_weight" => $this->weightToKg($product->get_weight()),
     483                        "actual_weight" => $this->defaultWeight($this->weightToKg($product->get_weight())),
    476484                        "height" => $this->defaultDimension($this->dimensionToCm($product->get_height())),
    477485                        "width" => $this->defaultDimension($this->dimensionToCm($product->get_width())),
     
    482490                    );
    483491
    484                     $total_weight = $total_weight + $product->get_weight();
     492                    $total_weight = $total_weight + $this->defaultWeight($this->weightToKg($product->get_weight()));
    485493
    486494                    $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width()))
     
    648656
    649657            //calculate volumetric weight
    650             $total_actual_weight = $this->weightToKg($total_weight);
     658            $total_actual_weight = $this->defaultWeight($this->weightToKg($total_weight));
    651659            $total_weight = $total_actual_weight;
    652660
     
    700708            }
    701709
    702             $services = $rates['services'];
    703 
    704             if(isset($services))
    705             {
     710            if(isset($rates['services']))
     711            {
     712                $services = $rates['services'];
    706713                if(sizeof($services) > 0)
    707714                {
     
    798805                              }
    799806
     807                              //convert currency
     808                              if($cost > 0)
     809                              {
     810                                    $cost = $cost * $settings['rate_currency_conversion'] ?? 1;
     811                              }
     812
    800813                                        $service_label = $shipper['service']['name'];
    801814                                        $service_label = str_replace('(DROP)', '', $service_label);
     
    809822                              }
    810823
    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'];
    813827
    814828                              $rate = array(
     
    844858        {
    845859            $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                    }
    854871                }
    855872            }
     
    861878        {
    862879            $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                    }
    873893                }
    874894            }
     
    891911        protected function setDiscountForItem($count)
    892912        {
    893             $this->discount_for_item = $count;
     913            if($this->control_discount && $count > 0)
     914            {
     915                $this->discount_for_item = $count;
     916            }
    894917        }
    895918
    896919        protected function getDiscountForItem()
    897920        {
    898             return $this->discount_for_item;
     921            if($this->control_discount)
     922            {
     923                return $this->discount_for_item;
     924            }
    899925        }
    900926
    901927        protected function addControlDiscount($val)
    902928        {
    903             $this->control_discount += $val;
     929            if($this->control_discount && $val > 0)
     930            {
     931                $this->control_discount += $val;
     932            }else {
     933                return 0;
     934            }
    904935        }
    905936
     
    911942            return $price;
    912943        }
    913   }
     944    }
    914945}
  • delyvax/trunk/readme.txt

    r2850327 r2854047  
    44Requires at least: 5.4
    55Tested up to: 6.1
    6 Stable tag: 1.1.39
     6Stable tag: 1.1.42
    77Requires PHP: 7.2
    88License: GPLv3
     
    3232
    3333== Changelog ==
     34
     35= 1.1.42 =
     36*Release Date - 19th January 2023*
     37
     38* Add currency conversion rate for live checkout shipping rates.
    3439
    3540= 1.1.41 =
Note: See TracChangeset for help on using the changeset viewer.