Re: Hide Available Shipping Methods table until Shipping Estimator runs
Quote:
Originally Posted by
Beagle
Fair enough. Did not mean to suggest that this change would fix a conflict with a shipping module.
Note the ! - checks for customer NOT logged in.
The logic of the shipping estimator is something like:
IF (customer is logged in) THEN
Use customer's address information for shipping estimate
ELSE
Present form to collect Country, State, Zip and use this for shipping estimate
END IF
But if the customer is logged in, the variables set by the form under ELSE are not set. Therefore the display of the shipping estimate is not presented, since the modification discussed here disables the display if any of the variables are not set. My additional condition ignores all the other conditions if the customer is logged in.
I present this should someone else have the same display issue - as far as I can tell, the original code cannot work if the customer is logged in.
Read your ealier post a bit too fast.. So I stand corrected.. You are right the original code probably never worked when a customer was logged in.. (admittedly I never tested this when I first used it..) so in the name of clarity gonna post the FULL change (makes it easier for folks following this if they don't have to piece together the change)
This is a replacement for the /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_shipping_estimator.php. There are two areas that were changed, just look for the //-bof and //-eof comments.
Code:
<?php
}
}
if($_SESSION['cart']->get_content_type() == 'virtual'){
?>
<?php echo CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS; ?>
<?php
}elseif ($free_shipping==1) {
?>
<?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)); ?>
<?php
}else{
//-bof-No display until country/state/zip are entered (1 of 2)
if (($selected_country == 0 || ($selectedState == '' && $state_zone_id == 0) || $zip_code == '') && (!$_SESSION['customer_id'])) {
if (!defined(TEXT_ENTER_ALL_VALUES)) define ('TEXT_ENTER_ALL_VALUES', 'Please select your country, state and zipcode so that we can can retrieve an accurate shipping estimate.');
echo '<p>' . TEXT_ENTER_ALL_VALUES . '</p>';
} else {
//-eof-No display until country/state/zip are entered (1 of 2)
?>
<table width="100%" border="1" cellpadding="2" cellspacing ="2">
<?php if ($_SESSION['customer_id'] < 1 ){ ?>
<tr>
<td colspan="2" class="seDisplayedAddressLabel">
<?php echo CART_SHIPPING_QUOTE_CRITERIA; ?><br />
<?php echo '<span class="seDisplayedAddressInfo">' . zen_get_zone_name($selected_country, $state_zone_id, '') . ($selectedState != '' ? ' ' . $selectedState : '') . ' ' . $order->delivery['postcode'] . ' ' . zen_get_country_name($order->delivery['country_id']) . '</span>'; ?>
</td>
</tr>
<?php } ?>
<tr>
<th scope="col" id="seProductsHeading"><?php echo CART_SHIPPING_METHOD_TEXT; ?></th>
<th scope="col" id="seTotalHeading"><?php echo CART_SHIPPING_METHOD_RATES; ?></th>
</tr>
<?php
for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
if(sizeof($quotes[$i]['methods'])==1){
// simple shipping method
$thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][0]['id'];
?>
<tr class="<?php echo $extra; ?>">
<?php
if($quotes[$i]['error']){
?>
<td colspan="2"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['error']; ?>)</td>
</tr>
<?php
}else{
if($selected_shipping['id'] == $thisquoteid){
?>
<td class="bold"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
<td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}else{
?>
<td><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
<td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}
}
} else {
// shipping method with sub methods (multipickup)
for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
$thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][$j]['id'];
?>
<tr class="<?php echo $extra; ?>">
<?php
if($quotes[$i]['error']){
?>
<td colspan="2"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['error']; ?>)</td>
</tr>
<?php
}else{
if($selected_shipping['id'] == $thisquoteid){
?>
<td class="bold"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
<td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}else{
?>
<td><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
<td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}
}
}
}
}
?>
</table>
<?php
}
//-bof-No display until country/state/zip are entered (2 of 2)
}
//-eof-No display until country/state/zip are entered (2 of 2)
}
?>
</form>
</div>
Re: Hide Available Shipping Methods table until Shipping Estimator runs
Quote:
Originally Posted by
DivaVocals
Read your ealier post a bit too fast.. So I stand corrected.. You are right the original code probably never worked when a customer was logged in.. (admittedly I never tested this when I first used it..) so in the name of clarity gonna post the FULL change (makes it easier for folks following this if they don't have to piece together the change)
This is a replacement for the
/includes/templates/YOUR_TEMPLATE/templates/tpl_modules_shipping_estimator.php. There are two areas that were changed, just look for the //-bof and //-eof comments.
Code:
<?php
}
}
if($_SESSION['cart']->get_content_type() == 'virtual'){
?>
<?php echo CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS; ?>
<?php
}elseif ($free_shipping==1) {
?>
<?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)); ?>
<?php
}else{
//-REMOVE -- REMOVE -- REMOVE -- REMOVE --
if (($selected_country == 0 || ($selectedState == '' && $state_zone_id == 0) || $zip_code == '') && (!$_SESSION['customer_id'])) {
if (!defined(TEXT_ENTER_ALL_VALUES)) define ('TEXT_ENTER_ALL_VALUES', 'Please select your country, state and zipcode so that we can can retrieve an accurate shipping estimate.');
echo '<p>' . TEXT_ENTER_ALL_VALUES . '</p>';
} else {
//-REMOVE -- REMOVE -- REMOVE -- REMOVE --
?>
//-BOF REMOVE TABLE TILL ZIP CODE ENTERED OR CUSTOMER SESSION EXISTS
<?php if ($_SESSION['customer_id'] < '1' and !empty($order->delivery['postcode']) or $_SESSION['customer_id']){ ?>
//-EOF REMOVE TABLE TILL ZIP CODE ENTERED OR CUSTOMER SESSION EXISTS
<table width="100%" border="1" cellpadding="2" cellspacing ="2">
//-MOVE ABOVE <HTML TABLE> AND CHANGE TO RED CODE
<?php if ($_SESSION['customer_id'] < 1 ){ ?>
//-MOVE ABOVE <HTML TABLE> AND CHANGE TO RED CODE
<tr>
<td colspan="2" class="seDisplayedAddressLabel">
<?php echo CART_SHIPPING_QUOTE_CRITERIA; ?><br />
<?php echo '<span class="seDisplayedAddressInfo">' . zen_get_zone_name($selected_country, $state_zone_id, '') . ($selectedState != '' ? ' ' . $selectedState : '') . ' ' . $order->delivery['postcode'] . ' ' . zen_get_country_name($order->delivery['country_id']) . '</span>'; ?>
</td>
</tr>
//-REMOVE -- REMOVE -- REMOVE -- REMOVE --
<?php } ?>
//-REMOVE -- REMOVE -- REMOVE -- REMOVE --
<tr>
<th scope="col" id="seProductsHeading"><?php echo CART_SHIPPING_METHOD_TEXT; ?></th>
<th scope="col" id="seTotalHeading"><?php echo CART_SHIPPING_METHOD_RATES; ?></th>
</tr>
<?php
for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
if(sizeof($quotes[$i]['methods'])==1){
// simple shipping method
$thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][0]['id'];
?>
<tr class="<?php echo $extra; ?>">
<?php
if($quotes[$i]['error']){
?>
<td colspan="2"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['error']; ?>)</td>
</tr>
<?php
}else{
if($selected_shipping['id'] == $thisquoteid){
?>
<td class="bold"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
<td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}else{
?>
<td><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][0]['title']; ?>)</td>
<td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}
}
} else {
// shipping method with sub methods (multipickup)
for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
$thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][$j]['id'];
?>
<tr class="<?php echo $extra; ?>">
<?php
if($quotes[$i]['error']){
?>
<td colspan="2"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['error']; ?>)</td>
</tr>
<?php
}else{
if($selected_shipping['id'] == $thisquoteid){
?>
<td class="bold"><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
<td class="cartTotalDisplay bold"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}else{
?>
<td><?php echo $quotes[$i]['module']; ?> (<?php echo $quotes[$i]['methods'][$j]['title']; ?>)</td>
<td class="cartTotalDisplay"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])); ?></td>
</tr>
<?php
}
}
}
}
}
?>
</table>
<?php
}
//-bof-No display until country/state/zip are entered (2 of 2) KEEP
}
//-eof-No display until country/state/zip are entered (2 of 2) KEEP
}
?>
</form>
</div>
Hope this helps and what you are looking to do.
Re: Hide Available Shipping Methods table until Shipping Estimator runs
Quote:
Originally Posted by
rbarbour
Hope this helps and what you are looking to do.
Honestly speaking what you posted isn't clear all.. the blue and red coloring confuses rather than clarifies things.. I tried your code and it doesn't work, and breaks a few things.. The code I posted (lat9's original code + the changes Beagle made) does achieve the original objective "Hide Available Shipping Methods table until Shipping Estimator runs", and now it works whether you are logged in or not.. Plus it has the added bonus of providing a nice on-screen message to remind the site visitor to enter the required info needed to obtain a shipping estimate..
Re: Hide Available Shipping Methods table until Shipping Estimator runs
Quote:
Originally Posted by
DivaVocals
Honestly speaking what you posted isn't clear all.. the blue and red coloring confuses rather than clarifies things.. I tried your code and it doesn't work, and breaks a few things..
"Hit" Post Quick Reply prematurely, to late to edit and I figured I would get a response anyways.
Quote:
Originally Posted by
DivaVocals
The code I posted (lat9's original code + the changes Beagle made) does achieve the original objective "Hide Available Shipping Methods table until Shipping Estimator runs", and now it works whether you are logged in or not.. Plus it has the added bonus of providing a nice on-screen message to remind the site visitor to enter the required info needed to obtain a shipping estimate..
Yes it does, maybe I will read entire threads before I post. lol
Re: Hide Available Shipping Methods table until Shipping Estimator runs
Quote:
Originally Posted by
rbarbour
"Hit" Post Quick Reply prematurely, to late to edit and I figured I would get a response anyways.
Yes it does, maybe I will read entire threads before I post. lol
:laugh: Yeah.. well I did the same thing earlier in this thread.. It's all good!!
Re: Hide Available Shipping Methods table until Shipping Estimator runs
Re: Hide Available Shipping Methods table until Shipping Estimator runs
How would i add this to zen 1.56c shipping estimator file
Re: Hide Available Shipping Methods table until Shipping Estimator runs
trying to add this to zen version 2.10 with php 8.0 and am getting this error
Code:
[10-Dec-2024 18:29:48 America/New_York] Request URI: /index.php?main_page=shopping_cart, IP address: 35.139.236.145, Language id 1
#1 require(/includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php) called at [/includes/modules/shipping_estimator.php:302]
#2 require(/includes/modules/shipping_estimator.php) called at [/includes/templates/wokiee/templates/tpl_shopping_cart_default.php:188]
#3 require(/includes/templates/wokiee/templates/tpl_shopping_cart_default.php) called at [/includes/templates/wokiee/common/tpl_main_page.php:167]
#4 require(/includes/templates/wokiee/common/tpl_main_page.php) called at [/index.php:94]
--> PHP Warning: Undefined variable $zip_code in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php on line 115.
[10-Dec-2024 18:29:48 America/New_York] Request URI: /index.php?main_page=shopping_cart, IP address: 35.139.236.145, Language id 1
#1 require(/includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php) called at [/includes/modules/shipping_estimator.php:302]
#2 require(/includes/modules/shipping_estimator.php) called at [/includes/templates/wokiee/templates/tpl_shopping_cart_default.php:188]
#3 require(/includes/templates/wokiee/templates/tpl_shopping_cart_default.php) called at [/includes/templates/wokiee/common/tpl_main_page.php:167]
#4 require(/includes/templates/wokiee/common/tpl_main_page.php) called at [/index.php:94]
--> PHP Warning: Undefined array key "customer_id" in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php on line 115.
[10-Dec-2024 18:29:48 America/New_York] PHP Fatal error: Uncaught Error: Undefined constant "TEXT_ENTER_ALL_VALUES" in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php:116
Stack trace:
#0 /includes/modules/shipping_estimator.php(302): require()
#1 /includes/templates/wokiee/templates/tpl_shopping_cart_default.php(188): require('...')
#2 /includes/templates/wokiee/common/tpl_main_page.php(167): require('...')
#3 /index.php(94): require('...')
#4 {main}
thrown in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php on line 116
[10-Dec-2024 18:29:48 America/New_York] Request URI: /index.php?main_page=shopping_cart, IP address: 35.139.236.145
--> PHP Fatal error: Uncaught Error: Undefined constant "TEXT_ENTER_ALL_VALUES" in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php:116
Stack trace:
#0 /includes/modules/shipping_estimator.php(302): require()
#1 /includes/templates/wokiee/templates/tpl_shopping_cart_default.php(188): require('...')
#2 /includes/templates/wokiee/common/tpl_main_page.php(167): require('...')
#3 /index.php(94): require('...')
#4 {main}
thrown in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php on line 116.
[10-Dec-2024 18:29:48 America/New_York] Request URI: /index.php?main_page=shopping_cart, IP address: 35.139.236.145
--> PHP Fatal error: Uncaught Error: Undefined constant "TEXT_ENTER_ALL_VALUES" in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php:116
Stack trace:
#0 /includes/modules/shipping_estimator.php(302): require()
#1 /includes/templates/wokiee/templates/tpl_shopping_cart_default.php(188): require('...')
#2 /includes/templates/wokiee/common/tpl_main_page.php(167): require('...')
#3 /index.php(94): require('...')
#4 {main}
thrown in /includes/templates/wokiee/templates/tpl_modules_shipping_estimator.php on line 116.
Re: Hide Available Shipping Methods table until Shipping Estimator runs
added this
Code:
'TEXT_ENTER_ALL_VALUES' => 'Please select your country, state and zipcode so that we can can retrieve an accurate shipping estimate.',
to lang.english.php
than i changed $zip_code to $postcode
and modified this
Code:
//-bof-No display until country/state/zip are entered (1 of 2)
if (($selected_country == 0 || ($selectedState == '' && $state_zone_id == 0) || $postcode == '') && (!$_SESSION['customer_id'])) {
echo '<p>' . TEXT_ENTER_ALL_VALUES . '</p>';
} else {
//-eof-No display until country/state/zip are entered (1 of 2)
this works in zen 210