Deprecated Function “Split” in Tiered Percentage Shipping Module

May 6th, 2014 | No Comments |

OSCommerce Coding - Deprecated Function "Split"Recently I acquired a client who had an eCommerce store with an extremely outdated version of OSCommerce. For some reason, their shopping cart wasn’t working, and due to the outdated core and plethora of custom coding, it would take more time to troubleshoot the error than it would to install a fresh, updated version of OSCommerce.

So I installed OSCommerce on my hosting account, which is with Godaddy, and added certain modules to match the ones they had installed on their old shopping cart. Everything was working perfectly, until I switched it over to their hosting account.

The “Tiered Shipping Percentage Rates” module wasn’t working. It would calculate the handling cost, but would leave out any and all percentage costs I had configured.

I was getting this error across the top of the /checkout_shipping.php page:

Deprecated: Function split() is deprecated in /home/horusa52/public_html/catalog/includes/modules/shipping/percent..php on line 57

Now, based on the error, it’s obvious the function “split()” is outdated. So, I contacted the person who helped with the creation of the tiered shipping percentage module to figure out a workaround. And there were a few solutions.

The first code change was using “explode” in place of “split.” Like this:

$percent_cost = explode(“,” , MODULE_SHIPPING_PERCENT_COST);

All that did was literally “EXPLODE” the shipping costs in my module by nearly 3,000%. So that didn’t work.

The second option was using “preg_split.” Like this:

$percent_cost = preg_split(“/(:|,)/” , MODULE_SHIPPING_PERCENT_COST);

Which worked perfectly. No more error and the shipping is calculated perfectly.

So, unless the module is updated with the new code, you might receive the same error and hopefully this post will be of some help to you.

Leave a comment