News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Toll Australia Courier Shipping Module

Started by aarondwyer, May 02, 2006, 03:10:22 AM

Previous topic - Next topic

aarondwyer

I have created a Toll Australia Courier Shipping Module contribution, I don't think you guys have a contribution setup like osCommerce so I'll just post it here and use this post as support for it.

You can get the file from here.

http://netrospect.com.au/downloads/TollAustraliaShippingModule.zip

Thanks
Aaron

laurie_lewis

Hi Aaron,

I have installed the changes and it appears to work fine.  I just have to wait for my postcode book and pricelists to update for my area. Once that is in I will run it through a few times to check the maths etc.  Thanks I could not have done this myself.

If you update it can I suggest the following:
1.  That you re-introduce the ability for the sender to add a packaging cost to the item
2.  That you create a further table for the base cost
  or however you need to do it.
3.  Cosmetic only - but the Aus Post module shows their logo.  Can it be done for the Toll one?


Just wondering - have you looked at the how TNT and Australia Air Express do their costings to see if works inside the same framework?  I was going to make a few phone calls today to try and find out.

Again thanks

Laurie



laurie_lewis

Hi Aaron,,

Know you are busy but I have had a go at looking at this myself but have not tested it.  I was wondering if you could check the CODE for me.  You know the background.  I have changed the order a bit from yours just for my own comfort zone.  More confident at the start.

Here goes

Step #1 - Analyzing requirements
This contribution requires:
•   VirtueMart v1.04

Step #2 - Backup files
Make a backup of the files that are going to be changed:
•   /administrator/components/com_virtuemart/classes/ps_shipping.php
•   /administrator/components/com_virtuemart/html/shipping.rate_form.php
•   /administrator/components/com_virtuemart/html/shipping.rate_list.php
•   /administrator/components/com_virtuemart/languages/english.php

and

Don't forget to backup your database as well.

Step #3 - Start editing your files
The bits to add are wrapped in these tags

// ###### Begin Added To Standard Shipping Module ######
code
// ###### End Added To Standard Shipping Module ######


The code bits before and after the tags are there to help you locate where to put them.

Step #4 - Add extra columns into shipping rate table in the database
You will need to use phpMyAdmin or whatever you use to edit your database and insert this SQL to add the extra rows.  These rows are used for the base shipping rate the the minimum cost for the shipping.

ALTER TABLE `jos_vm_shipping_rate` ADD `shipping_rate_minimum_cost` DECIMAL( 10, 2 ) DEFAULT '0.00' NOT NULL AFTER `shipping_rate_weight_end` ;
ALTER TABLE `jos_vm_shipping_rate` ADD `shipping_rate_base_cost` DECIMAL( 10, 2 ) DEFAULT '0.00' NOT NULL AFTER `shipping_rate_minimum_cost` ;


Step #5 - In /administrator/components/com_virtuemart/html/shipping.rate_form.php
This code changes where the data is entered in the shipping module adding two additional fields asking for minimum cost and base cost figures.  These rows were added to the database in the previous step.

locate within the file and add the commented text

<input type="text" class="inputbox" name="shipping_rate_weight_end" size="32" maxlength="255" value="<?php $db->sp("shipping_rate_weight_end"?>">
</td>
</tr>

// ###### Begin Added To Standard Shipping Module ######
<tr>
<td width="21%" ><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_RATE_FORM_MIMIMUM_COST ?>:</strong></div></td>
<td width="79%" >
<input type="text" class="inputbox" name="shipping_rate_minimum_cost" size="32" maxlength="255" value="<?php $db->sp("shipping_rate_minimum_cost"?>">
</td>
</tr>
<tr>
<td width="21%" ><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_RATE_FORM_BASE_COST ?>:</strong></div></td>
<td width="79%" >
<input type="text" class="inputbox" name="shipping_rate_base_cost" size="32" maxlength="255" value="<?php $db->sp("shipping_rate_base_cost"?>">
</td>
</tr>
// ###### End Added To Standard Shipping Module ######

<tr>
<td width="21%" ><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_RATE_FORM_VALUE ?>:</strong></div></td>



Step #6 - In /administrator/components/com_virtuemart/languages/english.php

