Forums / Addon Sideboxes / Shipping Estimator Sidebox compatibility?

Shipping Estimator Sidebox compatibility?

Views: 2,338

Results 1 to 11 of 11
22 Sep 2012, 5:12 PM
#1
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Shipping Estimator Sidebox compatibility?

Hi everyone,

I have discovered the very useful Shipping Estimator Sidebox written by Ravi Gulhane and updated recently by swguy. I installed it on a test environment (not on the live site) for testing but noticed that it doesn't cope with version 1.5.0 of Zen Cart. I wonder whether any of the developers is around to help. The issues faced are:

  1. The country selection drop-down is too wide to fit into the side box. I found this reported in another thread with a couple of workarounds suggested but I haven't done anything on it yet as I'm pretty confident that I can find a solution (if and) when the next two issues are resolved.

  2. The first serious issue has to do with entering items into the cart. There are three ways to enter items in the cart: a) by clicking on the "Buy now" button where it appears, b) by clicking the "Add to cart" button from the product description page and c) by defining a quantity for one or more items in a category page and clicking the "Add selected products to cart" button. It appears that option a) works fine and updates the cart and the estimator sidebox. Adding more products to the cart using this option doesn't cause any problem. Options b) and c) work and add products to the cart only if the cart is empty. If another item has been added with any of a), b) or c) nothing happens.

  3. The other issue is that product sort order cannot change in "New", "Featured" or "All" lists when there are items in the cart. No matter what sort option is selected from the drop down list, products are sorted by "Lowest price first" which is the default. If the cart is empty, the sort order can be changed normally.

Needless to say that I don't have these issues on my live site where the side box is not installed. It's a shame really because this "external" shipping estimator is exactly what I was looking for and I was thrilled when I discovered it but subsequently disappointed to see it not working properly.

Is there any chance to have these issues fixed and make us all happy? Many thanks in advance and kind regards.

23 Sep 2012, 12:29 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Shipping Estimator Sidebox compatibility?

The current Shipping Estimator Sidebox is only for ZC v1.3.8, v1.3.9 - it has not been made available for ZC 1.5 / 1.5.1

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

23 Sep 2012, 9:28 AM
#3
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Shipping Estimator Sidebox compatibility?

Yes Frank, I know it has not been made available for 1.5 (yet?) but I was hoping for the developer to read this and probably make it compatible eventually. I don't know about other users but I find it very useful. The number of downloads is quite high, so there are probably many more like me.

23 Sep 2012, 11:48 AM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: Shipping Estimator Sidebox compatibility?

@AthensCollectibles, 2 and 3 don't sound like Shipping Estimator problems. These sound like issues with your template.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

23 Sep 2012, 12:43 PM
#5
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Shipping Estimator Sidebox compatibility?

Thanks for replying Scot.

I wish 2) and 3) were issues with my template but they are not. My template is the Classic Zen Cart template modified mostly with CSS, it's not one from TemplateMonster or another one of those who are known to create issues. Besides, as I said in my first post, none of these problems exist in the live site where the Shipping Estimator is not installed.

Thank you anyway and I shall be looking forward to reinstall the mod if and when it is officially declared compatible with 1.5 to see how it goes.

Cheers and have a nice Sunday.

24 Sep 2012, 11:40 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: Shipping Estimator Sidebox compatibility?

I tried 2 and 3 and they both work fine in my setup (1.5.0 + Shipping Estimator with items in cart). Not sure what the issue you're having is; either it's a template issue or some other files are broken.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Nov 2012, 5:02 PM
#7
shopville avatar

shopville

Zen Follower

Join Date:
Aug 2012
Posts:
331
Plugin Contributions:
0

Re: Shipping Estimator Sidebox compatibility?

Is there any way to set shipping estimator sidebox to only show if user is logged in?

6 Nov 2012, 5:10 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping Estimator Sidebox compatibility?

You should be able to customize the file:
/includes/modules/sideboxes/shipping_estimator.php

using your templates and overrides:
/includes/modules/sideboxes/your_template_dir/shipping_estimator.php

with the code in RED:

