Page 1 of 1

[SOLVED] Destination Based Shipping working for CMS 1.8.2

Posted: Mon Nov 01, 2010 8:51 pm
by luminous
I need to set different shipping rates depending on destination and/or quantity of goods sold.

I've not done this before and after searching have found a module called "Destination Based Shipping".  Its installed OK, but any attempt to use it results in the following error:
Fatal error: Call to undefined method DestinationBasedShipping::ArrayToObject() in /homez.305/teesside/www/modules/DestinationBasedShipping/function.admin_settings_tab.php on line 67
What do other people use for destination based shipping costs?  A different module, or a different method of making this one work?

Code: Select all

----------------------------------------------

Cms Version: [b]1.8.2[/b]

Installed Modules:

    * CMSMailer: [b]2.0[/b]
    * MenuManager: [b]1.6.5[/b]
    * ModuleManager: [b]1.4[/b]
    * News: [b]2.10.6[/b]
    * nuSOAP: [b]1.0.2[/b]
    * Printing: [b]1.1.0[/b]
    * Search: [b]1.6.5[/b]
    * ThemeManager: [b]1.1.1[/b]
    * TinyMCE: [b]2.7.3[/b]
    * ScriptDeploy: [b]0.8[/b]
    * CGSimpleSmarty: [b]1.4.5[/b]
    * CGExtensions: [b]1.20[/b]
    * Products: [b]2.8.7[/b]
    * CGEcommerceBase: [b]1.2.2[/b]
    * Cart: [b]1.7.2[/b]
    * FrontEndUsers: [b]1.12.3[/b]
    * Captcha: [b]0.4.3[/b]
    * SimpleSiteInfo: [b]1.1[/b]
    * FileBackup: [b]0.5[/b]
    * CGPaymentGatewayBase: [b]1.0.9[/b]
    * Archiver: [b]0.2.3[/b]
    * Orders: [b]1.10.5[/b]
    * PaypalGateway: [b]2.2[/b]
    * FileManager: [b]1.0.2[/b]
    * ScriptDeploy: [b]0.8[/b]
    * CGSimpleSmarty: [b]1.4.5[/b]
    * CGExtensions: [b]1.20[/b]
    * Products: [b]2.8.7[/b]
    * CGEcommerceBase: [b]1.2.2[/b]
    * Cart: [b]1.7.2[/b]
    * FileBackup: [b]0.5[/b]
    * CGPaymentGatewayBase: [b]1.0.9[/b]
    * FrontEndUsers: [b]1.12.3[/b]
    * Orders: [b]1.10.5[/b]
    * SelfRegistration: [b]1.6.5[/b]
    * DestinationBasedShipping: [b]1.1[/b]


Config Information:

    * php_memory_limit: [b][/b]
    * process_whole_template: [b]false[/b]
    * output_compression: [b]false[/b]
    * max_upload_size: [b]64000000[/b]
    * default_upload_permission: [b]664[/b]
    * url_rewriting: [b]mod_rewrite[/b]
    * page_extension: [b][/b]
    * query_var: [b]page[/b]
    * use_hierarchy: [b]true[/b]
    * image_manipulation_prog: [b]GD[/b]
    * auto_alias_content: [b]true[/b]
    * locale: [b][/b]
    * default_encoding: [b]utf-8[/b]
    * admin_encoding: [b]utf-8[/b]
    * set_names: [b]true[/b]


Php Information:

    * phpversion: [b]5.2.13[/b]
    * md5_function: [b]On[/b] (True)
    * gd_version: [b]2[/b]
    * tempnam_function: [b]On[/b] (True)
    * magic_quotes_runtime: [b]Off[/b] (False)
    * E_STRICT: [b]0[/b]
    * memory_limit: [b]128M[/b]
    * max_execution_time: [b]30[/b]
    * output_buffering: [b]On[/b]
    * safe_mode: [b]Off[/b] (False)
    * file_uploads: [b]On[/b] (True)
    * post_max_size: [b]64M[/b]
    * upload_max_filesize: [b]64M[/b]
    * session_save_path: [b]/tmp[/b] (1777)
    * session_use_cookies: [b]On[/b] (True)
    * xml_function: [b]On[/b] (True)


Server Information:

    * Server Api: [b]cgi[/b]
    * Server Db Type: [b]MySQL (mysql)[/b]
    * Server Db Version: [b]5.0.90[/b]


----------------------------------------------

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:00 pm
by Peciura
It is a bit outdated module. For time being you can apply this patch.
EDIT: replaced patch.

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:12 pm
by luminous
What would this place be without you?   ;D

Its complaining that there is something wrong with this line:

Code: Select all

