Plugin Directory

Changeset 3442253


Ignore:
Timestamp:
01/19/2026 07:21:17 AM (2 months ago)
Author:
enituretechnology
Message:

3.3.11 - 2026-01-19

  • Update: Added a caching mechanism to efficiently handle multiple identical quote requests and reduce redundant API calls.
  • Update: Updated shipment logic to treat virtual products as single-shipment cases instead of multi-shipment cases in both cart and checkout.
  • Update: Added changes to display accessorial quote combinations correctly in multi-shipment quotes for better pricing clarity.

Ticket 33342966713

Location:
ltl-freight-quotes-rl-edition
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ltl-freight-quotes-rl-edition/tags/3.3.11/ltl-freight-quotes-rnl-edition.php

    r3394985 r3442253  
    44 * Plugin URI:     https://eniture.com/products/
    55 * Description:    Dynamically retrieves your negotiated shipping rates from R+L Freight and displays the results in the WooCommerce shopping cart.
    6  * Version:        3.3.10
     6 * Version:        3.3.11
    77 * Author:         Eniture Technology
    88 * Author URI:     http://eniture.com/
    99 * Text Domain:    eniture-technology
    10  * License:        GPL version 2 or later - http://www.eniture.com/
    11  * WC requires at least: 6.4
    12  * WC tested up to: 10.2.2
     10 * License:        GPLv2 or later
     11 * Requires Plugins: woocommerce
    1312 */
    1413if (!defined('ABSPATH')) {
  • ltl-freight-quotes-rl-edition/tags/3.3.11/readme.txt

    r3394985 r3442253  
    11=== LTL Freight Quotes - R+L Carriers Edition ===
    22Contributors: enituretechnology
    3 Tags: eniture,R+L,,LTL freight rates,LTL freight quotes, shipping estimates
     3Tags: eniture,R+L,LTL freight rates,LTL freight quotes, shipping estimates
    44Requires at least: 6.4
    5 Tested up to: 6.8
    6 Stable tag: 3.3.10
     5Tested up to: 6.9
     6Stable tag: 3.3.11
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    152152== Changelog ==
    153153
     154= 3.3.11 - 2026-01-19 =
     155* Update: Added a **caching mechanism** to efficiently handle multiple identical quote requests and reduce redundant API calls.
     156* Update: Updated shipment logic to treat **virtual products** as single-shipment cases instead of multi-shipment cases in both cart and checkout.
     157* Update: Added changes to display **accessorial quote combinations** correctly in multi-shipment quotes for better pricing clarity.
     158
    154159= 3.3.10 - 2025-11-07 =
    155160* Fix: Fixed quotes issues that occurred when using Residential and Limited Access Delivery services to ensure accurate and consistent rate generation.
  • ltl-freight-quotes-rl-edition/tags/3.3.11/rnl-carrier-service.php

    r3394985 r3442253  
    456456    function rnl_get_web_quotes($request_data, $rnl_package = [], $loc_id = '')
    457457    {
    458         // Check response from session
    459         $srequest_data = $request_data;
    460         $srequest_data['requestKey'] = "";
    461         $currentData = md5(json_encode($srequest_data));
    462         $requestFromSession = WC()->session->get('previousRequestData');
    463         $requestFromSession = ((is_array($requestFromSession)) && (!empty($requestFromSession))) ? $requestFromSession : array();
    464 
    465         if (isset($requestFromSession[$currentData]) && (!empty($requestFromSession[$currentData]))) {
    466             $this->InstorPickupLocalDelivery = (isset(json_decode($requestFromSession[$currentData])->InstorPickupLocalDelivery) ? json_decode($requestFromSession[$currentData])->InstorPickupLocalDelivery : NULL);
    467 //          Eniture debug mood
    468             do_action("eniture_debug_mood", "Build Query Session (R+L)", http_build_query($request_data));
    469             do_action("eniture_debug_mood", "Quotes Response Session (R+L)", json_decode($requestFromSession[$currentData]));
    470 
    471             return $this->parse_rnl_output($requestFromSession[$currentData], $request_data, $rnl_package, $loc_id);
    472         }
    473 
    474         if (is_array($request_data) && count($request_data) > 0) {
    475             $rnl_curl_obj = new RNL_Curl_Request();
    476             $output = $rnl_curl_obj->rnl_get_curl_response(RNL_FREIGHT_DOMAIN_HITTING_URL . '/index.php', $request_data);
    477 
    478 //          set response in session
     458        if (empty($request_data) || !is_array($request_data)) return [];
     459
     460        // Eniture debug mood
     461        do_action("eniture_debug_mood", "Build Query (R+L)", http_build_query($request_data));
     462
     463        $cachable_data = $this->create_cachable_data($request_data);
     464        $cache_key = $this->create_cache_key($cachable_data);
     465        $cache_response = get_transient($cache_key);
     466
     467        if (false === $cache_response) {
     468            $output = (new RNL_Curl_Request())->rnl_get_curl_response(RNL_FREIGHT_DOMAIN_HITTING_URL . '/index.php', $request_data);
    479469            $response = json_decode($output);
    480             if (isset($response->q) &&
    481                 (empty($response->error))) {
    482 
    483                 $aServicesResult = ((!is_array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel)) ? array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) : $response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel);
    484 
    485                 if (isset($response->autoResidentialSubscriptionExpired) &&
    486                     ($response->autoResidentialSubscriptionExpired == 1)) {
    487                     $flag_api_response = "no";
    488                     $srequest_data['residential_detecion_flag'] = $flag_api_response;
    489                     $currentData = md5(json_encode($srequest_data));
     470
     471            do_action("eniture_debug_mood", "Quotes Request (R+L)", $request_data);
     472            do_action("eniture_debug_mood", "Quotes Response (R+L)", $response);
     473
     474            if (isset($response->q) && empty($response->error)) {
     475                $aServicesResult = !is_array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) ? array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) : $response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel;
     476
     477                if (isset($response->autoResidentialSubscriptionExpired) && $response->autoResidentialSubscriptionExpired == 1) {
     478                    $srequest_data['residential_detecion_flag'] = 'no';
    490479                }
    491480
    492481                if (is_array($aServicesResult) && count($aServicesResult) > 0) {
    493 
    494                     $requestFromSession[$currentData] = $output;
    495                     WC()->session->set('previousRequestData', $requestFromSession);
     482                    set_transient($cache_key, $output, 12 * HOUR_IN_SECONDS);
    496483                }
    497484            }
    498 
    499             $response = json_decode($output);
    500             $this->InstorPickupLocalDelivery = (isset($response->InstorPickupLocalDelivery) ? $response->InstorPickupLocalDelivery : NULL);
    501 
    502 //          Eniture debug mood
    503             do_action("eniture_debug_mood", "Quotes Response (R+L)", json_decode($output));
    504 
    505             return $this->parse_rnl_output($output, $request_data, $rnl_package, $loc_id);
    506         }
     485        } else {
     486            $response = json_decode($cache_response);
     487        }
     488
     489        $this->InstorPickupLocalDelivery = isset($response->InstorPickupLocalDelivery) && !empty($response->InstorPickupLocalDelivery) ? $response->InstorPickupLocalDelivery : array();
     490
     491        return $this->parse_rnl_output($cache_response, $request_data, $rnl_package, $loc_id);
    507492    }
    508493
     
    537522        if (isset($this->quote_settings['indirect_deliveries_enabled']) && $this->quote_settings['indirect_deliveries_enabled'] != 'yes' && !$is_direct) {
    538523            // Eniture debug mood
    539             do_action("eniture_debug_mood", "Indirect Deliveries Disabled (R+L)");
     524            do_action("eniture_debug_mood", "Indirect Deliveries Disabled (R+L)", json_encode($result));
    540525
    541526            return [];
     
    1014999        return array_merge($excluded, $this->en_accessorial_excluded);
    10151000    }
     1001
     1002    function create_cachable_data($request_data)
     1003    {
     1004        $cachable_data = [];
     1005        $cachable_data['receiverCity'] = $request_data['receiverCity'];
     1006        $cachable_data['receiverState'] = $request_data['receiverState'];
     1007        $cachable_data['receiverZip'] = $request_data['receiverZip'];
     1008        $cachable_data['receiverCountryCode'] = $request_data['receiverCountryCode'];
     1009
     1010        $cachable_data['senderCity'] = $request_data['senderCity'];
     1011        $cachable_data['senderState'] = $request_data['senderState'];
     1012        $cachable_data['senderZip'] = $request_data['senderZip'];
     1013        $cachable_data['senderCountryCode'] = $request_data['senderCountryCode'];
     1014
     1015        $cachable_data['accessorials'] = $request_data['accessorials'];
     1016        $cachable_data['commdityDetails'] = $request_data['commdityDetails'];
     1017        $cachable_data['handlingUnitWeight'] = $request_data['handlingUnitWeight'];
     1018        $cachable_data['maxWeightPerHandlingUnit'] = $request_data['maxWeightPerHandlingUnit'];
     1019        $cachable_data['palletCode'] = isset($request_data['palletCode']) ? $request_data['palletCode'] : '';
     1020        $cachable_data['palletWeight'] = isset($request_data['palletWeight']) ? $request_data['palletWeight'] : '';
     1021        $cachable_data['holdAtTerminal'] = isset($request_data['holdAtTerminal']) ? $request_data['holdAtTerminal'] : '';
     1022
     1023        $cachable_data['doNesting'] = $request_data['doNesting'];
     1024        $cachable_data['modifyShipmentDateTime'] = $request_data['modifyShipmentDateTime'];
     1025        $cachable_data['suspend_residential'] = $request_data['suspend_residential'];
     1026        $cachable_data['residential_detecion_flag'] = $request_data['residential_detecion_flag'];
     1027        $cachable_data['liftGateWithAutoResidentials'] = isset($request_data['liftGateWithAutoResidentials']) ? $request_data['liftGateWithAutoResidentials'] : '';
     1028        $cachable_data['internationalResidential'] = isset($request_data['internationalResidential']) ? $request_data['internationalResidential'] : '';
     1029        $cachable_data['liftgateDelivery'] = isset($request_data['liftgateDelivery']) ? $request_data['liftgateDelivery'] : '';
     1030        $cachable_data['residentialDelivery'] = isset($request_data['residentialDelivery']) ? $request_data['residentialDelivery'] : '';
     1031        $cachable_data['residentialPickup'] = isset($request_data['residentialPickup']) ? $request_data['residentialPickup'] : '';
     1032        $cachable_data['liftgatePickup'] = isset($request_data['liftgatePickup']) ? $request_data['liftgatePickup'] : '';
     1033        $cachable_data['InstorPickupLocalDelivery'] = isset($request_data['InstorPickupLocalDelivery']) ? $request_data['InstorPickupLocalDelivery'] : '';
     1034
     1035        if (isset($request_data['autoResidentials']) && $request_data['autoResidentials'] == 1) {
     1036            $cachable_data['autoResidentials'] = $request_data['autoResidentials'];
     1037            $cachable_data['addressLine'] = $request_data['addressLine'];
     1038            $cachable_data['addressLine2'] = (isset($request_data['addressLine2'])) ? $request_data['addressLine2'] : '';
     1039            $cachable_data['defaultRADAddressType'] = $request_data['defaultRADAddressType'];
     1040            $cachable_data['defaultRADWithoutStreetAddress'] = $request_data['defaultRADWithoutStreetAddress'];
     1041            $cachable_data['poboxAddressValidation'] = $request_data['poboxAddressValidation'];
     1042        }
     1043
     1044        if (isset($request_data['standardPackaging']) && $request_data['standardPackaging'] == 1) {
     1045            $cachable_data['standardPackaging'] = $request_data['standardPackaging'];
     1046            $cachable_data['pallet'] = $request_data['pallet'];
     1047        }
     1048
     1049        $cachable_data['UserName'] = $request_data['UserName'];
     1050        $cachable_data['Password'] = $request_data['Password'];
     1051        $cachable_data['APIKey'] = $request_data['APIKey'];
     1052        $cachable_data['licence_key'] = $request_data['licence_key'];
     1053
     1054        return $cachable_data;
     1055    }
     1056
     1057    function create_cache_key($request_data) {
     1058        $request_build_query = http_build_query($request_data);
     1059        return md5('eniture_rnl_' . $request_build_query);
     1060    }
    10161061}
  • ltl-freight-quotes-rl-edition/tags/3.3.11/rnl-shipping-class.php

    r3394985 r3442253  
    136136
    137137            /**
    138              * Virtual Products
    139              */
    140             public function en_virtual_products()
    141             {
    142                 global $woocommerce;
    143                 $products = $woocommerce->cart->get_cart();
    144                 $items = $product_name = [];
    145                 foreach ($products as $key => $product_obj) {
    146                     $product = $product_obj['data'];
    147                     $is_virtual = $product->get_virtual();
    148 
    149                     if ($is_virtual == 'yes') {
    150                         $attributes = $product->get_attributes();
    151                         $product_qty = $product_obj['quantity'];
    152                         $product_title = str_replace(array("'", '"'), '', $product->get_title());
    153                         $product_name[] = $product_qty . " x " . $product_title;
    154 
    155                         $meta_data = [];
    156                         if (!empty($attributes)) {
    157                             foreach ($attributes as $attr_key => $attr_value) {
    158                                 $meta_data[] = [
    159                                     'key' => $attr_key,
    160                                     'value' => $attr_value,
    161                                 ];
    162                             }
    163                         }
    164 
    165                         $items[] = [
    166                             'id' => $product_obj['product_id'],
    167                             'name' => $product_title,
    168                             'quantity' => $product_qty,
    169                             'price' => $product->get_price(),
    170                             'weight' => 0,
    171                             'length' => 0,
    172                             'width' => 0,
    173                             'height' => 0,
    174                             'type' => 'virtual',
    175                             'product' => 'virtual',
    176                             'sku' => $product->get_sku(),
    177                             'attributes' => $attributes,
    178                             'variant_id' => 0,
    179                             'meta_data' => $meta_data,
    180                         ];
    181                     }
    182                 }
    183 
    184                 $virtual_rate = [];
    185 
    186                 if (!empty($items)) {
    187                     $virtual_rate = [
    188                         'id' => 'en_virtual_rate',
    189                         'label' => 'Virtual Quote',
    190                         'cost' => 0,
    191                     ];
    192 
    193                     $virtual_fdo = [
    194                         'plugin_type' => 'ltl',
    195                         'plugin_name' => 'wwe_quests',
    196                         'accessorials' => '',
    197                         'items' => $items,
    198                         'address' => '',
    199                         'handling_unit_details' => '',
    200                         'rate' => $virtual_rate,
    201                     ];
    202 
    203                     $meta_data = [
    204                         'sender_origin' => 'Virtual Product',
    205                         'product_name' => wp_json_encode($product_name),
    206                         'en_fdo_meta_data' => $virtual_fdo,
    207                     ];
    208 
    209                     $virtual_rate['meta_data'] = $meta_data;
    210 
    211                 }
    212 
    213                 return $virtual_rate;
    214             }
    215 
    216             /**
    217138             * Calculate Shipping Rates For R+L
    218139             * @param string $package
     
    353274
    354275                $smallQuotes = $this->en_spq_sort($smallQuotes);
    355 
    356276                $smallQuotes = (is_array($smallQuotes) && (!empty($smallQuotes))) ? reset($smallQuotes) : $smallQuotes;
    357277                $smallMinRate = (is_array($smallQuotes) && (!empty($smallQuotes))) ? current($smallQuotes) : $smallQuotes;
    358 
    359                 // Virtual products
    360                 $virtual_rate = $this->en_virtual_products();
    361278
    362279                //FDO
     
    392309                ($this->quote_settings['limited_access_delivery'] == "yes") ? $this->accessorials[] = "LA" : "";
    393310
    394                 // Virtual products
     311                // Multiple Shipment
    395312                if (count($quotes) > 1 || $smpkgCost > 0) {
    396 
    397                     // Multiple Shipment
    398                     $multi_cost = 0;
    399                     $s_multi_cost = 0;
    400                     $access_multi_cost = 0;
    401                     $hold_at_terminal_fee = 0;
    402                     $_label = "";
    403                     $access_label = [];
    404                     $access_append_label = "";
    405313                    $this->minPrices = array();
    406 
    407314                    $this->quote_settings['shipment'] = "multi_shipment";
    408                     $shipment_numbers = 0;
    409315
    410316                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_LIFT'] = $small_quotes : "";
     
    413319                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_NOTACCESS'] = $small_quotes : "";
    414320                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_HAT'] = $small_quotes : "";
    415 
    416                     // Virtual products
    417                     if (!empty($virtual_rate)) {
    418                         $en_virtual_fdo_meta_data[] = $virtual_rate['meta_data']['en_fdo_meta_data'];
    419                         $virtual_meta_rate['virtual_rate'] = $virtual_rate;
    420                         $this->minPrices['RNL_LIFT'] = isset($this->minPrices['RNL_LIFT']) && !empty($this->minPrices['RNL_LIFT']) ? array_merge($this->minPrices['RNL_LIFT'], $virtual_meta_rate) : $virtual_meta_rate;
    421                         $this->minPrices['RNL_NOTLIFT'] = isset($this->minPrices['RNL_NOTLIFT']) && !empty($this->minPrices['RNL_NOTLIFT']) ? array_merge($this->minPrices['RNL_NOTLIFT'], $virtual_meta_rate) : $virtual_meta_rate;
    422                         $this->minPrices['RNL_ACCESS'] = isset($this->minPrices['RNL_ACCESS']) && !empty($this->minPrices['RNL_ACCESS']) ? array_merge($this->minPrices['RNL_ACCESS'], $virtual_meta_rate) : $virtual_meta_rate;
    423                         $this->minPrices['RNL_NOTACCESS'] = isset($this->minPrices['RNL_NOTACCESS']) && !empty($this->minPrices['RNL_NOTACCESS']) ? array_merge($this->minPrices['RNL_NOTACCESS'], $virtual_meta_rate) : $virtual_meta_rate;
    424                         $this->en_fdo_meta_data_third_party = !empty($this->en_fdo_meta_data_third_party) ? array_merge($this->en_fdo_meta_data_third_party, $en_virtual_fdo_meta_data) : $en_virtual_fdo_meta_data;
    425                         if ($this->quote_settings['HAT_status'] == 'yes') {
    426                             $this->minPrices['RNL_HAT'] = isset($this->minPrices['RNL_HAT']) && !empty($this->minPrices['RNL_HAT']) ? array_merge($this->minPrices['RNL_HAT'], $virtual_meta_rate) : $virtual_meta_rate;
    427                         }
    428                     }
    429321
    430322                    $rates = $this->get_multi_formatted_quotes($quotes, $smpkgCost);
     
    793685
    794686                $pickup_delivery = array(
    795                     'id' => $this->id . ':' . 'in-store-pick-up',
     687                    'id' => 'in-store-pick-up',
    796688                    'cost' => 0,
    797689                    'label' => $label,
     
    817709
    818710                $local_delivery = array(
    819                     'id' => $this->id . ':' . 'local-delivery',
     711                    'id' => 'local-delivery',
    820712                    'cost' => $cost,
    821713                    'label' => $label,
     
    914806            function get_multi_formatted_quotes($quotes, $smpkgCost)
    915807            {
    916                 // Multiple Shipment
    917808                $multi_cost = 0;
    918809                $s_multi_cost = 0;
     
    928819                foreach ($quotes as $ship_key => $q) {
    929820                    if (!empty($q)) {
    930                         $guaranteed_quotes = !empty($q['guaranteed_services_quotes']) ? $q['guaranteed_services_quotes'] : [];
    931821                        unset($q['guaranteed_services_quotes']);
    932822                        $combined_quotes = [];
    933823                        $combined_quotes[] = $q;
    934                         $combined_quotes = array_merge($combined_quotes, array_values($guaranteed_quotes));
    935824
    936825                        $key = "LTL_" . $ship_key;
     
    961850                            $rates = (is_array($quote) && (!empty($quote))) ? $quote : array();
    962851
     852                            if ($this->quote_settings['liftgate_limited_access_delivery'] == 'yes' && empty($simple_quotes)) {
     853                                $lfg_fee = ($this->quote_settings['liftgate_delivery'] != 'yes' && $this->quote_settings['liftgate_resid_delivery'] != 'yes') && isset($rates['surcharges']['LIFT']) ? $rates['surcharges']['LIFT'] : 0;
     854                                $rates['cost'] -= floatval($lfg_fee);
     855
     856                                $simple_quotes = $rates;
     857                            }
     858
    963859                            $this->minPrices['RNL_LIFT' . $unique_id][$key] = $rates;
    964860
     
    972868                                $access_append_label = (isset($limited_access_quotes['append_label'])) ? $limited_access_quotes['append_label'] : "";
    973869
    974                                 // $access_multi_cost += $this->add_handling_fee($access_cost, $handling_fee);
    975870                                $access_multi_cost = $this->add_handling_fee($access_cost, $handling_fee);
    976871                                $this->minPrices['RNL_ACCESS' . $unique_id][$key]['cost'] = $this->add_handling_fee($access_cost, $handling_fee);
     872                                $this->en_fdo_meta_data['RNL_ACCESS' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($access_cost, $handling_fee);
    977873                            }
    978874
     
    986882
    987883                            // Offer lift gate delivery as an option is enabled
    988                             if (isset($this->quote_settings['liftgate_delivery_option']) &&
    989                                 ($this->quote_settings['liftgate_delivery_option'] == "yes") &&
    990                                 (!empty($simple_quotes))) {
     884                            if (((isset($this->quote_settings['liftgate_delivery_option']) &&
     885                                ($this->quote_settings['liftgate_delivery_option'] == "yes")) || $this->quote_settings['liftgate_limited_access_delivery'] == "yes") && !empty($simple_quotes)) {
    991886                                $s_rates = $simple_quotes;
    992887                                $this->minPrices['RNL_NOTLIFT' . $unique_id][$key] = $s_rates;
     
    998893                                $s_label = (isset($s_rates['label_sufex'])) ? $s_rates['label_sufex'] : array();
    999894                                $s_append_label = (isset($s_rates['append_label'])) ? $s_rates['append_label'] : "";
    1000                                 // $s_multi_cost += $this->add_handling_fee($s_cost, $handling_fee);
    1001895                                $s_multi_cost = $this->add_handling_fee($s_cost, $handling_fee);
    1002896                                $this->minPrices['RNL_NOTLIFT' . $unique_id][$key]['cost'] = $this->add_handling_fee($s_cost, $handling_fee);
    1003                             }
    1004 
    1005                             // $multi_cost += $this->add_handling_fee($_cost, $handling_fee);
     897                                $this->en_fdo_meta_data['RNL_NOTLIFT' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($s_cost, $handling_fee);
     898                            }
     899
    1006900                            $multi_cost = $this->add_handling_fee($_cost, $handling_fee);
    1007901                            $this->minPrices['RNL_LIFT' . $unique_id][$key]['cost'] = $this->add_handling_fee($_cost, $handling_fee);
     902                            $this->en_fdo_meta_data['RNL_LIFT' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($_cost, $handling_fee);
    1008903
    1009904                            $shipment_numbers++;
     
    1024919                            $this->arrange_multiship_freight(($multi_cost + $smpkgCost), 'RNL_LIFT' . $unique_id, $_label, $append_label) : "";
    1025920                            // Limited access delivery multi-shipment quotes
    1026                             ($access_multi_cost > 0 || $smpkgCost > 0) ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($access_multi_cost + $smpkgCost), 'RNL_ACCESS' . $unique_id, $access_label, $access_append_label) : "";
     921                            $always_lfg_when_lim_access = $this->quote_settings['liftgate_limited_access_delivery'] == 'yes';
     922                            ($access_multi_cost > 0 || $smpkgCost > 0) && !$always_lfg_when_lim_access ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($access_multi_cost + $smpkgCost), 'RNL_ACCESS' . $unique_id, $access_label, $access_append_label) : "";
    1027923                            // HAT multi-shipment quotes
    1028924                            ($hold_at_terminal_fee > 0) ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($hold_at_terminal_fee + $smpkgCost), 'RNL_HAT', $hat_label, $append_hat_label) : "";
     
    1044940                                        $la_fee = isset($quote['surcharges']['LA']) ? $quote['surcharges']['LA'] : 0;
    1045941
     942                                        $rad_status = isset($quote['label_sufex']) && is_array($quote['label_sufex']) && in_array('R', $quote['label_sufex']);
     943                                        if ($this->quote_settings['liftgate_delivery'] == 'yes' || ($this->quote_settings['liftgate_resid_delivery'] == 'yes' && $rad_status)) {
     944                                            $lg_fee = 0;
     945                                        }
     946
    1046947                                        $shipment_cost += (floatval($lg_fee) +  floatval($la_fee));
    1047948                                        $shipment_cost -= $resi_fee;
     
    1081982                    }
    1082983                }
    1083                
     984
    1084985                $hat_cheapest_rate = [];
    1085986                if (!empty($multi_hat_rates)) {
     
    1090991
    1091992                // Find the cheapest rate for each shipments
     993                $multi_keys = ['RNL_LIFTLTL_', 'RNL_NOTLIFTLTL_', 'RNL_ACCESSLTL_', 'RNL_LIFTACCESSLTL_'];
    1092994                $cheapest_rates = [];
    1093                 foreach ($multi_rates as $key => $rate) {
    1094                     array_multisort(array_column($rate, 'cost'), SORT_ASC, $rate);
    1095                     $cheapest_rates[$key] = $rate[0];
    1096                 }
    1097 
    1098                 $cheapest_rate = [];
     995                $_cost = null;
     996                foreach ($multi_rates as $rate) {
     997                    if (!is_array($rate)) continue;
     998
     999                    foreach ($multi_keys as $multi_key) {
     1000                        foreach ($rate as $rvalue) {
     1001                            if (strpos($rvalue['id'], $multi_key) === false || $_cost == $rvalue['cost']) continue;
     1002                            $_cost = isset($rvalue['cost']) ? $rvalue['cost'] : 0;
     1003
     1004                            $cheapest_rates[$multi_key][] = $rvalue;
     1005                        }
     1006                    }
     1007                }
     1008
     1009                $final_rates = [];
    10991010                $multi_rate_key = '';
    11001011                foreach ($cheapest_rates as $key => $chp_rate) {
    1101                     if (empty($cheapest_rate)) {
    1102                         $cheapest_rate = $chp_rate;
    1103                         $multi_rate_key = $chp_rate['id'];
    1104                     } else {
    1105                         $cheapest_rate['cost'] += floatval($chp_rate['cost']);
    1106                         $this->minPrices[$multi_rate_key]['LTL_' . $key] = reset(array_values($this->minPrices[$chp_rate['id']]));
    1107                         $this->en_fdo_meta_data[$multi_rate_key]['LTL_' . $key] = reset(array_values($this->en_fdo_meta_data[$chp_rate['id']]));
    1108                     }
    1109                 }
    1110 
    1111                 $final_quotes = array_merge(array($cheapest_rate), array($hat_cheapest_rate));
    1112 
    1113                 return $final_quotes;
     1012                    foreach ($chp_rate as $ckey => $crate) {
     1013                        if (!isset($final_rates[$key])) {
     1014                            $final_rates[$key] = $crate;
     1015                            $multi_rate_key = $crate['id'];
     1016                        } else {
     1017                            $final_rates[$key]['cost'] += floatval($crate['cost']);
     1018                            $this->minPrices[$multi_rate_key]['LTL_' . $ckey] = reset(array_values($this->minPrices[$crate['id']]));
     1019                            $this->en_fdo_meta_data[$multi_rate_key]['LTL_' . $ckey] = reset(array_values($this->en_fdo_meta_data[$crate['id']]));
     1020                            unset($this->minPrices[$crate['id']], $this->en_fdo_meta_data[$crate['id']]);
     1021                        }
     1022                    }
     1023                }
     1024
     1025                $final_rates = array_merge($final_rates, array($hat_cheapest_rate));
     1026
     1027                return $final_rates;
    11141028            }
    11151029
  • ltl-freight-quotes-rl-edition/trunk/ltl-freight-quotes-rnl-edition.php

    r3394985 r3442253  
    44 * Plugin URI:     https://eniture.com/products/
    55 * Description:    Dynamically retrieves your negotiated shipping rates from R+L Freight and displays the results in the WooCommerce shopping cart.
    6  * Version:        3.3.10
     6 * Version:        3.3.11
    77 * Author:         Eniture Technology
    88 * Author URI:     http://eniture.com/
    99 * Text Domain:    eniture-technology
    10  * License:        GPL version 2 or later - http://www.eniture.com/
    11  * WC requires at least: 6.4
    12  * WC tested up to: 10.2.2
     10 * License:        GPLv2 or later
     11 * Requires Plugins: woocommerce
    1312 */
    1413if (!defined('ABSPATH')) {
  • ltl-freight-quotes-rl-edition/trunk/readme.txt

    r3394985 r3442253  
    11=== LTL Freight Quotes - R+L Carriers Edition ===
    22Contributors: enituretechnology
    3 Tags: eniture,R+L,,LTL freight rates,LTL freight quotes, shipping estimates
     3Tags: eniture,R+L,LTL freight rates,LTL freight quotes, shipping estimates
    44Requires at least: 6.4
    5 Tested up to: 6.8
    6 Stable tag: 3.3.10
     5Tested up to: 6.9
     6Stable tag: 3.3.11
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    152152== Changelog ==
    153153
     154= 3.3.11 - 2026-01-19 =
     155* Update: Added a **caching mechanism** to efficiently handle multiple identical quote requests and reduce redundant API calls.
     156* Update: Updated shipment logic to treat **virtual products** as single-shipment cases instead of multi-shipment cases in both cart and checkout.
     157* Update: Added changes to display **accessorial quote combinations** correctly in multi-shipment quotes for better pricing clarity.
     158
    154159= 3.3.10 - 2025-11-07 =
    155160* Fix: Fixed quotes issues that occurred when using Residential and Limited Access Delivery services to ensure accurate and consistent rate generation.
  • ltl-freight-quotes-rl-edition/trunk/rnl-carrier-service.php

    r3394985 r3442253  
    456456    function rnl_get_web_quotes($request_data, $rnl_package = [], $loc_id = '')
    457457    {
    458         // Check response from session
    459         $srequest_data = $request_data;
    460         $srequest_data['requestKey'] = "";
    461         $currentData = md5(json_encode($srequest_data));
    462         $requestFromSession = WC()->session->get('previousRequestData');
    463         $requestFromSession = ((is_array($requestFromSession)) && (!empty($requestFromSession))) ? $requestFromSession : array();
    464 
    465         if (isset($requestFromSession[$currentData]) && (!empty($requestFromSession[$currentData]))) {
    466             $this->InstorPickupLocalDelivery = (isset(json_decode($requestFromSession[$currentData])->InstorPickupLocalDelivery) ? json_decode($requestFromSession[$currentData])->InstorPickupLocalDelivery : NULL);
    467 //          Eniture debug mood
    468             do_action("eniture_debug_mood", "Build Query Session (R+L)", http_build_query($request_data));
    469             do_action("eniture_debug_mood", "Quotes Response Session (R+L)", json_decode($requestFromSession[$currentData]));
    470 
    471             return $this->parse_rnl_output($requestFromSession[$currentData], $request_data, $rnl_package, $loc_id);
    472         }
    473 
    474         if (is_array($request_data) && count($request_data) > 0) {
    475             $rnl_curl_obj = new RNL_Curl_Request();
    476             $output = $rnl_curl_obj->rnl_get_curl_response(RNL_FREIGHT_DOMAIN_HITTING_URL . '/index.php', $request_data);
    477 
    478 //          set response in session
     458        if (empty($request_data) || !is_array($request_data)) return [];
     459
     460        // Eniture debug mood
     461        do_action("eniture_debug_mood", "Build Query (R+L)", http_build_query($request_data));
     462
     463        $cachable_data = $this->create_cachable_data($request_data);
     464        $cache_key = $this->create_cache_key($cachable_data);
     465        $cache_response = get_transient($cache_key);
     466
     467        if (false === $cache_response) {
     468            $output = (new RNL_Curl_Request())->rnl_get_curl_response(RNL_FREIGHT_DOMAIN_HITTING_URL . '/index.php', $request_data);
    479469            $response = json_decode($output);
    480             if (isset($response->q) &&
    481                 (empty($response->error))) {
    482 
    483                 $aServicesResult = ((!is_array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel)) ? array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) : $response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel);
    484 
    485                 if (isset($response->autoResidentialSubscriptionExpired) &&
    486                     ($response->autoResidentialSubscriptionExpired == 1)) {
    487                     $flag_api_response = "no";
    488                     $srequest_data['residential_detecion_flag'] = $flag_api_response;
    489                     $currentData = md5(json_encode($srequest_data));
     470
     471            do_action("eniture_debug_mood", "Quotes Request (R+L)", $request_data);
     472            do_action("eniture_debug_mood", "Quotes Response (R+L)", $response);
     473
     474            if (isset($response->q) && empty($response->error)) {
     475                $aServicesResult = !is_array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) ? array($response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel) : $response->q->soapBody->GetRateQuoteResponse->GetRateQuoteResult->Result->ServiceLevels->ServiceLevel;
     476
     477                if (isset($response->autoResidentialSubscriptionExpired) && $response->autoResidentialSubscriptionExpired == 1) {
     478                    $srequest_data['residential_detecion_flag'] = 'no';
    490479                }
    491480
    492481                if (is_array($aServicesResult) && count($aServicesResult) > 0) {
    493 
    494                     $requestFromSession[$currentData] = $output;
    495                     WC()->session->set('previousRequestData', $requestFromSession);
     482                    set_transient($cache_key, $output, 12 * HOUR_IN_SECONDS);
    496483                }
    497484            }
    498 
    499             $response = json_decode($output);
    500             $this->InstorPickupLocalDelivery = (isset($response->InstorPickupLocalDelivery) ? $response->InstorPickupLocalDelivery : NULL);
    501 
    502 //          Eniture debug mood
    503             do_action("eniture_debug_mood", "Quotes Response (R+L)", json_decode($output));
    504 
    505             return $this->parse_rnl_output($output, $request_data, $rnl_package, $loc_id);
    506         }
     485        } else {
     486            $response = json_decode($cache_response);
     487        }
     488
     489        $this->InstorPickupLocalDelivery = isset($response->InstorPickupLocalDelivery) && !empty($response->InstorPickupLocalDelivery) ? $response->InstorPickupLocalDelivery : array();
     490
     491        return $this->parse_rnl_output($cache_response, $request_data, $rnl_package, $loc_id);
    507492    }
    508493
     
    537522        if (isset($this->quote_settings['indirect_deliveries_enabled']) && $this->quote_settings['indirect_deliveries_enabled'] != 'yes' && !$is_direct) {
    538523            // Eniture debug mood
    539             do_action("eniture_debug_mood", "Indirect Deliveries Disabled (R+L)");
     524            do_action("eniture_debug_mood", "Indirect Deliveries Disabled (R+L)", json_encode($result));
    540525
    541526            return [];
     
    1014999        return array_merge($excluded, $this->en_accessorial_excluded);
    10151000    }
     1001
     1002    function create_cachable_data($request_data)
     1003    {
     1004        $cachable_data = [];
     1005        $cachable_data['receiverCity'] = $request_data['receiverCity'];
     1006        $cachable_data['receiverState'] = $request_data['receiverState'];
     1007        $cachable_data['receiverZip'] = $request_data['receiverZip'];
     1008        $cachable_data['receiverCountryCode'] = $request_data['receiverCountryCode'];
     1009
     1010        $cachable_data['senderCity'] = $request_data['senderCity'];
     1011        $cachable_data['senderState'] = $request_data['senderState'];
     1012        $cachable_data['senderZip'] = $request_data['senderZip'];
     1013        $cachable_data['senderCountryCode'] = $request_data['senderCountryCode'];
     1014
     1015        $cachable_data['accessorials'] = $request_data['accessorials'];
     1016        $cachable_data['commdityDetails'] = $request_data['commdityDetails'];
     1017        $cachable_data['handlingUnitWeight'] = $request_data['handlingUnitWeight'];
     1018        $cachable_data['maxWeightPerHandlingUnit'] = $request_data['maxWeightPerHandlingUnit'];
     1019        $cachable_data['palletCode'] = isset($request_data['palletCode']) ? $request_data['palletCode'] : '';
     1020        $cachable_data['palletWeight'] = isset($request_data['palletWeight']) ? $request_data['palletWeight'] : '';
     1021        $cachable_data['holdAtTerminal'] = isset($request_data['holdAtTerminal']) ? $request_data['holdAtTerminal'] : '';
     1022
     1023        $cachable_data['doNesting'] = $request_data['doNesting'];
     1024        $cachable_data['modifyShipmentDateTime'] = $request_data['modifyShipmentDateTime'];
     1025        $cachable_data['suspend_residential'] = $request_data['suspend_residential'];
     1026        $cachable_data['residential_detecion_flag'] = $request_data['residential_detecion_flag'];
     1027        $cachable_data['liftGateWithAutoResidentials'] = isset($request_data['liftGateWithAutoResidentials']) ? $request_data['liftGateWithAutoResidentials'] : '';
     1028        $cachable_data['internationalResidential'] = isset($request_data['internationalResidential']) ? $request_data['internationalResidential'] : '';
     1029        $cachable_data['liftgateDelivery'] = isset($request_data['liftgateDelivery']) ? $request_data['liftgateDelivery'] : '';
     1030        $cachable_data['residentialDelivery'] = isset($request_data['residentialDelivery']) ? $request_data['residentialDelivery'] : '';
     1031        $cachable_data['residentialPickup'] = isset($request_data['residentialPickup']) ? $request_data['residentialPickup'] : '';
     1032        $cachable_data['liftgatePickup'] = isset($request_data['liftgatePickup']) ? $request_data['liftgatePickup'] : '';
     1033        $cachable_data['InstorPickupLocalDelivery'] = isset($request_data['InstorPickupLocalDelivery']) ? $request_data['InstorPickupLocalDelivery'] : '';
     1034
     1035        if (isset($request_data['autoResidentials']) && $request_data['autoResidentials'] == 1) {
     1036            $cachable_data['autoResidentials'] = $request_data['autoResidentials'];
     1037            $cachable_data['addressLine'] = $request_data['addressLine'];
     1038            $cachable_data['addressLine2'] = (isset($request_data['addressLine2'])) ? $request_data['addressLine2'] : '';
     1039            $cachable_data['defaultRADAddressType'] = $request_data['defaultRADAddressType'];
     1040            $cachable_data['defaultRADWithoutStreetAddress'] = $request_data['defaultRADWithoutStreetAddress'];
     1041            $cachable_data['poboxAddressValidation'] = $request_data['poboxAddressValidation'];
     1042        }
     1043
     1044        if (isset($request_data['standardPackaging']) && $request_data['standardPackaging'] == 1) {
     1045            $cachable_data['standardPackaging'] = $request_data['standardPackaging'];
     1046            $cachable_data['pallet'] = $request_data['pallet'];
     1047        }
     1048
     1049        $cachable_data['UserName'] = $request_data['UserName'];
     1050        $cachable_data['Password'] = $request_data['Password'];
     1051        $cachable_data['APIKey'] = $request_data['APIKey'];
     1052        $cachable_data['licence_key'] = $request_data['licence_key'];
     1053
     1054        return $cachable_data;
     1055    }
     1056
     1057    function create_cache_key($request_data) {
     1058        $request_build_query = http_build_query($request_data);
     1059        return md5('eniture_rnl_' . $request_build_query);
     1060    }
    10161061}
  • ltl-freight-quotes-rl-edition/trunk/rnl-shipping-class.php

    r3394985 r3442253  
    136136
    137137            /**
    138              * Virtual Products
    139              */
    140             public function en_virtual_products()
    141             {
    142                 global $woocommerce;
    143                 $products = $woocommerce->cart->get_cart();
    144                 $items = $product_name = [];
    145                 foreach ($products as $key => $product_obj) {
    146                     $product = $product_obj['data'];
    147                     $is_virtual = $product->get_virtual();
    148 
    149                     if ($is_virtual == 'yes') {
    150                         $attributes = $product->get_attributes();
    151                         $product_qty = $product_obj['quantity'];
    152                         $product_title = str_replace(array("'", '"'), '', $product->get_title());
    153                         $product_name[] = $product_qty . " x " . $product_title;
    154 
    155                         $meta_data = [];
    156                         if (!empty($attributes)) {
    157                             foreach ($attributes as $attr_key => $attr_value) {
    158                                 $meta_data[] = [
    159                                     'key' => $attr_key,
    160                                     'value' => $attr_value,
    161                                 ];
    162                             }
    163                         }
    164 
    165                         $items[] = [
    166                             'id' => $product_obj['product_id'],
    167                             'name' => $product_title,
    168                             'quantity' => $product_qty,
    169                             'price' => $product->get_price(),
    170                             'weight' => 0,
    171                             'length' => 0,
    172                             'width' => 0,
    173                             'height' => 0,
    174                             'type' => 'virtual',
    175                             'product' => 'virtual',
    176                             'sku' => $product->get_sku(),
    177                             'attributes' => $attributes,
    178                             'variant_id' => 0,
    179                             'meta_data' => $meta_data,
    180                         ];
    181                     }
    182                 }
    183 
    184                 $virtual_rate = [];
    185 
    186                 if (!empty($items)) {
    187                     $virtual_rate = [
    188                         'id' => 'en_virtual_rate',
    189                         'label' => 'Virtual Quote',
    190                         'cost' => 0,
    191                     ];
    192 
    193                     $virtual_fdo = [
    194                         'plugin_type' => 'ltl',
    195                         'plugin_name' => 'wwe_quests',
    196                         'accessorials' => '',
    197                         'items' => $items,
    198                         'address' => '',
    199                         'handling_unit_details' => '',
    200                         'rate' => $virtual_rate,
    201                     ];
    202 
    203                     $meta_data = [
    204                         'sender_origin' => 'Virtual Product',
    205                         'product_name' => wp_json_encode($product_name),
    206                         'en_fdo_meta_data' => $virtual_fdo,
    207                     ];
    208 
    209                     $virtual_rate['meta_data'] = $meta_data;
    210 
    211                 }
    212 
    213                 return $virtual_rate;
    214             }
    215 
    216             /**
    217138             * Calculate Shipping Rates For R+L
    218139             * @param string $package
     
    353274
    354275                $smallQuotes = $this->en_spq_sort($smallQuotes);
    355 
    356276                $smallQuotes = (is_array($smallQuotes) && (!empty($smallQuotes))) ? reset($smallQuotes) : $smallQuotes;
    357277                $smallMinRate = (is_array($smallQuotes) && (!empty($smallQuotes))) ? current($smallQuotes) : $smallQuotes;
    358 
    359                 // Virtual products
    360                 $virtual_rate = $this->en_virtual_products();
    361278
    362279                //FDO
     
    392309                ($this->quote_settings['limited_access_delivery'] == "yes") ? $this->accessorials[] = "LA" : "";
    393310
    394                 // Virtual products
     311                // Multiple Shipment
    395312                if (count($quotes) > 1 || $smpkgCost > 0) {
    396 
    397                     // Multiple Shipment
    398                     $multi_cost = 0;
    399                     $s_multi_cost = 0;
    400                     $access_multi_cost = 0;
    401                     $hold_at_terminal_fee = 0;
    402                     $_label = "";
    403                     $access_label = [];
    404                     $access_append_label = "";
    405313                    $this->minPrices = array();
    406 
    407314                    $this->quote_settings['shipment'] = "multi_shipment";
    408                     $shipment_numbers = 0;
    409315
    410316                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_LIFT'] = $small_quotes : "";
     
    413319                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_NOTACCESS'] = $small_quotes : "";
    414320                    (isset($small_quotes) && count($small_quotes) > 0) ? $this->minPrices['RNL_HAT'] = $small_quotes : "";
    415 
    416                     // Virtual products
    417                     if (!empty($virtual_rate)) {
    418                         $en_virtual_fdo_meta_data[] = $virtual_rate['meta_data']['en_fdo_meta_data'];
    419                         $virtual_meta_rate['virtual_rate'] = $virtual_rate;
    420                         $this->minPrices['RNL_LIFT'] = isset($this->minPrices['RNL_LIFT']) && !empty($this->minPrices['RNL_LIFT']) ? array_merge($this->minPrices['RNL_LIFT'], $virtual_meta_rate) : $virtual_meta_rate;
    421                         $this->minPrices['RNL_NOTLIFT'] = isset($this->minPrices['RNL_NOTLIFT']) && !empty($this->minPrices['RNL_NOTLIFT']) ? array_merge($this->minPrices['RNL_NOTLIFT'], $virtual_meta_rate) : $virtual_meta_rate;
    422                         $this->minPrices['RNL_ACCESS'] = isset($this->minPrices['RNL_ACCESS']) && !empty($this->minPrices['RNL_ACCESS']) ? array_merge($this->minPrices['RNL_ACCESS'], $virtual_meta_rate) : $virtual_meta_rate;
    423                         $this->minPrices['RNL_NOTACCESS'] = isset($this->minPrices['RNL_NOTACCESS']) && !empty($this->minPrices['RNL_NOTACCESS']) ? array_merge($this->minPrices['RNL_NOTACCESS'], $virtual_meta_rate) : $virtual_meta_rate;
    424                         $this->en_fdo_meta_data_third_party = !empty($this->en_fdo_meta_data_third_party) ? array_merge($this->en_fdo_meta_data_third_party, $en_virtual_fdo_meta_data) : $en_virtual_fdo_meta_data;
    425                         if ($this->quote_settings['HAT_status'] == 'yes') {
    426                             $this->minPrices['RNL_HAT'] = isset($this->minPrices['RNL_HAT']) && !empty($this->minPrices['RNL_HAT']) ? array_merge($this->minPrices['RNL_HAT'], $virtual_meta_rate) : $virtual_meta_rate;
    427                         }
    428                     }
    429321
    430322                    $rates = $this->get_multi_formatted_quotes($quotes, $smpkgCost);
     
    793685
    794686                $pickup_delivery = array(
    795                     'id' => $this->id . ':' . 'in-store-pick-up',
     687                    'id' => 'in-store-pick-up',
    796688                    'cost' => 0,
    797689                    'label' => $label,
     
    817709
    818710                $local_delivery = array(
    819                     'id' => $this->id . ':' . 'local-delivery',
     711                    'id' => 'local-delivery',
    820712                    'cost' => $cost,
    821713                    'label' => $label,
     
    914806            function get_multi_formatted_quotes($quotes, $smpkgCost)
    915807            {
    916                 // Multiple Shipment
    917808                $multi_cost = 0;
    918809                $s_multi_cost = 0;
     
    928819                foreach ($quotes as $ship_key => $q) {
    929820                    if (!empty($q)) {
    930                         $guaranteed_quotes = !empty($q['guaranteed_services_quotes']) ? $q['guaranteed_services_quotes'] : [];
    931821                        unset($q['guaranteed_services_quotes']);
    932822                        $combined_quotes = [];
    933823                        $combined_quotes[] = $q;
    934                         $combined_quotes = array_merge($combined_quotes, array_values($guaranteed_quotes));
    935824
    936825                        $key = "LTL_" . $ship_key;
     
    961850                            $rates = (is_array($quote) && (!empty($quote))) ? $quote : array();
    962851
     852                            if ($this->quote_settings['liftgate_limited_access_delivery'] == 'yes' && empty($simple_quotes)) {
     853                                $lfg_fee = ($this->quote_settings['liftgate_delivery'] != 'yes' && $this->quote_settings['liftgate_resid_delivery'] != 'yes') && isset($rates['surcharges']['LIFT']) ? $rates['surcharges']['LIFT'] : 0;
     854                                $rates['cost'] -= floatval($lfg_fee);
     855
     856                                $simple_quotes = $rates;
     857                            }
     858
    963859                            $this->minPrices['RNL_LIFT' . $unique_id][$key] = $rates;
    964860
     
    972868                                $access_append_label = (isset($limited_access_quotes['append_label'])) ? $limited_access_quotes['append_label'] : "";
    973869
    974                                 // $access_multi_cost += $this->add_handling_fee($access_cost, $handling_fee);
    975870                                $access_multi_cost = $this->add_handling_fee($access_cost, $handling_fee);
    976871                                $this->minPrices['RNL_ACCESS' . $unique_id][$key]['cost'] = $this->add_handling_fee($access_cost, $handling_fee);
     872                                $this->en_fdo_meta_data['RNL_ACCESS' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($access_cost, $handling_fee);
    977873                            }
    978874
     
    986882
    987883                            // Offer lift gate delivery as an option is enabled
    988                             if (isset($this->quote_settings['liftgate_delivery_option']) &&
    989                                 ($this->quote_settings['liftgate_delivery_option'] == "yes") &&
    990                                 (!empty($simple_quotes))) {
     884                            if (((isset($this->quote_settings['liftgate_delivery_option']) &&
     885                                ($this->quote_settings['liftgate_delivery_option'] == "yes")) || $this->quote_settings['liftgate_limited_access_delivery'] == "yes") && !empty($simple_quotes)) {
    991886                                $s_rates = $simple_quotes;
    992887                                $this->minPrices['RNL_NOTLIFT' . $unique_id][$key] = $s_rates;
     
    998893                                $s_label = (isset($s_rates['label_sufex'])) ? $s_rates['label_sufex'] : array();
    999894                                $s_append_label = (isset($s_rates['append_label'])) ? $s_rates['append_label'] : "";
    1000                                 // $s_multi_cost += $this->add_handling_fee($s_cost, $handling_fee);
    1001895                                $s_multi_cost = $this->add_handling_fee($s_cost, $handling_fee);
    1002896                                $this->minPrices['RNL_NOTLIFT' . $unique_id][$key]['cost'] = $this->add_handling_fee($s_cost, $handling_fee);
    1003                             }
    1004 
    1005                             // $multi_cost += $this->add_handling_fee($_cost, $handling_fee);
     897                                $this->en_fdo_meta_data['RNL_NOTLIFT' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($s_cost, $handling_fee);
     898                            }
     899
    1006900                            $multi_cost = $this->add_handling_fee($_cost, $handling_fee);
    1007901                            $this->minPrices['RNL_LIFT' . $unique_id][$key]['cost'] = $this->add_handling_fee($_cost, $handling_fee);
     902                            $this->en_fdo_meta_data['RNL_LIFT' . $unique_id][$key]['rate']['cost'] = $this->add_handling_fee($_cost, $handling_fee);
    1008903
    1009904                            $shipment_numbers++;
     
    1024919                            $this->arrange_multiship_freight(($multi_cost + $smpkgCost), 'RNL_LIFT' . $unique_id, $_label, $append_label) : "";
    1025920                            // Limited access delivery multi-shipment quotes
    1026                             ($access_multi_cost > 0 || $smpkgCost > 0) ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($access_multi_cost + $smpkgCost), 'RNL_ACCESS' . $unique_id, $access_label, $access_append_label) : "";
     921                            $always_lfg_when_lim_access = $this->quote_settings['liftgate_limited_access_delivery'] == 'yes';
     922                            ($access_multi_cost > 0 || $smpkgCost > 0) && !$always_lfg_when_lim_access ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($access_multi_cost + $smpkgCost), 'RNL_ACCESS' . $unique_id, $access_label, $access_append_label) : "";
    1027923                            // HAT multi-shipment quotes
    1028924                            ($hold_at_terminal_fee > 0) ? $multi_rates[$ship_key][] = $this->arrange_multiship_freight(($hold_at_terminal_fee + $smpkgCost), 'RNL_HAT', $hat_label, $append_hat_label) : "";
     
    1044940                                        $la_fee = isset($quote['surcharges']['LA']) ? $quote['surcharges']['LA'] : 0;
    1045941
     942                                        $rad_status = isset($quote['label_sufex']) && is_array($quote['label_sufex']) && in_array('R', $quote['label_sufex']);
     943                                        if ($this->quote_settings['liftgate_delivery'] == 'yes' || ($this->quote_settings['liftgate_resid_delivery'] == 'yes' && $rad_status)) {
     944                                            $lg_fee = 0;
     945                                        }
     946
    1046947                                        $shipment_cost += (floatval($lg_fee) +  floatval($la_fee));
    1047948                                        $shipment_cost -= $resi_fee;
     
    1081982                    }
    1082983                }
    1083                
     984
    1084985                $hat_cheapest_rate = [];
    1085986                if (!empty($multi_hat_rates)) {
     
    1090991
    1091992                // Find the cheapest rate for each shipments
     993                $multi_keys = ['RNL_LIFTLTL_', 'RNL_NOTLIFTLTL_', 'RNL_ACCESSLTL_', 'RNL_LIFTACCESSLTL_'];
    1092994                $cheapest_rates = [];
    1093                 foreach ($multi_rates as $key => $rate) {
    1094                     array_multisort(array_column($rate, 'cost'), SORT_ASC, $rate);
    1095                     $cheapest_rates[$key] = $rate[0];
    1096                 }
    1097 
    1098                 $cheapest_rate = [];
     995                $_cost = null;
     996                foreach ($multi_rates as $rate) {
     997                    if (!is_array($rate)) continue;
     998
     999                    foreach ($multi_keys as $multi_key) {
     1000                        foreach ($rate as $rvalue) {
     1001                            if (strpos($rvalue['id'], $multi_key) === false || $_cost == $rvalue['cost']) continue;
     1002                            $_cost = isset($rvalue['cost']) ? $rvalue['cost'] : 0;
     1003
     1004                            $cheapest_rates[$multi_key][] = $rvalue;
     1005                        }
     1006                    }
     1007                }
     1008
     1009                $final_rates = [];
    10991010                $multi_rate_key = '';
    11001011                foreach ($cheapest_rates as $key => $chp_rate) {
    1101                     if (empty($cheapest_rate)) {
    1102                         $cheapest_rate = $chp_rate;
    1103                         $multi_rate_key = $chp_rate['id'];
    1104                     } else {
    1105                         $cheapest_rate['cost'] += floatval($chp_rate['cost']);
    1106                         $this->minPrices[$multi_rate_key]['LTL_' . $key] = reset(array_values($this->minPrices[$chp_rate['id']]));
    1107                         $this->en_fdo_meta_data[$multi_rate_key]['LTL_' . $key] = reset(array_values($this->en_fdo_meta_data[$chp_rate['id']]));
    1108                     }
    1109                 }
    1110 
    1111                 $final_quotes = array_merge(array($cheapest_rate), array($hat_cheapest_rate));
    1112 
    1113                 return $final_quotes;
     1012                    foreach ($chp_rate as $ckey => $crate) {
     1013                        if (!isset($final_rates[$key])) {
     1014                            $final_rates[$key] = $crate;
     1015                            $multi_rate_key = $crate['id'];
     1016                        } else {
     1017                            $final_rates[$key]['cost'] += floatval($crate['cost']);
     1018                            $this->minPrices[$multi_rate_key]['LTL_' . $ckey] = reset(array_values($this->minPrices[$crate['id']]));
     1019                            $this->en_fdo_meta_data[$multi_rate_key]['LTL_' . $ckey] = reset(array_values($this->en_fdo_meta_data[$crate['id']]));
     1020                            unset($this->minPrices[$crate['id']], $this->en_fdo_meta_data[$crate['id']]);
     1021                        }
     1022                    }
     1023                }
     1024
     1025                $final_rates = array_merge($final_rates, array($hat_cheapest_rate));
     1026
     1027                return $final_rates;
    11141028            }
    11151029
Note: See TracChangeset for help on using the changeset viewer.