$new_order_created = false; 
// BEGIN CEON FIX 1 of 2
if ([B]!$_SESSION['customer_id'] || [/B]$current_page_base == 'login' || $current_page_base == 'create_account' ||

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

6 Nov 2012, 6:12 PM
#9
shopville avatar

shopville

Zen Follower

Join Date:
Aug 2012
Posts:
331
Plugin Contributions:
0

Re: Shipping Estimator Sidebox compatibility?

Thanks, tried it and this is what displays:

Parse error: syntax error, unexpected '{' in /*******/includes/modules/sideboxes/shipping_estimator.php on line 25

<?php
/**
 * Shipping Estimator module
 *
 * Customized by: Linda McGrath [email protected] to:
 * - Handles Free Shipping for orders over $total as defined in the Admin
 * - Shows Free Shipping on Virtual products
 *
 * @package modules
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * portions Copyright (c) 2003 Edwin Bekaert ([email protected])
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: shipping_estimator.php 6996 2007-09-13 22:36:54Z ajeh $
 * @by Teddy
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
$new_order_created = false; 
// BEGIN CEON FIX 1 of 2
if (!$_SESSION['customer_id'] ||($current_page_base == 'login' || $current_page_base == 'create_account' ||
	  strpos($current_page_base, 'checkout') !== false ||
	  strpos($current_page_base, '3d_secure_iframe') !== false ||
	  $current_page_base == 'fec_confirmation') {
  // Don't let this code run during checkout process, as it will then override the user's shipping
  // selection. (Also don't show the sidebox on the login or create account pages)
  /*
// END CEON FIX 1 of 2
if ($current_page_base == 'checkout_shipping' OR $current_page_base == 'checkout_payment' OR $current_page_base == 'checkout_confirmation' OR $current_page_base == 'login' OR $current_page_base == 'create_account' OR $current_page_base == 'checkout_shipping_address' ) {
	// show nothing
// BEGIN CEON FIX 2 of 2
  */
// END CEON FIX 2 of 2
} else {

	// load JS updater
	if ($current_page_base != 'popup_shipping_estimator') {
		require_once(DIR_WS_MODULES . '/pages/popup_shipping_estimator/jscript_addr_pulldowns.php');
	}
	
	// Only do when something is in the cart
	if ($_SESSION['cart']->count_contents() > 0) {
		 $zip_code = (isset($_SESSION['cart_zip_code'])) ? $_SESSION['cart_zip_code'] : '';
		 $zip_code = (isset($_POST['zip_code'])) ? strip_tags(addslashes($_POST['zip_code'])) : $zip_code;
		 $state_zone_id = (isset($_SESSION['cart_zone'])) ? (int)$_SESSION['cart_zone'] : '';
		 $state_zone_id = (isset($_POST['zone_id'])) ? (int)$_POST['zone_id'] : $state_zone_id;
		 $selectedState = zen_db_input($_POST['state']);

		require_once('includes/classes/http_client.php'); // shipping in basket

		
		if ($_SESSION['customer_id']) {
			// user is logged in
			if (isset($_POST['address_id'])){
				// user changed address
				$sendto = $_POST['address_id'];
			}elseif ($_SESSION['cart_address_id']){
				// user once changed address
				$sendto = $_SESSION['cart_address_id'];
				//        $sendto = $_SESSION['customer_default_address_id'];
			}else{
				// first timer
				$sendto = $_SESSION['customer_default_address_id'];
			}
			$_SESSION['sendto'] = $sendto;
			// set session now
			$_SESSION['cart_address_id'] = $sendto;
			// set shipping to null ! multipickjup changes address to store address...
			$shipping='';
			// include the order class (uses the sendto !)
			require_once(DIR_WS_CLASSES . 'order.php');
            $old_order = $order; 
			$order = new order;
            $new_order_created = true; 
		}else{

			// user not logged in !
			if (isset($_POST['zone_country_id'])){
				// country is selected
				$_SESSION['country_info'] = zen_get_countries($_POST['zone_country_id'],true);
				$country_info = $_SESSION['country_info'];
				$order->delivery = array('postcode' => $zip_code,
																 'country' => array('id' => $_POST['zone_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
																 'country_id' => $_POST['zone_country_id'],
																 //add state zone_id
																 'zone_id' => $state_zone_id,
																 'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
				$_SESSION['cart_country_id'] = $_POST['zone_country_id'];
				//add state zone_id
				$_SESSION['cart_zone'] = $state_zone_id;
				$_SESSION['cart_zip_code'] = $zip_code;
			} elseif ($_SESSION['cart_country_id']){
				// session is available
				$_SESSION['country_info'] = zen_get_countries($_SESSION['cart_country_id'],true);
				$country_info = $_SESSION['country_info'];
				// fix here - check for error on $cart_country_id
				$order->delivery = array('postcode' => $_SESSION['cart_zip_code'],
																 'country' => array('id' => $_SESSION['cart_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
																 'country_id' => $_SESSION['cart_country_id'],
																 'zone_id' => $state_zone_id,
																 'format_id' => zen_get_address_format_id($_SESSION['cart_country_id']));
			} else {
				// first timer
				$_SESSION['cart_country_id'] = STORE_COUNTRY;
				$_SESSION['country_info'] = zen_get_countries(STORE_COUNTRY,true);
				$country_info = $_SESSION['country_info'];
				$order->delivery = array(//'postcode' => '',
																 'country' => array('id' => STORE_COUNTRY, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
																 'country_id' => STORE_COUNTRY,
																 'zone_id' => $state_zone_id,
																 'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
			}
			// set the cost to be able to calculate free shipping
			$order->info = array('total' => $_SESSION['cart']->show_total(), // TAX ????
													 'currency' => $currency,
													 'currency_value'=> $currencies->currencies[$currency]['value']);
		}
		// weight and count needed for shipping !
		$total_weight = $_SESSION['cart']->show_weight();
		$shipping_estimator_display_weight = $total_weight;
		$total_count = $_SESSION['cart']->count_contents();
		require_once(DIR_WS_CLASSES . 'shipping.php');
		$shipping_modules = new shipping;
		$quotes = $shipping_modules->quote();
		//print_r($quotes);
		//die('here');
		$order->info['subtotal'] = $_SESSION['cart']->show_total();

		// set selections for displaying
		$selected_country = $order->delivery['country']['id'];
 	//$selected_country = '234';

		$selected_address = $sendto;
		//}
		// eo shipping cost

		/* so no need free shipping
		// check free shipping based on order $total
		if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true')) {
			switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
				case 'national':
				if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
				case 'international':
				if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
				case 'both':

				$pass = true; break;
				default:
				$pass = false; break;
			}
			$free_shipping = false;
			if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) {
				$free_shipping = true;
				include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/order_total/ot_shipping.php');
			}
		} else {
			$free_shipping = false;
		}

		// eo no need free shipping */
		$free_shipping = false;



		// begin shipping cost
		if(!$free_shipping && $_SESSION['cart']->get_content_type() !== 'virtual'){
			if (zen_not_null($_POST['scid'])){
				list($module, $method) = explode('_', $_POST['scid']);
				$_SESSION['cart_sid'] = $_POST['scid'];
			}elseif ($_SESSION['cart_sid']){
				list($module, $method) = explode('_', $_SESSION['cart_sid']);
			}else{
				$module="";
				$method="";
			}
			if (zen_not_null($module)){
				$selected_quote = $shipping_modules->quote($method, $module);
				if($selected_quote[0]['error'] || !zen_not_null($selected_quote[0]['methods'][0]['cost'])){
					$selected_shipping = $shipping_modules->cheapest();
					$order->info['shipping_method'] = $selected_shipping['title'];
					$order->info['shipping_cost'] = $selected_shipping['cost'];
					$order->info['total']+= $selected_shipping['cost'];
				}else{
					$order->info['shipping_method'] = $selected_quote[0]['module'].' ('.$selected_quote[0]['methods'][0]['title'].')';
					$order->info['shipping_cost'] = $selected_quote[0]['methods'][0]['cost'];
					$order->info['total']+= $selected_quote[0]['methods'][0]['cost'];
					$selected_shipping['title'] = $order->info['shipping_method'];
					$selected_shipping['cost'] = $order->info['shipping_cost'];
					$selected_shipping['id'] = $selected_quote[0]['id'].'_'.$selected_quote[0]['methods'][0]['id'];
				}
			}else{
				$selected_shipping = $shipping_modules->cheapest();
				$order->info['shipping_method'] = $selected_shipping['title'];
				$order->info['shipping_cost'] = $selected_shipping['cost'];
				$order->info['total']+= $selected_shipping['cost'];
			}
		}

		/* virtual products need a free shipping
		if($_SESSION['cart']->get_content_type() == 'virtual') {
			$order->info['shipping_method'] = CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS;
			$order->info['shipping_cost'] = 0;
		}
		if($free_shipping) {
			$order->info['shipping_method'] = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
			$order->info['shipping_cost'] = 0;
		}
		*/
		$shipping=$selected_shipping;
		if (SHOW_SHIPPING_ESTIMATOR_BUTTON == '1') {
			$show_in = FILENAME_POPUP_SHIPPING_ESTIMATOR;
		} else {
			$show_in = FILENAME_SHOPPING_CART;
		}
		if(sizeof($quotes)) {
			if ($_SESSION['customer_id']) {
				$addresses = $db->execute("select address_book_id, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
				// only display addresses if more than 1
				if ($addresses->RecordCount() > 1){
					while (!$addresses->EOF) {
						$addresses_array[] = array('id' => $addresses->fields['address_book_id'], 'text' => zen_address_format(zen_get_address_format_id($addresses->fields['country_id']), $addresses->fields, 0, ' ', ' '));
						$addresses->MoveNext();
					}
				}
			} else {
				if($_SESSION['cart']->get_content_type() != 'virtual'){
					$state_array[] = array('id' => '', 'text' => PULL_DOWN_SHIPPING_ESTIMATOR_SELECT);
					$state_values = $db->Execute("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$selected_country . "' order by zone_country_id DESC, zone_name");
					while (!$state_values->EOF) {
						$state_array[] = array('id' => $state_values->fields['zone_id'],
																	 'text' => $state_values->fields['zone_name']);
						$state_values->MoveNext();
					}
				}
			}
		}

	// This is done after quote-calcs in order to include Tare info accurately.  NOTE: tare values are *not* included in weights shown on-screen.
		$totalsDisplay = '';
		// by Teddy
			switch (true) {
				case (SHOW_TOTALS_IN_CART == '1'):
				$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . TEXT_TOTAL_WEIGHT . $shipping_estimator_display_weight . TEXT_PRODUCT_WEIGHT_UNIT . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
				break;
				case (SHOW_TOTALS_IN_CART == '2'):
				$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . ($shipping_estimator_display_weight > 0 ? TEXT_TOTAL_WEIGHT . $shipping_estimator_display_weight . TEXT_PRODUCT_WEIGHT_UNIT : '') . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
				break;
				case (SHOW_TOTALS_IN_CART == '3'):
				$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
				break;
			}
		// by Teddy

		if (!isset($tplVars['flagShippingPopUp']) || $tplVars['flagShippingPopUp'] !== true) {
	/**
	 * use the template tpl_modules_shipping_estimator.php to display the result
	 *
	**/
			// by Teddy require($template->get_template_dir('tpl_modules_shipping_estimator.php', DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/' . 'tpl_modules_shipping_estimator.php');
		}
	} else { // Only do when something is in the cart
	?>
	<!--
	<h2><?php echo CART_SHIPPING_OPTIONS; ?></h2>
	<div class="cartTotalsDisplay important"><?php echo EMPTY_CART_TEXT_NO_QUOTE; ?></div>-->
	<?php
	}
	?>

	<!--<script type="text/javascript" language="javascript">update_zone(document.estimator); </script>-->
	<?php

	 require($template->get_template_dir('tpl_shipping_estimator.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes').'/'. 'tpl_shipping_estimator.php');

	 $title=SHIPPING_ESTIMATOR_SIDEBOX_TITLE;

	require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
		?>
	<!-- shipping_estimator_eof //-->

<?php
    if ($new_order_created) {  
       $order = $old_order; 
    }
}

Is how the file looks like

6 Nov 2012, 6:25 PM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shipping Estimator Sidebox compatibility?

// BEGIN CEON FIX 1 of 2
if (!$_SESSION['customer_id'] ||($current_page_base == 'login' || $current_page_base == 'create_account' ||

You left a ( in front of $current_page_base == 'login'.

6 Nov 2012, 6:27 PM
#11
shopville avatar

shopville

Zen Follower

Join Date:
Aug 2012
Posts:
331
Plugin Contributions:
0

Re: Shipping Estimator Sidebox compatibility?

That worked! thank's so much for your help!

All the Best