I am working with OS Commerce 2. Unfortunately developing with and for OS Commerce has been an exercise in patience. I've worked with many open source projects in the past and seen some bad coding practices but OS Commerce tops them all. If there is a bad, corrupt, or insecure php programming practice that isn't demonstrated in the source for OS Commerce somewhere I would be really surprised. Even spelling errors are rampant!
Unfortunately it seems to be about the most complete PHP open source shopping cart system available. Its popularity mixed with its corrupt nature has even caused some to completely refactor the code in an attempt to remove early 1990s design paradigms (literally almost a hundred layout tables per page) and allow for accessibility.
In working with it I had to create a tax zone for the entire world in order to charge extra shipping for international orders. Rather than manually adding each of the 238(?) countries to my tax zone I wrote this mySQL Store Procedure to accomplish that task for me:
DELIMITER //
DROP PROCEDURE IF EXISTS import_countries//
CREATE PROCEDURE import_countries ()
BEGIN
DECLARE s_country_id INT DEFAULT 0;
DECLARE s_country_name VARCHAR(100);
DECLARE s_max_i INT DEFAULT 100;
DECLARE s_i INT DEFAULT 0;
SELECT max(countries_id) FROM countries INTO s_max_i;
aloop: LOOP
SET s_i=s_i+1;
IF s_i > s_max_i THEN
LEAVE aloop;
END IF;
SELECT countries_id, countries_name INTO s_country_id, s_country_name FROM countries WHERE countries_id = s_i;
IF s_country_id <> 223 THEN
INSERT INTO zones_to_geo_zones
(association_id, zone_country_id, zone_id, geo_zone_id, last_modified, date_added)
VALUES(NULL, s_country_id, 0, 2, NOW(), NOW());
END IF;
END LOOP aloop;
END;
//
DELIMITER ;