-
1 Attachment(s)
Shipping Estimator
Zen Cart v1.5.7c
Php Version PHP Version 7.3.33
Big Royal Mail
Please could I have some help getting my shipping estimator to work.
Firstly I could see messages in my log showing
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; rm1stpacket has a deprecated constructor in /home/tidytoys/public_html/includes/modules/shipping/rm1stpacket.php on line 12
So I have changed made the following coding changes
// class constructor
// function rmairsure() {
function _construct() {
I have 5 different choices for mailing. 3 are for uk customers and 2 are for outside the uk.
Big Royal Mail is nice and simple in the fact that I only need 2 files for each type of postage.
Now I have the Shipping Estimator showing ... but I only need the country to show up on the shipping estimator, the State/Province and Post Code options are not needed for estimating the costs. Even when completing all 3 choices Im not getting any estimates to show up.
Im getting this message in my log but dont know if its connected to the issue ...
--> PHP Warning: Use of undefined constant DATE_TIME_FORMAT - assumed 'DATE_TIME_FORMAT' (this will throw an Error in a future version of PHP) in /home/tidytoys/public_html/admin/includes/functions/general.php on line 189.
Attachment 20139
-
Re: Shipping Estimator
-
Re: Shipping Estimator
I will read and try and follow ...
But Please could you tell me how I remove the State and Post Code options from the menu ?
-
Re: Shipping Estimator
This is really difficult for me.
Im not a coder and the files I use for Royal Mail calculation
arent the really complex ones that are used by other people.
I struggle and most of the things that are thrown at me to do I cant understand.
-
Re: Shipping Estimator
Sorry .. but this means nothing to me ...
A number of constants which were unused by the core were removed from language files. If you use a plugin which relied on these defines, you should expect a PHP Notice in your /logs folder. To resolve this, define the needed constants in a plugin specific file or an override, as appropriate. Some of the defines removed are DATE_FORMAT_SHORT and DATE_TIME_FORMAT, which some plugins may have used even though core Zen Cart code does not.
-
Re: Shipping Estimator
For calculating uk 1st class postage ...
I just have 2 files
includes/languages/english/modules/shipping/rm1stpacket.php and
includes/modules/shipping/rm1stpacket.php
PHP Code:
<?php
/*
GPL released as part of the big_royalmail_v2.3 package
see CREDITS.txt for the contributors and support forum.
*/
if(!defined('MODULE_SHIPPING_RM_EXPIRES')){define('MODULE_SHIPPING_RM_EXPIRES', 1238976000);}
define('MODULE_SHIPPING_RM1STPACKET_TEXT_TITLE', 'Royal Mail 1<sup>st</sup> Class <i style="font-weight: normal">"Packet"</i>');
define('MODULE_SHIPPING_RM1STPACKET_TEXT_DESCRIPTION', 'Royal Mail 1<sup>st</sup> Class <i style="font-weight: normal">"Packet"</i> Rates. Weights in kg. <i>Rates valid until '.date('jS M Y', MODULE_SHIPPING_RM_EXPIRES).'</i>');
define('MODULE_SHIPPING_RM1STPACKET_TEXT_WAY', 'Great Britain and Northern Ireland only');
define('MODULE_SHIPPING_RM1STPACKET_TEXT_UNITS', 'kg(s)');
define('MODULE_SHIPPING_RM1STPACKET_INVALID_ZONE', 'GB & Northern Ireland only for this service');
define('MODULE_SHIPPING_RM1STPACKET_UNDEFINED_RATE', 'The shipping rate cannot be determined at this time');
define('MODULE_SHIPPING_RM1STPACKET_TEXT_UNDERMINTOTAL', 'The 1<sup>st</sup> Class <i style="font-weight: normal">"Packet"</i> service is only available for orders over £');
define('MODULE_SHIPPING_RM1STPACKET_TEXT_OVERMAXTOTAL', 'The 1<sup>st</sup> Class <i style="font-weight: normal">"Packet"</i> service is only available for orders under £');
PHP Code:
<?php
/*
GPL released as part of the big_royalmail_v2.3 package
see CREDITS.txt for the contributors and support forum.
*/
class rm1stpacket {
var $code, $title, $description, $enabled, $num_zones ;
// class constructor
function _construct() {
// function rm1stpacket() {
global $order, $total_weight, $messageStack ;
$this->version = '2.3.8';
$this->code = 'rm1stpacket';
$this->title = ( (defined('IS_ADMIN_FLAG') && IS_ADMIN_FLAG == true) ? @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_TITLE'). ' <b style="color:#ff4000">ver. '.$this->version.'</b>' : constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_TITLE') );
$this->description = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_DESCRIPTION');
$this->sort_order = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_SORT_ORDER');
$this->icon = (( defined('DIR_WS_ICONS') ? DIR_WS_ICONS : 'images/icons/' ) . 'shipping_ukrm.jpg');
$this->tax_class = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TAX_CLASS');
$this->enabled = ((MODULE_SHIPPING_RM1STPACKET_STATUS == 'True') ? true : false);
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
$this->num_zones = 1;
// inspired by Jim Barrington (JollyJim)
if( isset($order) && @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_HIDE_SHIPPING_ERRORS') == 'True' ){
switch(isset($order->info['subtotal'])){
case true:
if( $order->info['subtotal'] < @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MIN_ORDERVALUE')){
$this->enabled = false;
return ;
}else
if(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE != -1 && $order->info['subtotal'] > @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MAX_ORDERVALUE')){
$this->enabled = false;
return ;
}
break;
case false:
if($order->info['total'] < @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MIN_ORDERVALUE')){
$this->enabled = false;
return ;
}else
if(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE != -1 && $order->info['total'] > @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MAX_ORDERVALUE')){
$this->enabled = false;
return ;
}
break;
} // end of switch on subtotal
// check that it is a valid country being shipped to.
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_RM1STPACKET_ZONES_COUNTRIES_' . $i);
$country_zones = preg_split("/,/", preg_replace('/\s*/','',$countries_table) );
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}
// ship to country is invalid for this service
if ($dest_zone == 0) {
$this->enabled = false;
return ;
}else{
$this->enabled = false; // enabled set to true if valid shipping weight found
$zones_cost = constant('MODULE_SHIPPING_RM1STPACKET_ZONES_COST0_' . $dest_zone);
$zones_table = preg_split("/[:,]/" , preg_replace('/\s*/','',$zones_cost) );
$size = sizeof($zones_table);
for ($i=0; $i<$size; $i+=2) {
if ($total_weight <= $zones_table[$i]) {
$this->enabled = true;
// disable when entire cart is free shipping defined by total weight = 0 as initiated by freeshipper
if ($total_weight <=0) {
$this->enabled = ((MODULE_SHIPPING_RM1STPACKET_STATUS == 'false') ? true : false);
}
break;
}
} // end of looping through
return ;
} // end of valid country
} // end of if hide invalid shipping methods is set
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $currency;
$currencies = new currencies();
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_RM1STPACKET_ZONES_COUNTRIES_' . $i);
$country_zones = preg_split("/,/", preg_replace('/\s*/','',$countries_table) );
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}
//12 FEB 04 MBeedell NO specified country (or *) then use this zone for all shipping rates
if ($dest_zone == 0) {
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_RM1STPACKET_ZONES_COUNTRIES_' . $i);
if ($countries_table == '' or $countries_table == '*') {
$dest_zone = $i;
break;
}
}
}
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
//12 FEB 04 MBeedell 'glue' together the rates from the 10 cost data entry boxes
$zones_cost = constant('MODULE_SHIPPING_RM1STPACKET_ZONES_COST0_' . $dest_zone);
$zones_table = preg_split("/[:,]/" , preg_replace('/\s*/','',$zones_cost) );
$size = sizeof($zones_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $zones_table[$i]) {
$shipping = $zones_table[$i+1];
//12 Feb 04 MBeedell - correctly format the total weight... if the weight exceeds the max
// weight, then it is divided down over a number of separate packages - so the weight could end
// up being a long fraction.
$sw_text = number_format($shipping_weight, 3, $currencies->currencies[DEFAULT_CURRENCY]['decimal_point'], $currencies->currencies[DEFAULT_CURRENCY]['thousands_point']);
$shipping_method = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_WAY') . ' ' . $dest_country . ' : ' . $sw_text . ' ' . constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_UNITS');
$shipping_method = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_WAY') . ' : ' . $sw_text . ' ' . constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_UNITS');
if ($shipping_num_boxes > 1) {
// PC corrected shipping_num_boxes
$sw_text = number_format($shipping_num_boxes, 0, $currencies->currencies[DEFAULT_CURRENCY]['decimal_point'], $currencies->currencies[DEFAULT_CURRENCY]['thousands_point']);
$shipping_method = $shipping_method . ' in ' . $sw_text . ' boxes ';
}
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_UNDEFINED_RATE');
//$shipping_method = $zones_cost; //12 FEB 04 MBeedell useful for debug-print out the rates list!
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_RM1STPACKET_ZONES_HANDLING_' . $dest_zone);
}
}
$this->quotes = array('id' => $this->code,
'module' => @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_TITLE') ,
// 'module' => 'Royal Mail 1<sup>st</sup> class <i style="font-weight: normal">"packet"</i>' ,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
switch(isset($order->info['subtotal'])){
case true:
if($order->info['subtotal'] < @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MIN_ORDERVALUE')){
$this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_UNDERMINTOTAL') . number_format(MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE,2) ;
return $this->quotes;
}else
if(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE != -1 && $order->info['subtotal'] > @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MAX_ORDERVALUE')){
$this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_OVERMAXTOTAL') . number_format(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE,2) ;
return $this->quotes;
}
break;
case false:
if($order->info['total'] < @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MIN_ORDERVALUE')){
$this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_UNDERMINTOTAL') . number_format(MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE,2) ;
return $this->quotes;
}else
if(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE != -1 && $order->info['total'] > @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_MAX_ORDERVALUE')){
$this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_TEXT_OVERMAXTOTAL') . number_format(MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE,2) ;
return $this->quotes;
}
break;
}
if ($shipping == -1) {
$this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_UNDEFINED_RATE');
}
if ($error == true) $this->quotes['error'] = @constant('MODULE_SHIPPING_'.(strtoupper($this->code)).'_INVALID_ZONE');
return $this->quotes;
}
function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_RM1STPACKET_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}
function install() {
global $db;
$this->remove();
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable this shipping option', 'MODULE_SHIPPING_RM1STPACKET_STATUS', 'False', 'If you need to adjust your shipping rates, you can use this option to disable it in your shop, instead of re-installing', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Hide Invalid Shipping', 'MODULE_SHIPPING_RM1STPACKET_HIDE_SHIPPING_ERRORS', 'False', 'Hide this shipping service if it is not valid (either due to exceeding the maximum weight or the min & max order values).', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_RM1STPACKET_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_RM1STPACKET_SORT_ORDER', '100', 'Sort order of display.', '6', '0', now())");
$handling_test = $db->Execute("SELECT configuration_key FROM " . TABLE_CONFIGURATION . " WHERE configuration_key IN ( 'MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE', 'MODULE_SHIPPING_RM1STPACKET_ZONES_HANDLING_1' ) " );
if(!$handling_test->RecordCount()){
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Value', 'MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE', '0.00', 'Minimum order value in £ GBP for this shipping option.<br />Set to 0 for no minimum order value.', '6', '0', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Order Value', 'MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE', '32.00', 'Maximum order value in £ GBP for this shipping option.<br />Set to -1 if there is no Maximum', '6', '0', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_RM1STPACKET_ZONES_HANDLING_1', '0', 'The amount it costs you to package the items for first class delivery.', '6', '0', now())");
}
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 1 Countries', 'MODULE_SHIPPING_RM1STPACKET_ZONES_COUNTRIES_1', 'GB,GG,JE,IM', 'two character ISO country codes for Great Britain and Northern Ireland " . $i . ".', '6', '0', now())");
if(!defined('MODULE_SHIPPING_RM1STPACKET_ZONES_COST0_1')){
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping rates to GB & Northern Ireland', 'MODULE_SHIPPING_RM1STPACKET_ZONES_COST0_1', '0.1:1.14,0.25:1.45, 0.5:1.94, 0.75:2.51, 1.0:3.08, 1.25:4.30, 1.5:5.00, 1.75:5.70, 2:6.40, 4:8.22, 6:11.02', 'Correct to 6<sup>th</sup> April 2009, a SQL patch is available for the 2009 rates. <br />Example: 0.1:1.14 means weights less than or equal to 0.1 Kg would cost £1.14.', '6', '0', 'zen_cfg_textarea(', now())");
}
}
function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "') AND configuration_key NOT IN ('MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE', 'MODULE_SHIPPING_RM1STPACKET_ZONES_HANDLING_1') AND configuration_key NOT LIKE 'MODULE_SHIPPING_RM1STPACKET_ZONES_COST%'");
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_RM1STPACKET_ZONES_COUNTRIES_1'");
}
function keys() {
$keys = array('MODULE_SHIPPING_RM1STPACKET_STATUS', 'MODULE_SHIPPING_RM1STPACKET_HIDE_SHIPPING_ERRORS', 'MODULE_SHIPPING_RM1STPACKET_TAX_CLASS', 'MODULE_SHIPPING_RM1STPACKET_SORT_ORDER', 'MODULE_SHIPPING_RM1STPACKET_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STPACKET_MAX_ORDERVALUE');
$keys[] = 'MODULE_SHIPPING_RM1STPACKET_ZONES_HANDLING_1';
$keys[] = 'MODULE_SHIPPING_RM1STPACKET_ZONES_COST0_1';
return $keys;
}
}
?>
-
Re: Shipping Estimator
I'm, unfortunately, not familiar with the Royal Mail shipping module ... but I'll try to help. It looks like you're using a clone of the built-in 'responsive_classic' template; please advise.
-
Re: Shipping Estimator
Yes, Im using the responsive_classic template but have just adjusted settings and messed about to get it how I want it to look
-
Re: Shipping Estimator
With the shipping ... I just replicate these 2 files for each shipping type that I have.
Royal Mail can be complicated but Im just after a simple solution as Im working by the weight of the item and finding
a corresponding postal price for that weight band.
I have 1st, 2nd Class post and courier for uk customers
and two different Royal Mail products for overseas.
I only need to know the country the parcel is being sent to.
Hence, the State/Province and Zip/Post Code can be removed from the shipping estimator box.
The trouble is that I dont have any coding experience with modern languages and just muddle through.
I can find my way round zen cart to change lines that Im told to change but cant come up with my own solutions.
-
Re: Shipping Estimator
I removed the changes I did to the code ...
"So I have changed made the following coding changes
// class constructor
// function rmairsure() {
function _construct() { "
And now the shipping is showing ...
except now the 1st and 2nd class isnt now showing in my admin panel
-
Re: Shipping Estimator
Just to let you know that ...
Ive managed to get my shipping estimator to look and work exactly how I want.
I dont quite know how or why its started working again but I removed the code I put in and the postage started
to show again in the estimator, whereas even before I changed the code the postage wasnt showing.
Then I was left with removing the State and Zip Code pull-downs from the shipping estim ... and found this
https://www.zen-cart.com/showthread....ping-Estimator
I still have these warnings in my log but at least my shipping estimator is looking good.
--> PHP Warning: Use of undefined constant DATE_TIME_FORMAT - assumed 'DATE_TIME_FORMAT' (this will throw an Error in a future version of PHP) in /home/tidytoys/public_html/admin/includes/functions/general.php on line 189.
-
Re: Shipping Estimator
Depending on the time of your problem, the reason could have been... https://downdetector.com/status/usps/