Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MVS Shipping Estimator - no estimate for multiple items in cart


rickheck

Recommended Posts

Sorry, but your change just masks an error. This code is an error handler. Anything that gets past this line (evaluates to true) is an error:

      if (!tep_session_is_registered ('customer_id') && (!tep_session_is_registered ('shippostcode') || !tep_session_is_registered ('shipcountry') || (!tep_session_is_registered ('shipzone') && SHIP_ESTIMATOR_USE_ZONES == 'true') ) ) {

The real problem is that one of the error conditions is not detected. The Zone needs to be checked for content if it is enabled. Add this line after the above::

          if (!tep_not_null ($_POST['shipzone']) && SHIP_ESTIMATOR_USE_ZONES == 'true' ) $error_code .= '&error_shipzone=1';

That error code then needs to be detected and an error message set in the estimator box. Try this (without your additions) and see if it now works as expected.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 9 months later...
  • 1 month later...

Jim,

 

I am trying to convert your Shipping Cost Estimator to work with my 2.3.1. store. I am having trouble converting the code to make the pop up window work with my store buttons.

I don't know how to put in the reference to the javascript function. Right now when I click the ship estimate button it just loads the information into the same window.

 

I trying to modify this:

<!-- added for pop-up ship estimator //-->
 <div class="buttonSet">
   <span class="buttonAction"><?php echo '<a href="javascript:estimatorpopupWindow' .tep_draw_button(IMAGE_BUTTON_SHIP_ESTIMATOR, 'triangle-1-e', tep_href_link(FILENAME_SHIP_ESTIMATOR, '', 'SSL')); ?></span>
 </div>
<!-- added for pop-up ship estimator end //-->

 

Right now I have this:

 

<!-- added for pop-up ship estimator //-->
 <div class="buttonSet">
   <span class="buttonAction"><?php echo '<a href="javascript:estimatorpopupWindow' .tep_draw_button(IMAGE_BUTTON_SHIP_ESTIMATOR, 'triangle-1-e', tep_href_link(FILENAME_SHIP_ESTIMATOR, '', 'SSL')); ?></span>
 </div>
<!-- added for pop-up ship estimator end //-->

 

Which does not work. Could you please help me straighten this out?

 

Thanks,

 

Varina

Link to comment
Share on other sites

I don't see any difference between those two code snippits. In any case, use the following code where you want the button to appear on shopping_cart.php:

 

// MVS Shipping Estimator start
   if (SHIP_ESTIMATOR_BUTTON_SHOPPING_CART == 'true') {
  echo tep_draw_button (IMAGE_BUTTON_SHIP_ESTIMATOR, 'check', 'javascript:estimatorpopupWindow(\'' . tep_href_link (FILENAME_SHIP_ESTIMATOR, '', 'SSL') . '\')');
   }
// MVS Shipping Estimator end

 

You also need the Javascript function it calls. Put this near the top of shopping_cart.php:

 

  // Insert the javascript for the shipping estimator popup
 $head_javascript .= '  <script language="javascript" type="text/javascript">' . "\n";
 $head_javascript .= "    function estimatorpopupWindow(URL) {window.open(URL,'shippingestimator','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600')}\n";
 $head_javascript .= '  </script>' . "\n";
 $oscTemplate->addBlock( $head_javascript, 'header_tags' );

 

That should bring up the popup for you.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Jim,

 

Thanks for the reply. I posted the wrong snippet of code yesterday. Wrong copy / paste function on my part. I should have proofread it better. Sorry about that.

 

At the top of my shopping_cart.php file I have this code:

 

<!-- added for pop-up ship estimator //-->
<SCRIPT LANGUAGE="JavaScript"><!--
 function estimatorpopupWindow(URL) {window.open(URL,'shippingestimator','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600')}
//--></script>
<!-- added for pop-up ship estimator end //-->

 

Then I used this code just above the checkout button:

 

<!-- added for pop-up ship estimator //-->
<td align="left" class="main">
<?php echo '<a href="javascript:estimatorpopupWindow(\'' .  tep_href_link(FILENAME_SHIP_ESTIMATOR, '', 'SSL') . '\')">' . tep_image_button('button_estimate_shipping.gif', IMAGE_BUTTON_SHIP_ESTIMATOR) . '</a>'; ?>
</td>
<!-- added for pop-up ship estimator end //-->

 

It works just fine. I just wanted to change button from an image to the button set my store uses using the <div> classes.

 

I tried your new code, but it isn't working with my page, the code shows up in the shopping cart, not a button.

 

I changed it to this:

 

   <?php echo tep_draw_button (IMAGE_BUTTON_SHIP_ESTIMATOR, 'check', 'javascript:estimatorpopupWindow(\'' . tep_href_link (FILENAME_SHIP_ESTIMATOR, '', 'SSL') . '\')');
  ?>

 

Now it seems to work. Now I just have to figure out how position it right and restyle the pop up window. Thanks for helping!

 

-Varina

Link to comment
Share on other sites

I spoke too soon. Everything works great in Chrome, Firefox, but in IE I am missing my infoboxes and the checkout button. I noticed I have this error:

 

 

Webpage error details

 

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)

