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.phplocate 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.phpPut 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/shippingLocate 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