Re: Calculated shipping doesn't show up when an item is free shipping.
Quote:
Originally Posted by
Ajeh
Have you a link to that add on? I am not following how a clone of Flat Rate flat is calculating shipping regarding weight ... :lookaroun
http://www.zen-cart.com/downloads.php?do=file&id=1224
It doesn't actually calculate shipping... that's the point of the add-on... I calculate the shipping manually, email the customer the shipping quote, then they enter what I tell them themselves in the text entry box that this add-on creates.
Re: Calculated shipping doesn't show up when an item is free shipping.
What version of Zen Cart are you using?
What is the Zone Definition for the USA set to on the id?
Re: Calculated shipping doesn't show up when an item is free shipping.
Quote:
Originally Posted by
Ajeh
What version of Zen Cart are you using?
What is the Zone Definition for the USA set to on the id?
1.39h....
I'm not quite sure what you are asking for regarding the zone definition..... When I click Admin > Locations/Taxes > Zone Definitions > USA >
It says: Country: United States Zone: All Zones
Re: Calculated shipping doesn't show up when an item is free shipping.
If you look at the URL ... what is the zID for that Zone Definition that you see in the URL?
Re: Calculated shipping doesn't show up when an item is free shipping.
Once you know the Zone Definition id number, you can replace the 21 that I use with your value ...
Edit the file:
/includes/classes/shipping.php
and add the code in RED:
Code:
function calculate_boxes_weight_and_tare() {
global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;
// Always Free Shipping added back except for US 48 plus DC zone_id = 21
// bof: allow 1 zone only for Always Free Shipping
global $db, $order, $cart;
$valid_zone_id = 21;
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $valid_zone_id . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$total_weight += $_SESSION['cart']->free_shipping_weight;
}
// eof: allow 1 zone only for Always Free Shipping
// Always Free Shipping added back except for US 48 plus DC zone_id = 21
if (is_array($this->modules)) {
Then customize your Flat Rate flat clone ...
I am using the Flat Rate flat module so just adapt the code to your Flat Rate clone with the code in RED:
Code:
// disable only when entire cart is free shipping
// if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
// }
Code:
// class methods
function quote($method = '') {
global $order;
global $shipping_weight;
//echo 'Flat $shipping_weight: ' . $shipping_weight . ' $total_weight: ' . $total_weight . '<br>';
if ($shipping_weight > 0) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
'cost' => MODULE_SHIPPING_FLAT_COST + $chk_weight_charge)));
}
if ($this->tax_class > 0) {
On the FREE SHIPPING! freeshipper add your Zone for the US to that module ...
See if this makes it work for you ...
Re: Calculated shipping doesn't show up when an item is free shipping.
Quote:
Originally Posted by
Ajeh
Once you know the Zone Definition id number, you can replace the 21 that I use with your value ...
Edit the file:
/includes/classes/shipping.php
and add the code in
RED:
Code:
function calculate_boxes_weight_and_tare() {
global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;
// Always Free Shipping added back except for US 48 plus DC zone_id = 21
// bof: allow 1 zone only for Always Free Shipping
global $db, $order, $cart;
$valid_zone_id = 21;
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $valid_zone_id . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
$total_weight += $_SESSION['cart']->free_shipping_weight;
}
// eof: allow 1 zone only for Always Free Shipping
// Always Free Shipping added back except for US 48 plus DC zone_id = 21
if (is_array($this->modules)) {
Then customize your Flat Rate flat clone ...
I am using the Flat Rate flat module so just adapt the code to your Flat Rate clone with the code in
RED:
Code:
// disable only when entire cart is free shipping
// if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
// }
Code:
// class methods
function quote($method = '') {
global $order;
global $shipping_weight;
//echo 'Flat $shipping_weight: ' . $shipping_weight . ' $total_weight: ' . $total_weight . '<br>';
if ($shipping_weight > 0) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
'cost' => MODULE_SHIPPING_FLAT_COST + $chk_weight_charge)));
}
if ($this->tax_class > 0) {
On the FREE SHIPPING! freeshipper add your Zone for the US to that module ...
See if this makes it work for you ...
Linda,
Thanks so much for your help and time. I got it working perfectly now so that ALWAYS FREE SHIPPING products do not offer the free shipping option for zones outside the USA. This solution worked for me. THANK YOU!
Re: Calculated shipping doesn't show up when an item is free shipping.
Thanks for the update that this is working for you to offer Always Free Shipping to just one zone ...
Re: Calculated shipping doesn't show up when an item is free shipping.
Here's an Observer class that can be added to a v1.5.5 site to skip the need to edit the shipping.php file as shown in post #25 above:
Install it as /includes/classes/observers/auto.free_shipping_override_for_international.php
Code:
<?php
/**
* @package plugins
* @copyright Copyright 2003-2017 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: Designed for v1.5.5+ $
*/
class zcObserverFreeShippingOverrideForInternational extends base {
function __construct() {
$this->attach($this, array('NOTIFY_SHIPPING_MODULE_PRE_CALCULATE_BOXES_AND_TARE'));
}
// For items that are marked as always_free_shipping, check the shipping zone, and if not in the zone-limits for FreeShipper, reset the free-shipping to 0
function updateNotifyShippingModulePreCalculateBoxesAndTare(&$class, $eventID, $null, $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes)
{
global $db, $order;
if (isset($order) && isset($order->delivery)) {
$check_flag = false;
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FREESHIPPER_ZONE . "'
and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
// 0 = all zones match; therefore restriction is imposed
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
// zone matches; therefore restriction is imposed
$check_flag = true;
break;
}
$check->MoveNext();
}
if ($check_flag == false) {
// no matches for free-shipping zones, so treat as chargeable instead of free shipping
$total_weight += $_SESSION['cart']->free_shipping_weight;
}
}
}
}
Then configure the FreeShipper shipping module to have a "Shipping Zone" for the country/states that you wish to allow free shipping.
The observer will use that zone to determine when to restore the shipping weight back for quoting for addresses outside that zone.
Then comment out the zen_get_shipping_enabled() line as shown in post #25 for whichever shipping module you want to provide quotes for these always-free-shipping items when outside the zone defined in the FreeShipper module.