+			     number_format($row['price'], '.', ''),10,10);
I wish I could fix it, but its cooking my noodle :(  I'm just starting to dip my toe into the coding side of things.
Parse error: syntax error, unexpected ',' in /homez.305/teesside/www/modules/DestinationBasedShipping/function.admin_settings_tab.php on line 76

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:23 pm
by Peciura
Replaced patch file on previous post.

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:31 pm
by luminous
Really sorry to report that it is still reporting an error:
Parse error: syntax error, unexpected ',' in /homez.305/teesside/www/modules/DestinationBasedShipping/function.admin_settings_tab.php on line 76
Posted whole contents of file, just in case its me that is making the mistake

Code: Select all

<?php
#BEGIN LICENSE
#-------------------------------------------------------------------------
# Module: DestinationBasedShipping - A simple shipping module for Cart
# Version: 1.0, calguy1000 <calguy1000@hotmail.com>
#
#-------------------------------------------------------------------------
# CMS - CMS Made Simple is (c) 2005 by Ted Kulp (wishy@cmsmadesimple.org)
# This project's homepage is: http://www.cmsmadesimple.org
# The module's homepage is: http://dev.cmsmadesimple.org/projects/skeleton/
#
#-------------------------------------------------------------------------
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# However, as a special exception to the GPL, this software is distributed
# as an addon module to CMS Made Simple.  You may not use this software
# in any Non GPL version of CMS Made simple, or in any version of CMS
# Made simple that does not indicate clearly and obviously in its admin 
# section that the site was built with CMS Made simple.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
#
#-------------------------------------------------------------------------
#END LICENSE
if( !isset($gCms) ) exit;
if( !$this->CheckPermission('Modify Site Preferences') )
  {
    echo $this->ShowErrors('error_permissiondenied');
    return;
  }

$this->SetCurrentTab('settings');
$smarty->assign('formstart',
		$this->CGCreateFormStart($id,'admin_save_settings',$returnid));
$smarty->assign('formend',$this->CreateFormEnd());
$smarty->assign('submit',$this->CreateInputSubmit($id,'submit',$this->Lang('submit')));

$products = $this->GetModuleInstance('Products');
$weightunit = $products->GetPreference('products_weightunits');
$priceunit = $products->GetPreference('products_currencysymbol');
$smarty->assign('weightunit',$weightunit);
$smarty->assign('priceunit',$priceunit);
$smarty->assign('input_label',
		$this->CreateInputCountryDropdown($id,'input_label','',true));
$smarty->assign('input_quantity',
		$this->CreateInputText($id,'input_quantity','',5,5));
$smarty->assign('input_price',
		$this->CreateInputText($id,'input_price','',10,10));

// Get the existing data out of the database
$entries = array();
$query = 'SELECT * FROM '.cms_db_prefix().'module_destshipping ORDER BY label,quantity_limit';
 $dbr = $db->Execute( $query );
 while( $dbr && ($row = $dbr->FetchRow() ) )
   {
-    $obj = $this->ArrayToObject($row);
+    $obj = cge_array::to_object($row);
     $obj->input_label = $this->CreateInputCountryDropdown($id,'label[]',$row['label']);
     $obj->input_quantity = 
       $this->CreateInputText($id,'quantity[]',
 			     sprintf("%3d",$row['quantity_limit']),5,5);
     $obj->input_price = 
       $this->CreateInputText($id,'price[]',
-			     sprintf("%.2f",$row['price']),10,10);
+			     number_format($row['price'], 2, '.', ''),10,10);
     $entries[] = $obj;
   }
 $smarty->assign('entries',$entries);

echo $this->ProcessTemplate('admin_settings_tab.tpl');
// EOF
?>

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:39 pm
by Peciura
Patch is not php code it displays changes in code. 
Line beginning with '-' has to be replaced with line that starts with '+'. So you have to remove 2 lines and 2 characters '+' (to make valid php code).

Re: Destination Based Shipping

Posted: Mon Nov 01, 2010 10:43 pm
by luminous
:-[ :-[ :-[

Please excuse my noobness.  Works fine now :)

P.S.  what did you use to generate the patch file?  Could be useful for me to know in the future as I get into this more.

Re: [SOLVED] Destination Based Shipping working for CMS 1.8.2

Posted: Mon Nov 01, 2010 10:51 pm
by Peciura
On Win you could use Winmerge or Tortoise SVN ( depends on platform and repository ) or any similar software.

Re: [SOLVED] Destination Based Shipping working for CMS 1.8.2

Posted: Mon Nov 01, 2010 10:52 pm
by luminous
Thanks again  :)

Re: [SOLVED] Destination Based Shipping working for CMS 1.8.

Posted: Sun Jan 16, 2011 11:13 am
by spinfold
Sorry to drag this up from the dredges, but this just worked for me too - many thanks :)