X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   XC4.3.2 Mod use different shipping methods for a country that belong to several zones (https://forum.x-cart.com/showthread.php?t=60015)

man0n 06-30-2011 09:09 AM

XC4.3.2 Mod use different shipping methods for a country that belong to several zones
 
When your courier offers you different services to send to same country,
you will need to define different zones for the same country and create different shipping rates for the different zones.

By example if UPS Express saver service (by plane) the zone for Germany have zone 6
and UPS Standard (by road) the zone for Germany is zone 5.
THe logic of Xcart will be to list the shipping method of the first zone it found.
This mod will list all available shipping method of the zones that belong to the destination country.


At file shipping/shipping.php line 415 after foreach ($product_providers as $provider) {
sustitute apropiate lines by this:
Code:

 
414        foreach ($product_providers as $provider) {   
415 // man0n customization   
416          $provider_condition = " AND provider='$provider'";   
417          $customer_zones = func_get_customer_zone_ship2($customer_info, $provider, "D");   
418          $shipping = $shipping && func_query_first_cell(str_replace('{{weight}}', $weight_array[$provider],$shipping_query)." AND zoneid IN ('".implode("','", array_keys($customer_zones))."') ".$provider_condition);


At file include/func/func.cart.php line 73 after function func_get_customer_zone_ship add:
Code:


// man0n customization
function func_get_customer_zone_ship2 ($username, $provider, $type) {
        global $sql_tbl;
        global $single_mode;

        $zones = func_get_customer_zones_avail($username, $provider, "S");
        $zone = 0; # default zone
        if (is_array($zones)) {
                $provider_condition = ($single_mode) ? "" : " AND provider='".addslashes($provider)."'";
                $tmp = func_query_column("SELECT zoneid FROM $sql_tbl[shipping_rates] WHERE zoneid IN ('".implode("','", array_keys($zones))."') $provider_condition AND type='$type' GROUP BY zoneid");
                if (is_array($tmp) && !empty($tmp)) {
                        $unused = $zones;
                        # remove not available zones
                        foreach($tmp as $v) {
                                if (isset($unused[intval($v)]))
                                        unset($unused[intval($v)]);
                        }
                        if (!empty($unused)) {
                                foreach($unused as $k => $v)
                                        unset($zones[$k]);
                        }

                        reset($zones);
                      //  $zone = key($zones); #extract first zone
                }
        }

        return $zones;
}

function func_get_customer_zone_ship3 ($username, $provider, $type,$shippingid) {
        global $sql_tbl;
        global $single_mode;

        $zones = func_get_customer_zones_avail($username, $provider, "S");
        $zone = 0; # default zone
        if (is_array($zones)) {
                $provider_condition = ($single_mode) ? "" : " AND provider='".addslashes($provider)."'";
                $tmp = func_query_column("SELECT zoneid FROM $sql_tbl[shipping_rates] WHERE shippingid=$shippingid and zoneid IN ('".implode("','", array_keys($zones))."') $provider_condition AND type='$type' GROUP BY zoneid");
                if (is_array($tmp) && !empty($tmp)) {
                        $unused = $zones;
                        # remove not available zones
                        foreach($tmp as $v) {
                                if (isset($unused[intval($v)]))
                                        unset($unused[intval($v)]);
                        }
                        if (!empty($unused)) {
                                foreach($unused as $k => $v)
                                        unset($zones[$k]);
                        }

                        reset($zones);
                        $zone = key($zones); #extract first zone
                }
        }

        return $zone;
}

 


At line 1135
After
if (($shipping_type == "D") || ($shipping_type == "R" && $shipping_cost > 0)) {
sustitute:
Code:

$customer_zone = func_get_customer_zone_ship($customer_info, $provider, $shipping_type);
by:
Code:


                  // man0n customization
                    $customer_zone = func_get_customer_zone_ship3($customer_info, $provider, $shipping_type,$shipping_id);
                 



If you need help let me know.


All times are GMT -8. The time now is 02:19 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.