This is supposed to add in the text for the two new fields, (minimum cost and error costs) and the error messages if they are empty.  I am not sure why the zip parts are added I though they would have been there from the start.

locate within the file and add the commented text

var $_PHPSHOP_RATE_FORM_VALUE = 'Fee';
var $_PHPSHOP_RATE_FORM_PACKAGE_FEE = 'Your package fee';

// ###### Begin Added To Standardll Shipping ######
var $_PHPSHOP_RATE_FORM_MINIMUM_COST = 'Minimum shipping charge';
        var $_PHPSHOP_RATE_FORM_BASE_COST = 'Base shipping charge';
// ###### End Added To Standard Shipping #######

var $_PHPSHOP_RATE_FORM_CURRENCY = 'Currency';
var $_PHPSHOP_RATE_FORM_VAT_ID = 'VAT Id';
var $_PHPSHOP_RATE_FORM_LIST_ORDER = 'List Order';
var $_PHPSHOP_SHIPPING_RATE_LIST_CARRIER_LBL = 'Shipper';
var $_PHPSHOP_SHIPPING_RATE_LIST_RATE_NAME = 'Shipping Rate description';

// ####### Begin Added To Standard Shipping ###########
var $_PHPSHOP_SHIPPING_RATE_LIST_RATE_ZIP_START = 'ZIP Start';
var $_PHPSHOP_SHIPPING_RATE_LIST_RATE_ZIP_END = 'ZIP End';
// ######## End Added To Standard Shipping ########

var $_PHPSHOP_SHIPPING_RATE_LIST_RATE_WSTART = 'Weight from ...';
var $_PHPSHOP_SHIPPING_RATE_LIST_RATE_WEND = '... to';
var $_PHPSHOP_CARRIER_FORM_NAME = 'Shipper Company';
var $_PHPSHOP_CARRIER_FORM_LIST_ORDER = 'Listorder';
var $_PHPSHOP_ERR_MSG_CARRIER_EXIST = 'ERROR: Shipper ID exists.';
var $_PHPSHOP_ERR_MSG_CARRIER_ID_REQ = 'ERROR: Choose a shipper.';
var $_PHPSHOP_ERR_MSG_CARRIER_INUSE = 'ERROR: At least one Shipping Rate exists, delete rates prior to shipper';
var $_PHPSHOP_ERR_MSG_CARRIER_NOTFOUND = 'ERROR: Unable to find a shipper with this ID.';
var $_PHPSHOP_ERR_MSG_RATE_CARRIER_ID_REQ = 'ERROR: Choose a shipper.';
var $_PHPSHOP_ERR_MSG_RATE_CARRIER_ID_INV = 'ERROR: Unable to find a shipper with this ID.';
var $_PHPSHOP_ERR_MSG_RATE_NAME_REQ = 'ERROR: A rate descriptor is requested.';
var $_PHPSHOP_ERR_MSG_RATE_COUNTRY_CODE_INV = 'ERROR: The Destination country is invalid. More than one country could be separated with ";".';
var $_PHPSHOP_ERR_MSG_RATE_WEIGHT_START_REQ = 'ERROR: A lowest weight is requested';
var $_PHPSHOP_ERR_MSG_RATE_WEIGHT_END_REQ = 'ERROR: A highes weight are requested';
var $_PHPSHOP_ERR_MSG_RATE_WEIGHT_STARTEND_INV = 'ERROR: The lowest weight must be smaller than the highes weight';
var $_PHPSHOP_ERR_MSG_RATE_WEIGHT_VALUE_REQ = 'ERROR: A shipping fee requested';

// ####### Begin Added To Standard Shipping #######
var $_PHPSHOP_ERR_MSG_RATE_MINIMUM_COST_REQ = 'ERROR: A shipping minimum fee requested';
        var $_PHPSHOP_ERR_MSG_RATE_BASE_COST_REQ = 'ERROR: A base minimum fee requested';
// #######End Added To Standard Shipping #######

var $_PHPSHOP_ERR_MSG_RATE_CURRENCY_ID_INV = 'ERROR: Coose a currency';
var $_PHPSHOP_ERR_MSG_RATE_ID_REQ = 'ERROR: A Shipping Rate is requested';



