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)
-   -   Google Checkout shipping rates fix (https://forum.x-cart.com/showthread.php?t=48175)

necroflux 06-18-2009 10:51 PM

Google Checkout shipping rates fix
 
Well I know a ton of people have given up on Google Checkout because of the whole 3 second timeout on shipping calculations - well I have a solution - simply create the XML code yourself for the shipping rates instead of letting X-cart generate it dynamically. In gcheckout.php, after:

Code:

                <merchant-calculated-shipping name="{$_ship_method['shipping']}">
                    <price currency="{$config['Google_Checkout']['gcheckout_currency']}">{$_ship_method['rate']}</price>
                    <address-filters>
                        <allowed-areas>
                            <world-area />
                        </allowed-areas>
                    </address-filters>
                </merchant-calculated-shipping>

OUT;
            }


We will be overriding this previous calculation and totally defining the $shipping_methods variable ourselves. Here's my example (and this would be pasted directly below the above code):


Code:

            $shipping_xml = "<shipping-methods>\n";
            //Set up free shipping if order total is > $100       

            if($cart["subtotal"]>="100") {
           
            $shipping_xml.="<flat-rate-shipping name=\"UPS Ground\">
                    <price currency=\"USD\">0.00</price>
                    <shipping-restrictions>
                        <allowed-areas>
                            <us-country-area country-area=\"CONTINENTAL_48\"/>
                        </allowed-areas>
                    </shipping-restrictions>
                </flat-rate-shipping>";

            } else {
           
            $shipping_xml.="<flat-rate-shipping name=\"UPS Ground\">
                    <price currency=\"USD\">7.95</price>
                    <shipping-restrictions>
                        <allowed-areas>
                            <us-country-area country-area=\"CONTINENTAL_48\"/>
                        </allowed-areas>
                    </shipping-restrictions>
                </flat-rate-shipping>";
            }           

            $shipping_xml.=    "<flat-rate-shipping name=\"UPS 2nd Day Air\">
                    <price currency=\"USD\">15.00</price>
                    <shipping-restrictions>
                        <allowed-areas>
                            <us-country-area country-area=\"CONTINENTAL_48\"/>
                        </allowed-areas>
                    </shipping-restrictions>
                </flat-rate-shipping>
                <flat-rate-shipping name=\"UPS Next Day Air Saver\">
                    <price currency=\"USD\">30.00</price>
                    <shipping-restrictions>
                        <allowed-areas>
                            <us-country-area country-area=\"CONTINENTAL_48\"/>
                        </allowed-areas>
                    </shipping-restrictions>
                </flat-rate-shipping>
                <flat-rate-shipping name=\"UPS 2nd Day Air (Alaska, Hawaii)\">
                    <price currency=\"USD\">25.00</price>
                    <shipping-restrictions>
                        <allowed-areas>
                            <us-state-area>
                                <state>HI</state>
                            </us-state-area>
                            <us-state-area>
                                <state>AK</state>
                            </us-state-area>
                        </allowed-areas>
                    </shipping-restrictions>
                </flat-rate-shipping>


                \n\t\t\t</shipping-methods>               
               
\n";


Basically, this gives:

To the continental US:
-- $7.95 Ground shipping for orders under $100
-- Free Ground shipping for orders above $100
-- $15 2nd day air shipping
-- $30 next day shipping

To Hawaii and Alaska:
-- $25 2nd day air shipping

This has worked 100% of the time, the shipping variables are loaded in with the initial XML request so I don't think the 3 second rule even applies here. To test it anyway, I hammered the checkout button about 30 times in 5 seconds, and every single tab loaded the shipping rates correctly (some tabs taking up to a minute to load). Seems pretty rock solid.

I've used an if/then statement for the order total to give free shipping on orders above a certain amount, but you could also work in other rules based on your own needs, even using the total shipping weight and manually setting up tiered shipping rates with XML to simulate calculated rates if necessary.

Hope this helps you guys out!

joestern 09-02-2009 03:25 PM

Re: Google Checkout shipping rates fix
 
When you implemented this fix, do your x-cart-generated invoices show the correct shipping total and method?

Every xcart invoice for a google order shwos 0.00 for shipping, regardless of the shipping method actually purchased/chosen in google.

Thanks.


All times are GMT -8. The time now is 06:33 AM.

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