Plugin Directory

Changeset 2521227


Ignore:
Timestamp:
04/26/2021 02:06:19 AM (5 years ago)
Author:
delyva
Message:

1.1.1 - added volumetric weight or actual weight consideration

Location:
delyvax/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • delyvax/trunk/delyvax.php

    r2517977 r2521227  
    44    Plugin URI: https://delyva.com/solutions
    55    description: The official DelyvaX plugin helps store owners to integrate WooCommerce with [DelyvaX](https://delyva.com/solutions) for seamless service comparison and order processing.
    6     Version: 1.1.0
     6    Version: 1.1.1
    77    Author: DelyvaX
    88    Author URI: https://delyva.com/solutions
  • delyvax/trunk/functions.php

    r2517977 r2521227  
    424424      $inventories = array();
    425425      $total_weight = 0;
     426      $total_dimension = 0;
    426427      $total_price = 0;
    427428      $order_notes = '';
     
    514515
    515516                  $total_weight = $total_weight + ($product->get_weight()*$quantity);
     517
     518                  $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width()))
     519                        * $this->defaultDimension($this->dimensionToCm($product->get_length()))
     520                        * $this->defaultDimension($this->dimensionToCm($product->get_height())));
     521
    516522                  $total_price = $total_price + $total;
    517523
     
    589595
    590596              $total_weight = $total_weight + ($product->get_weight()*$quantity);
     597
     598              $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width()))
     599                    * $this->defaultDimension($this->dimensionToCm($product->get_length()))
     600                    * $this->defaultDimension($this->dimensionToCm($product->get_height())));
     601
    591602              $total_price = $total_price + $total;
    592603
     
    676687      );
    677688
     689      //
     690
     691      //calculate volumetric weight
     692      $total_actual_weight = $total_weight;
     693
     694      if($total_dimension > 0)
     695      {
     696          if($volumetric_constant == 1000)
     697          {
     698              $total_volumetric_weight = $total_dimension/1000;
     699          }else if($volumetric_constant == 6000)
     700          {
     701              $total_volumetric_weight = $total_dimension/6000;
     702          }else {
     703              $total_volumetric_weight = $total_dimension/5000;
     704          }
     705      }else {
     706          $total_volumetric_weight = $total_actual_weight;
     707      }
     708
     709      if($weight_option == 'ACTUAL')
     710      {
     711          $total_weight = $total_actual_weight;
     712      }else if($weight_option == 'VOL')
     713      {
     714          $total_weight = $total_volumetric_weight;
     715      }else {
     716          if($total_actual_weight > $total_volumetric_weight)
     717          {
     718              $total_weight = $total_actual_weight;
     719          }else {
     720              $total_weight = $total_volumetric_weight;
     721          }
     722      }
     723      //
     724
    678725      $weight = array(
    679726        "unit" => "kg",
     
    906953
    907954                                  $total_weight = $total_weight + ($product->get_weight()*$quantity);
     955
     956                                  $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width()))
     957                                        * $this->defaultDimension($this->dimensionToCm($product->get_length()))
     958                                        * $this->defaultDimension($this->dimensionToCm($product->get_height())));
     959
    908960                                  $total_price = $total_price + $total;
    909961
  • delyvax/trunk/includes/delyvax-shipping.php

    r2517977 r2521227  
    152152                'description' => __( 'Default order - package item type. e.g. DOCUMENT / PARCEL / FOOD / PACKAGE.' ),
    153153            ),
    154             'task_item_type' => array(
    155                 'title'     => __( 'Default Task - Item type', 'delyvax' ),
    156                 'type' => 'text',
    157                 'default' => __('0', 'delyvax'),
    158                 'id' => 'delyvax_task_item_type',
    159                 'description' => __( 'Default task - package item type. e.g. DOCUMENT / PARCEL / FOOD / PACKAGE.' ),
    160             ),
    161             'split_tasks' => array(
    162                 'title'     => __( 'Fulfilment by vendors', 'delyvax' ),
    163                 'id'        => 'delyvax_split_tasks',
    164                 'description'   => __( 'Create tasks and assign to vendors by ext id type and ext id', 'delyvax' ),
    165                 'type'      => 'checkbox',
    166                 'default'   => ''
    167             ),
    168             'ext_id_type' => array(
    169                 'title'     => __( 'Personnel External ID Type', 'delyvax' ),
    170                 'type' => 'text',
    171                 'default'   => '',
    172                 'id'        => 'delyvax_ext_id_type',
    173                 'description'   => __( 'Personnel External ID Type. e.g. dokan', 'delyvax' ),
    174             ),
    175             'pickup_minutes' => array(
    176                 'title'     => __( 'Fulfilment minutes before delivery', 'delyvax' ),
    177                 'type' => 'text',
    178                 'default' => __('0', 'delyvax'),
    179                 'id' => 'delyvax_processing_hours',
    180                 'description' => __( 'Number of minutes before delivery. e.g. 30 - 30 minutes befor delivery time; 60 - 60 minutes befor delivery time.' ),
    181             ),
     154            'weight_option' => array(
     155                'title'     => __( 'Weight consideration', 'delyvax' ),
     156                'type' => 'text',
     157                'default' => __('BEST', 'delyvax'),
     158                'id' => 'delyvax_item_type',
     159                'description' => __( 'e.g. BEST-Whichever is higher / ACTUAL-Actual weight / VOL-Volumetric Weight.' ),
     160            ),
     161            'volumetric_constant' => array(
     162                'title'     => __( 'Volumetric weight constant', 'delyvax' ),
     163                'type' => 'text',
     164                'default' => __('5000', 'delyvax'),
     165                'id' => 'delyvax_item_type',
     166                'description' => __( 'e.g. 1000 / 5000 / 6000.' ),
     167            ),
     168            // 'task_item_type' => array(
     169            //     'title'      => __( 'Default Task - Item type', 'delyvax' ),
     170            //     'type' => 'text',
     171            //     'default' => __('0', 'delyvax'),
     172            //     'id' => 'delyvax_task_item_type',
     173            //     'description' => __( 'Default task - package item type. e.g. DOCUMENT / PARCEL / FOOD / PACKAGE.' ),
     174            // ),
     175            // 'split_tasks' => array(
     176            //     'title'      => __( 'Fulfilment by vendors', 'delyvax' ),
     177            //     'id'         => 'delyvax_split_tasks',
     178            //     'description'    => __( 'Create tasks and assign to vendors by ext id type and ext id', 'delyvax' ),
     179            //     'type'       => 'checkbox',
     180            //     'default'    => ''
     181            // ),
     182            // 'ext_id_type' => array(
     183            //     'title'      => __( 'Personnel External ID Type', 'delyvax' ),
     184            //     'type' => 'text',
     185            //     'default'    => '',
     186            //     'id'         => 'delyvax_ext_id_type',
     187            //     'description'    => __( 'Personnel External ID Type. e.g. dokan', 'delyvax' ),
     188            // ),
     189            // 'pickup_minutes' => array(
     190            //     'title'      => __( 'Fulfilment minutes before delivery', 'delyvax' ),
     191            //     'type' => 'text',
     192            //     'default' => __('0', 'delyvax'),
     193            //     'id' => 'delyvax_processing_hours',
     194            //     'description' => __( 'Number of minutes before delivery. e.g. 30 - 30 minutes befor delivery time; 60 - 60 minutes befor delivery time.' ),
     195            // ),
    182196            // 'api_webhook_key' => array(
    183197            //     'title' => __('API API Webhook Key', 'delyvax'),
     
    232246
    233247            $total_weight = 0;
     248            $total_dimension = 0;
     249            $total_volumetric_weight = 0;
    234250
    235251            if (defined('WOOCS_VERSION')) {
     
    289305
    290306                    $total_weight = $total_weight + $this->weightToKg($product->get_weight());
     307
     308                    $total_dimension = $total_dimension + ($this->defaultDimension($this->dimensionToCm($product->get_width()))
     309                          * $this->defaultDimension($this->dimensionToCm($product->get_length()))
     310                          * $this->defaultDimension($this->dimensionToCm($product->get_height())));
    291311                }
    292312            }
     
    321341            $store_country = $split_country[0];
    322342            $store_state   = $split_country[1];
     343
     344            $weight_option = $settings['weight_option'] ?? 'BEST';
     345            $volumetric_constant = $settings['volumetric_constant'] ?? '5000';
    323346
    324347            if(function_exists(dokan_get_seller_id_by_order) && function_exists(dokan_get_store_info))
     
    377400            );
    378401
     402            //calculate volumetric weight
     403            $total_actual_weight = $total_weight;
     404
     405            if($total_dimension > 0)
     406            {
     407                if($volumetric_constant == 1000)
     408                {
     409                    $total_volumetric_weight = $total_dimension/1000;
     410                }else if($volumetric_constant == 6000)
     411                {
     412                    $total_volumetric_weight = $total_dimension/6000;
     413                }else {
     414                    $total_volumetric_weight = $total_dimension/5000;
     415                }
     416            }else {
     417                $total_volumetric_weight = $total_actual_weight;
     418            }
     419
     420            if($weight_option == 'ACTUAL')
     421            {
     422                $total_weight = $total_actual_weight;
     423            }else if($weight_option == 'VOL')
     424            {
     425                $total_weight = $total_volumetric_weight;
     426            }else {
     427                if($total_actual_weight > $total_volumetric_weight)
     428                {
     429                    $total_weight = $total_actual_weight;
     430                }else {
     431                    $total_weight = $total_volumetric_weight;
     432                }
     433            }
     434            //
     435
    379436            //
    380437            $weight = array(
  • delyvax/trunk/readme.txt

    r2517977 r2521227  
    44Requires at least: 5.4
    55Tested up to: 5.7
    6 Stable tag: 1.1.0
     6Stable tag: 1.1.1
    77Requires PHP: 7.2
    88License: GPLv3
     
    3030== Changelog ==
    3131
    32 = 1.1.0 - April 19 2022 = Bug fixes, and improvements to comply with Wordpress standards.
     32= 1.1.1 - April 26 2021 = Added support for volumetric or actual weight consideration.
     33= 1.1.0 - April 19 2021 = Bug fixes, and improvements to comply with Wordpress standards.
    3334= 1.0.0 - August 13 2020 = Initial Release.
Note: See TracChangeset for help on using the changeset viewer.