Step #7 - In /administrator/components/com_virtuemart/html/shipping.rate_list.php

locate within the file and add the commented text

I am not sure of this area and what needs to be done

$columns = Array(  "#" => "width=\"20\"",
"<input type=\"checkbox\" name=\"toggle\" value=\"\" onclick=\"checkAll(".$num_rows.")\" />" => "width=\"20\"",
$VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_CARRIER_LBL => '',
$VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_RATE_NAME => '',
// #################### Begin Added Toll Shipping ######################
$VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_RATE_ZIP_START => '',
$VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_RATE_ZIP_END => '',
// $VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_RATE_WSTART => '',
// $VM_LANG->_PHPSHOP_SHIPPING_RATE_LIST_RATE_WEND => '',
// #################### End Added Toll Shipping ######################
_E_REMOVE => "width=\"5%\""
);
$listObj->writeTableHeader( $columns );

$db->query($list);
$i = 0;

   
then

$url = $_SERVER['PHP_SELF'] . "?page=$modulename.rate_form&limitstart=$limitstart&keyword=$keyword&shipping_rate_id=". $db->f("shipping_rate_id");
$tmp_cell = "<a href=\"" . $sess->url($url) . "\">". $db->f("shipping_rate_name")."</a>";

$listObj->addCell( $tmp_cell );
// #################### Begin Added Toll Shipping ######################
$listObj->addCell( $db->f("shipping_rate_zip_start"));
$listObj->addCell( $db->f("shipping_rate_zip_end"));
// $listObj->addCell( $db->f("shipping_rate_weight_start"));
// $listObj->addCell( $db->f("shipping_rate_weight_end"));
// #################### End Added Toll Shipping ######################

$listObj->addCell( $ps_html->deleteButton( "shipping_rate_id", $db->f("shipping_rate_id"), "rateDelete", $keyword, $limitstart ) );

$i++;



Step #8 - In /administrator/components/com_virtuemart/classes/ps_shipping.php
Put in error mesages if minimum and base costs missing
locate within the file and add the commented text

if ($d["shipping_rate_value"] == "") {
      $d["error"] = $VM_LANG->_PHPSHOP_ERR_MSG_RATE_WEIGHT_VALUE_REQ;
      return False;
    }

// ####### Begin Added To Standard Shipping ########
     if ($d["shipping_rate_minimum_cost"] == "") {
      $d["error"] = $VM_LANG->_PHPSHOP_ERR_MSG_RATE_MINIMUM_COST_REQ;
      return False;
    }   
      if ($d["shipping_rate_base_cost"] == "") {
      $d["error"] = $VM_LANG->_PHPSHOP_ERR_MSG_RATE_BASE_COST_REQ;
      return False;
    }
// ####### End Added To Standard Shipping ########

    if ($d["shipping_rate_package_fee"] == "") {
      $d["shipping_rate_package_fee"] = '0';
    }
    $q = "SELECT currency_id FROM #__{vm}_currency WHERE currency_id='" . $d["shipping_rate_currency_id"] . "'";



Step #9 - Copy new shipping files into /administrator/components/com_virtuemart/classes/shipping

Locate the files that were in the ZIP file:

    * standard_shipping_2.php
    * standard_shipping_2.ini

and copy them into the shipping sub directory.



I have also edited your Toll files and attached them as standard_shipping_2.zip.  The alterations are again marked so they can be reviewed.

I would love some feedback before I try it?

Laurie



[attachment cleanup by admin]

fagan

I have done this but in my admin section when adding a rate I have a field labled ":" <---- what is this field?

laurie_lewis

You should end up with two new rows in the table:

shipping_rate_minimum_cost
shipping_rate_base_cost

It looks like you might not have cut and pasted correctly.

I updated this and figured a few extra things out in another link adding all the files that I updated.

See here:-
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=18592.0

I have just about finished putting all the postcodes in for Australian air Express and will put them at the end of the link I just pointed you to.  If you are going to use Aarons Toll express codes you will have to do a bit of manipulating as he has only put in one more field where as I have added two.

Laurie

fagan

Hi laurie,

FOr some reason my weight is not adding on per extra kg.. eg the base is 10 then 10 per kg but for a 100.00kg (test) it comes up as only 20?

Any ideas anyone?