Timestamp: Sat, 18 Feb 2012 18:24:58 UTC

 

 

Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

Line: 0

Char: 0

Code: 0

URI: http://pinecreekwood.com/catalog/shopping_cart.php

 

Any ideas on how I fix this? If I remove the javascript code my page works again.

 

Varina

Link to comment
Share on other sites

This is due to invalid HTML. Your shopping cart page has this:

 

<span class="tdbLink"><a id="tdb6" href="javascript:estimatorpopupWindow('https://pinecreekwood.com/catalog/ship_estimator.php')"><b>Get Shipping Quote</a></span>

 

Note that the bold tag is not closed. You should not be using bold here anyway: The tag is deprecated in XHTML, and bold text in the buttons should always be handled by the theme.

 

I didn't check all of your HTML, so there could be other errors as well. I suggest tunning the W3C Validator on your pages to find the errors.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Sigh. Thanks Jim. That fixed my issue for the shopping_cart file.

 

I finally got used to the code from 2.2 This 2.3.1 code is a bit harder for me to figure out. Hopefully it will start making more sense soon.

 

Now I have to go back and undo the button changes I made on the ship_estimator file...since it is throwing errors in IE too.

 

Grumble, grumble...

Link to comment
Share on other sites

Jim,

 

Sorry to keep bugging you, but I am getting frustrated on the button changes is the ship_estimator file. I found your thread on how to convert the 2.2 buttons to 2.3.1. and I thought I could figure it out, but every time I try to change the buttons in this file I lose the functionality, and get standard windows buttons instead of my theme buttons. I am not sure what I am doing wrong.

 

The three I would like to change are:

 

Close:

 

<!-- close_window //-->
 <tr>
   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 </tr>
 <tr>
   <td>
  <p class="smallText" align="center">
  <?php echo '<a href="' . tep_href_link (FILENAME_SHIP_ESTIMATOR, 'action=end', 'NONSSL') . '">' . tep_image_button('button_close_window.gif', IMAGE_BUTTON_CLOSE) . '</a>'; ?>
  </p>
   </td>
 </tr>
<!-- close_window_eof //-->

 

Reset (New Address):

