CubeCart 3.0 Currency and Shipping Solutions

This article was published by, , as a feature tutorial.

In the realm of storefront solutions, there are both proprietary and open source alternatives, with the latter category receiving greater interest from businesspeople and software developers, just as we are seeing in other application areas. Sadly, the quality of the open source alternatives is quite uneven, and generally below that of the proprietary ones. That is not say that they are far behind in functionality. In fact, from the perspective of the typical businessperson who just wants to set up their online store as easily as possible with the essential capabilities, some of the open source storefronts can be quite impressive. But for developers who are tasked with maintaining, modifying, and truly understanding the workings of these systems, the poor quality of the code can be shocking. This applies to some of the best-known open-source systems.

Fortunately, there are a handful of open source storefronts/shopping carts that provide all of the basic functionality needed by the business owner to begin selling on the Web, with code quality and rational organization that make it possible for developers to implement and change them as needed, without too much pain. This also makes it easier for developers to create their own modules and themes, which one can think of as prepackaged functionality and site styling, respectively. Among Web developers creating online stores, CubeCart is a popular solution.

In this tutorial, I will show how to set up some critical functionality in an online store using CubeCart. In particular, I will show how, using third-party modules, to automate the process of updating currency rates, and how to charge shipping costs by subtotal — both being functionality that is valuable to CubeCart administrators and customers alike. This tutorial assumes that you have a working CubeCart 3.0 installation, and that you feel comfortable modifying an installation as a site administrator.

As always, first back-up your CubeCart files and database before making any changes. While none of the changes delineated in this tutorial are risky, there is always the chance for inadvertently modifying a key component of CubeCart, and rendering your site partially or wholly unusable.

Currency Updating the Hard Way

One of the advantages of using CubeCart for building an e-commerce site, is that it has built-in support for multiple currencies — eleven in all: Australian dollars, British pounds, Canadian dollars, Chinese yuan, euros, Japanese yen, Mexican peso, Russian rubles, South African rand, Swiss francs, and US dollars. This greatly facilitates the sale of products in all countries that use these currencies. Customers are not restricted to US dollars and euros, as with some shopping carts.

The disadvantage of using this feature — proportional to how many currencies you make available — is having to manually update the foreign exchange (FX) rates, which are fluctuating continuously throughout the day, as foreign-currency trading buffets the quoted rates among each pair of currencies.

This is especially true if the products for sale are high ticket items, in which case your client can incur daily monetary losses if particular FX rates move against your client, and customers are able to purchase valuable items for less than a fair price. But the more frequently that you or your client try to keep the exchange rates up to date in CubeCart, the more time will be lost doing this tedious chore.

Currency Updating the Easy Way

It is thus fortunate that there exists a CubeCart module for updating all of your FX rates, with a single click. You won't have to waste any time checking the latest rates on the Web, and manually setting those values in your CubeCart site.

To get started, visit the Automatic Currency Updater page

Automatic Currency Updater page
Figure 1. Automatic Currency Updater page

Download and install the Automatic Currency Updater, which consists of a single PHP script, UpDateXchange.php. Create a new directory in CubeCart's admin/ directory, named UpDateXchange. Put UpDateXchange.php in that new directory.

In your copy of UpDateXchange.php, set $udx_defaultcurrency to the three-letter currency code for the default currency of the CubeCart store. For instance, American sites would use "USD". Also, uncomment the value of $udx_ratesfrom corresponding to whatever online source you want to use for FX rates. For instance, I chose "".

In the file admin/includes/, below the currency.php line, insert the following code:

    <li><a <?php if(permission("settings","write")==TRUE){ ?>href=";?php%20echo%20$GLOBALS[%27rootRel%27];%20?%26gt;admin/UpDateXchange/UpDateXchange.php" class="txtLink"<?php }
else { echo $link401; } ?>>Update Xchange rates</a></li>

Once you have done all of the above steps, then in the CubeCart admin area, under the "Store Config" menu, you should see a new menu item, "Update Xchange rates".

Automatic Currency Updater menu item
Figure 2. Automatic Currency Updater menu item

When you click on that link, the module queries your chosen FX rate provider, and sets all of the values within CubeCart.

Automatic Currency Updater processing
Figure 3. Automatic Currency Updater processing

Afterwards, all of your foreign currency rates should be up-to-date, as seen in the screenshot below.

Automatic Currency Updater results
Figure 4. Automatic Currency Updater results

Further Reading

There is limited documentation for the Automatic Currency Updater offered on the website listed earlier, and even less in the PHP script itself. But that should not pose a problem, because installation and use of the module is relatively straightforward, with minor customization needed — as explained above.

