BradWaite Posted November 19, 2002 Share Posted November 19, 2002 Hi all. I added USPSMethods to the Contributions a few days ago. In a nutshell, it allows you to choose which USPS shipping methods will be presented to the customer. For example, if you only want customers to choose between Parcel Post and Priority Mail, you can uncheck Express and First Class in the admin interface. When the customer checks out, he doesn't even see Express or First Class. In order to make this work, I had to add a new function to general.php that allows a config option to have multiple values - tep_cfg_select_multioption. Previously, the only choice was to use radio buttons ( with tep_cfg_select_option), which are exclusive - only one option can be chosen at a time. This may have been done elsewhere, but I haven't come across it. In any case, it should be useful to other developers. Brad Waite W Cubed Quote Link to comment Share on other sites More sharing options...
zzfritz Posted November 20, 2002 Share Posted November 20, 2002 Brilliant! This is like magic -- I went to sleep last night thinking about making a mod something like this (some overseas user chose a USPS method I had never heard of), and behold, when I woke up this morning Brad's post about the contribution was waiting for me. Just two comments: The final step of this mod, editing catalog/includes/modules/shipping/usps.php, was written before one more line was added in version 1.36 to fix an important bug. So now the step is to replace if ($order->delivery['country']['id'] == STORE_COUNTRY) { $request = '<RateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">'; $services_count = 0; if (isset($this->service)) { $this->types = array($this->service => $this->types[$this->service]); } reset($this->types); while (list($key, $value) = each($this->types)) { $request .= '<Package ID="' . $services_count . '">' . with if ($order->delivery['country']['id'] == STORE_COUNTRY) { $request = '<RateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">'; $services_count = 0; if (isset($this->service)) { $this->types = array($this->service => $this->types[$this->service]); } reset($this->types); $allowed_types = explode(", ", MODULE_SHIPPING_USPS_TYPES); while (list($key, $value) = each($this->types)) { if ( !in_array($key, $allowed_types) ) continue; $request .= '<Package ID="' . $services_count . '">' . And the other thing is the list of allowable methods may need some tweeking to filter some of the international services. I have not yet completed this analysis, but for instance, there is something called Global Express Guaranteed Document Service (and a Non-Document variation) that is not appropriate for what my store sells. Presumably, the platform Brad has provided will allow for dealing with these. Quote Link to comment Share on other sites More sharing options...
BradWaite Posted November 20, 2002 Author Share Posted November 20, 2002 The final step of this mod, editing catalog/includes/modules/shipping/usps.php, was written before one more line was added in version 1.36 to fix an important bug. So now the step is to replace if (isset($this->service)) { $this->types = array($this->service => $this->types[$this->service]); } My bad. I'd already fixed that myself (before the addition to CVS) by adding if ($method) $this->types = array($method => $type->types[$method]); into the quote() function in usps.php. It was simpler than the CVS solution, but USPSMethods should have been based on the CVS code, not mine. And the other thing is the list of allowable methods may need some tweeking to filter some of the international services. I have not yet completed this analysis, but for instance, there is something called Global Express Guaranteed Document Service (and a Non-Document variation) that is not appropriate for what my store sells. Presumably, the platform Brad has provided will allow for dealing with these. Actually, I didn't even consider international options so the methods won't be checked if the delivery address is not in the same country as the store (US). Back to coding... Thanks for the heads-up. Brad Quote Link to comment Share on other sites More sharing options...
zzfritz Posted November 21, 2002 Share Posted November 21, 2002 The contribution fails to revive properly after being disabled, unless you add the following to the install function after the other lines that look similar, at about line 94: tep_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express, Priority, First Class, Parcel', 'Select the USPS services to be offered.', '6', '14', 'tep_cfg_select_multioption(array('Express', 'Priority', 'First Class', 'Parcel'), ', now())"); Then, the module will behave better and show the new service options without then necessity of manually inserting into the configuration table. Quote Link to comment Share on other sites More sharing options...
BradWaite Posted November 21, 2002 Author Share Posted November 21, 2002 The contribution fails to revive properly after being disabled, unless you add the following to the install function after the other lines that look similar Drat! I was going to mention that. I guess I'll have to release a new version. Again, good catch. Brad Quote Link to comment Share on other sites More sharing options...
elfmuse Posted November 24, 2002 Share Posted November 24, 2002 I'm glad I checked the forums here. I was about to implement this mod. Please let us the less experienced php people know when you have the mods done to the contribution:) Elfmuse Quote Link to comment Share on other sites More sharing options...
Guest Posted November 25, 2002 Share Posted November 25, 2002 a similar mod for UPS would be wonderful. is it possible for someone to create one? TIA jc Quote Link to comment Share on other sites More sharing options...
zzfritz Posted November 26, 2002 Share Posted November 26, 2002 For UPS, I posted a hack to do this: http://www.oscommerce.com/forums/viewtopic.php...p?p=81630#81630 Quote Link to comment Share on other sites More sharing options...
Guest Posted November 26, 2002 Share Posted November 26, 2002 you da man! or let me say it right: YOU da man! thank you very much!! Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 27, 2002 Share Posted November 27, 2002 can some one tell me if USPS is functioning properly. i want to install it but want to be sure before that as I have no coding experience Dumb Quote Link to comment Share on other sites More sharing options...
zzfritz Posted November 27, 2002 Share Posted November 27, 2002 USPS is working fine, so well in fact that some of us want to limit the number of choices it provides. For international shipments it provides a bewildering number of alternatives. Quote Link to comment Share on other sites More sharing options...
BradWaite Posted November 27, 2002 Author Share Posted November 27, 2002 Hello everyone. I just posted USPSMethods_v1.1 to the contribs. The new version includes the fixes zzfritz caught. International support will be coming in the undetermined future. Brad Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 28, 2002 Share Posted November 28, 2002 Does USPS methods contribution work with international shipping as well? Quote Link to comment Share on other sites More sharing options...
BradWaite Posted November 28, 2002 Author Share Posted November 28, 2002 Does USPS methods contribution work with international shipping as well? International USPS works as before - the contrib doesn't affect it. Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 28, 2002 Share Posted November 28, 2002 can someone tell me where I should I change the code to implement USPS methods. I know Brad mentioned the path as " Modules->Shipping->United States Postal Service" but how do I get there. Again , I know this is a dumb question! Quote Link to comment Share on other sites More sharing options...
Guest Posted November 28, 2002 Share Posted November 28, 2002 www/yoursitename/admin/index.php (or whatever the path to your admin area is) click on modules click on shipping click on usps Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 28, 2002 Share Posted November 28, 2002 jeff i dont see anu codes there. I actually did try using cute ftp. However, looks like i messed up I am getting this , message whenever I click anything on my website "Fatal error: Cannot redeclare tep_set_banner_status() (previously declared in /home/kashmira/public_html/catalog/includes/functions/general.php:664) in /home/kashmira/public_html/catalog/includes/functions/banner.php on line 15 i uploaded the backup files but i am still getting the same message Someone please help Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 28, 2002 Share Posted November 28, 2002 never mind...i fixed it....site is working in its prior state. i will try changing the code again I know i am dumb! Quote Link to comment Share on other sites More sharing options...
Guest Posted November 28, 2002 Share Posted November 28, 2002 the only way you learn is to ask questions you think we all just woke up one day and could do this stuff??? Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 30, 2002 Share Posted November 30, 2002 I am trying to install USPS methods... can someone guide where the following code needs to be installed Execute the following SQL command on your catalog database: INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added ) VALUES ( 'Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express, Priority, First Class, Parcel', 'Select the USPS services to be offered.', '6', '14', 'tep_cfg_select_multioption(array('Express', 'Priority', 'First Class', 'Parcel'), ', now() ) What configuaration are we talking about! thanks for your help Quote Link to comment Share on other sites More sharing options...
zzfritz Posted November 30, 2002 Share Posted November 30, 2002 The sql command should be entered while running phpMyAdmin, a tool that shows you what is in the database and allows you to modify not only the contents but the structure of the database. The table in the database that is changed by this particular command is named 'configuration' and holds execution parameters for osC. Some server control panels have phpMyAdmin built in (under MySQL), or you can get the open source script here: http://www.phpmyadmin.net/ Learning how to use this is essential to your continuing ability to extend and maintain osC, as you can see the contributions often require it. Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 30, 2002 Share Posted November 30, 2002 thanks...appreciate your help Quote Link to comment Share on other sites More sharing options...
BradWaite Posted November 30, 2002 Author Share Posted November 30, 2002 FYI, if you've got USPSMethods v1.1, there's a somewhat easier way to install it. Insert the rest of the code as described in the instructions (other than Step 1), then simply turn the USPS module off and back on again. The install() function automatically executes the required SQL commands. HTH, Brad Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 30, 2002 Share Posted November 30, 2002 ok I will try that brad Thanks! Quote Link to comment Share on other sites More sharing options...
dumb_question Posted November 30, 2002 Share Posted November 30, 2002 well I tried to do that but i got this errror in shipping module in the cobtrol panel Parse error: parse error, unexpected '.' in /home/public_html/catalog/includes/modules/shipping/usps.php on line 141 Also, the code in my USPS seems to be different than what u have displayed in your contribution if ($order->delivery['country']['id'] == STORE_COUNTRY) { $request = '<RateRequest USERID="' . MODULE_SHIPPING_USPS_USERID . '" PASSWORD="' . MODULE_SHIPPING_USPS_PASSWORD . '">'; $services_count = 0; if (isset($this->service)) { $this->types = array($this->service => $this->types[$this->service]); } reset($this->types); while (list($key, $value) = each($this->types)) { $request .= '<Package ID="' . $services_count . '">' . Any suggestions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.