<!-- reset //-->
 <tr>
   <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  <tr class="infoBoxContents">
    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="main" width="100%" align="center"><?php echo TEXT_RESET_EXPLAIN; ?> </td>
  </tr>
  <tr>
    <td><?php echo tep_draw_separator ('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
    <td class="main" width="100%" align="center"><?php echo '<a href="' . tep_href_link (FILENAME_SHIP_ESTIMATOR, 'action=reset', 'SSL') . '">' . tep_image_button('button_reset.gif', IMAGE_BUTTON_RESET_FORM) . '</a>'; ?> </td>
  </tr>
    </table></td>
  </tr>
   </table></td>
 </tr>
<!-- reset_eof //-->

 

And the Process Quote Button:

 

<!-- ship-to_form //-->
 <tr>
   <td>
   <?php echo tep_draw_form ('est_shipping_id', tep_href_link (FILENAME_SHIP_ESTIMATOR, 'action=process', 'SSL'), 'post')// . tep_draw_hidden_field('action', 'process'); ?>
   <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
  <tr class="infoBoxContents">
    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
	    <td colspan=2 class="main"><b><?php echo TITLE_SHIPPING_ADDRESS; ?></b></td>
	  </tr>
	  <tr>
	    <td class="infoBoxContents"><?php echo ENTRY_POST_CODE; ?></td>
	    <td class="infoBoxContents"><?php echo tep_draw_input_field ('shippostcode') . ' ' . (tep_not_null(ENTRY_POST_CODE) ? '<span class="inputRequirement">* Required</span>': ''); ?></td>
	  </tr>
	  <tr>
	    <td class="infoBoxContents"><?php echo ENTRY_COUNTRY; ?></td>
	    <td class="infoBoxContents"><?php echo tep_get_country_list ('shipcountry',DEFAULT_COUNTRY) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">* Required</span>': ''); ?></td>
	  </tr>
	    <td class="infoBoxContents"></td>
	    <td class="infoBoxContents"><?php echo tep_image_submit ('button_process_quote.gif', IMAGE_BUTTON_PROCESS_QUOTE); ?></td>
	  </tr>
    </table></td>
  </tr>
  <tr>
   <td width="10"><?php echo tep_draw_separator ('pixel_trans.gif', '10', '1'); ?></td>
   </tr>
   </table></form></td>
 </tr>
<!-- ship-to_form_eof //-->

 

Can these buttons be changed to the new style?

 

-Varina

Link to comment
Share on other sites

You can change the buttons, but they depend on the jQuery code in the head, so you'll have to add that as well. I just converted the whole popup page by replacing the head section with a call to template_top.php. See the instructions here.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thanks for the link Jim. I am muddling through it. But since it is a pop up window I don't really need the heading info, (logo, cart buttons...) Can I put the jquery info in without calling for template_top.php?

Link to comment
Share on other sites

You're right, that won't work. I forgot about the header part. Yes, you can add the jQuery and jQuery UI links to the head section of that page.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

You're right, that won't work. I forgot about the header part. Yes, you can add the jQuery and jQuery UI links to the head section of that page.

 

Regards

Jim

 

Yep, I could, if I knew how...

Maybe I should just give up and stick with the old buttons...blue and grey isn't that bad right?

Link to comment
Share on other sites

OK, I can help with this. Here's the files for 2.3.1 with Theme Switcher installed. If you're using the older version of Theme Switcher, add back the two lines of jQuery links, like you have in your template_top.php. If you have the latest version, this should work out of the box. This is only the two popup files, not all of the supporting stuff, since I haven't had time to fix up a release.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Thank you, thank you, thank you. :)

 

It worked except when I was logged in, then I got this error:

 

 

1054 - Unknown column 'customers_default_shipping_address_id' in 'field list'

 

select customers_default_shipping_address_id from customers where customers_id = '2'

 

[TEP STOP]

 

 

I replaced customers_default_shipping_address_id with customers_default_address_id and now everything seems to work.

 

Thank you so much. Everything matches now. :)

Link to comment
Share on other sites

I forgot to mention that code was ripped out of a working but heavily modified store. Fortunately you were able to fix the differences.

 

Someday I need to fix this up and release it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 1 year later...

Jim,

 

I have been successfully using this shipping estimator program for a while now, but now I have a problem. We have just received negotiated rates from UPS, and I have fixed my UPS XML module to recognize this change. When a customer is logged in, the shipping estimator works fine. The problem I have is that if someone is not logged in and wants to check the shipping cost I get the following error:

 

United Parcel Service

110206: Missing/Illegal ShipTo/Address/StateProvinceCode

 

Is there a way I can add the state code to the shipping estimator file so it doesn't throw this error?

 

It has been a while since I have modified this code, so a little push in the right direction would be helpful.

 

Thank you,

 

Varina

Edited by varina
Link to comment
Share on other sites

There should be a key in the configuration database table named SHIP_ESTIMATOR_USE_ZONES. Add that if it is not there and give it a value of true. The estimator will then ask a customer for their state/province if they are not signed in.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Jim,

 

I have the Use Zones Configuration set to true, but the pop up window only has entries for zip code and country code.

-Varina

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...