However, has a discussion of this module. Note that is not affiliated with Devellion Limited (the developer and vendor of CubeCart itself), but instead Inspired Solutions. The site hosts several useful forums, for two different versions of CubeCart, including links to free and commercial CubeCart modules.

Shipping by Subtotal

By default, CubeCart has built-in support for ten different shipping methods that you can make available to your site's customers: per category, Royal Mail, by weight, by price, free shipping, by percent, flat rate, per item, UPS, and USPS. However, many online sellers wish to charge fixed rates for various subtotal ranges. I will show how you could do that. Our first example will be the simplest: I will charge each US-based customer a fixed shipping rate of $60, and each non-US customer a rate of $25 (in conjunction with requiring that they provide their own FedEx, UPS, or DHL account number).

Firstly, visit the Shipping by Subtotal page

Shipping by Subtotal page
Figure 5. Shipping by Subtotal page

Download and unzip the archive file, which contains two directories, named "admin" and "modules", and one file, named ReadMe.txt. Extract the two directories into your CubeCart root directory. Doing this adds the following two files to your CubeCart installation: admin\modules\shipping\By_Subtotal\index.php and modules\shipping\By_Subtotal\calc.php.

It also adds a new option in Modules > Shipping, "By Subtotal". By default, the "Free Shipping" method is the only one enabled.

Shipping modules default
Figure 6. Shipping modules default

Disable "Free Shipping" by clicking its "Configure" link and setting "Status" to "Disabled".

Enable "By Subtotal" by clicking its "Configure" link.

Shipping by Subtotal before enabled
Figure 7. Shipping by Subtotal before enabled

Set "Status" to "Enabled", and click the "Edit Config" button. Then set "Use Zones" to "Yes", and "Tax Class" to "Tax Exempt". That latter setting is needed, otherwise the flat shipping rate is increased by the tax rate, which most merchants would not want.

Continuing with our example of charging US customers a subtotal rate different from that for non-US customers, set the "Zone 1 Countries:" to US, and the "Zone 1 Shiping [sic] Rates:" to 0:60, which means the shipping charge will be $60 regardless of the invoice subtotal. (The term "shipping" is misspelled in four places on the module's page.) Then set the "Zone 2 Countries:" to the following list: AD,AE,AF,AG,AI,AL,AM,AN,AO,AQ,AR,AS,AT,AU,AW,AZ,BA,BB,BD,BE,BF,BG,BH,BI,BJ,BM,BN,BO,BR,BS,BT,BV,BW,BY,BZ,CA,CC,CD,CF,CG,CH,CI,CK,CL,CM,CN,CO, CR,CS,CU,CV,CX,CY,CZ,DE,DJ,DK,DM,DO,DZ,EC,EE,EG,EH,ER,ES,ET,FI,FJ,FK,FM,FO,FR,GA,GB,GD,GE,GF,GH,GI,GL,GM,GN,GP,GQ,GR,GS,GT,GU,GW,GY, HK,HM,HN,HR,HT,HU,ID,IE,IL,IN,IO,IQ,IR,IS,IT,JM,JO,JP,KE,KG,KH,KI,KM,KN,KP,KR,KW,KY,KZ,LA,LB,LC,LI,LK,LR,LS,LT,LU,LV,LY,MA,MC,MD,MG,MH,MK,ML, MM,MN,MO,MP,MQ,MR,MS,MT,MU,MV,MW,MX,MY,MZ,NA,NC,NE,NF,NG,NI,NL,NO,NP,NR,NU,NZ,OM,PA,PE,PF,PG,PH,PK,PL,PM,PN,PR,PS,PT,PW,PY,QA,RE,RO,RU,RW, SA,SB,SC,SD,SE,SG,SH,SI,SJ,SK,SL,SM,SN,SO,SR,ST,SV,SY,SZ,TC,TD,TF,TG,TH,TJ,TK,TL,TM,TN,TO,TR,TT,TV,TW,TZ,UA,UG,UM,UY,UZ,VA,VC,VE,VG,VI,VN,VU, WF,WS,YE,YT,ZA,ZM,ZW. Then set "Zone 2 Shiping [sic] Rates:" to 0:25. Lastly, again click the "Edit Config" button.

Shipping by Subtotal after setting
Figure 8. Shipping by Subtotal after setting

You are all finished. Now your CubeCart store will automatically charge the correct shipping fee depending upon the location of the customer.

Charging different shipping costs for different ranges of subtotals, is just as easy. For instance, if you want to charge US customers $10 for any order up to $200, and charge $15 for anything up to $500, then you would set the Zone 1 shipping rates to "200:10,500:15".

There may be other modules out there that can give you the functionality described above, but these two may be the only ones available, and are certainly the most popular.

Copyright © 2008 Michael J. Ross. All rights reserved.
bad bots block