Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shipping in cart without addon?


Duroniel

Recommended Posts

I have been using a ship in cart addon for my store, but now my webhost have announced that they will be upgrading to PHP 5.5.4 in January. When I view my site under these new "conditions", I get errormessages in the cart from the shipping module.

 

Warning: Creating default object from empty value in C:\-----catalog\includes\modules\shipping_estimator.php on line 92

is the one I get when not logged in, and

 

Warning: Illegal string offset 'title' in C:\----catalog\includes\classes\order.php on line 222

 

Warning: Illegal string offset 'cost' in C:\----catalog\includes\classes\order.php on line 223

 

these two when I am logged in.

 

The addon I use is pretty old by now (http://addons.oscommerce.com/info/1781) and that got me thinking. I won't need the option to search postage cost by country or zip code or anything that fancy, since I only have one shipping option (well, that and free shipping for a very limited amount of customers that I have a personal relation with)

so is there a way to add this amount to the cart without the need of a fancy addon? of course the shipping cost should be included in the shown order total, for both guests and signed in customers.

Link to comment
Share on other sites

It might be easier just to clean up the old add-on. For starters, I see an error in shipping_estimator.php:

        $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,
                                'format_id' => tep_get_address_format_id($HTTP_POST_VARS['country_id']));

There is an extraneous ) on the iso_code_3 line that should be removed.

 

There are probably other fixes needed.

 

P.S. Your host is probably going to 5.4, which is the current production version. It's still a bit early to be forcing customers onto 5.5.

Edited by MrPhil
Link to comment
Share on other sites

Nope, that's not what they said I'm afraid. This is a copy from the mail I've gotten from them, in original and translated to english:

"Uppgraderingen av PHP gör att vi går från version 5.3.10 till version 5.5.5."

"The upgrade of the PHP takes us from version 5.3.10 to version 5.5.5"

 

As for the extra ), I get this message when I try to remove it:

Parse error: syntax error, unexpected ';', expecting ')' in C:\----------\includes\modules\shipping_estimator.php on line 95

Link to comment
Share on other sites

Oops, my bad. I missed the extra array( in there. Don't remove the ). Maybe tonight I can take a look at the code again and try to figure out what happened.

 

Going to 5.5 is still a bit "bleeding edge". I hope they allow you to fall back to 5.4 for at least a little while. osC 2.3.3.4 is supposed to work with 5.4, but I don't know what needs to be done for 5.5.

Link to comment
Share on other sites

Thank you so much for the help! Take all the time you need, I'm not in such a hurry ;)

 

Well, I don't think they will allow it from what I can tell, but as I said before, they had a way of testing the website for 5.5.5, and from what I can tell the only errors I see are these messages, and one about deprecated mysql code, and that one disappears after I upgrade to 2.3.3.2 I think it was.

Link to comment
Share on other sites

I suspect that $order is not being defined in shipping_estimator.php, near the top, because tep_session_is_registered() isn't behaving as expected. I recall that there were many changes to session handling in PHP 5.3+. What version of osC are you using? What was the highest PHP version and osC version that this add-on worked correctly in?

 

I'm still trying to understand the code. It appears that the only way for the $order object to be created is for the user to be logged in. In that sense, it would not be surprising that you got the error when not logged in, but why did the error not show up until now? This isn't the first time you've tried this path through the code while not logged in, is it?

 

As for the title and cost errors, they are used in the $shipping array in the cart() method of the order class. $shipping is a global variable, but it is an empty string if the $order creation in shipping_estimator.php is where it's being used. All in all, very strange in the sense of "how did this work before"?

 

The author, @@sunrise99, appears to be currently active with osC, so perhaps asking them to update the add-on for osC 2.3.3 and PHP 5.4+ might work out.

Link to comment
Share on other sites

I am using 2.3.3 at the moment, but will upgrade to the latest one when I have the time. I'm not sure about which version of PHP is the latest, but since the webhosting declared they are moving from 5.3.10, I can say that it worked on that version. As soon as I redirect my webpage to the new 5.5.5, the error appears. I don't even have to update anything in osc.

 

No, no, I have had my webshop for a bit over a year, and I have never seen these errors before, as far as I can remember.

 

I did actually write about this in the addons' support forum, but since it was so long ago anyone posted there (over a year I believe) I only waited for a few days before posting this, since I didn't think it would be updated again.

 

 

PS. Since you said the code behaves strange, it might not make a difference, but I did read something about error reporting being on when redirecting to the 5.5.5, I don't know how osc works (I think the person was talking about Joomla or something) but I don't think I personally have made any changes to hide error reporting.

Edited by Duroniel
Link to comment
Share on other sites

That first error is going to be tough to fix. All of the shipping estimators do the same thing. Most osCommerce shipping modules need certain values from the order class to work, but the class is not available until the Checkout Shipping page. Creating an instance of the class on the Shopping Cart page interferes with the checkout process. The shipping estimators get around this by defining the class values that are needed, even though the class does not yet exist. Normally this should not happen. This is a loophole/bug in PHP, at least in versions before 5.5. It appears that this has been fixed in PHP 5.5.

 

I don't have a good solution to this right now. I just wanted to let you know that it is likely that no shipping estimator will work on PHP 5.5.

 

Regards

Jim

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

Link to comment
Share on other sites

Wow... that is pretty bad news for me then... and I guess there is no way of adding/hardcoding the cost to the total either? As stated before, I only have one shipping charge (except for over a certain amount and it becomes free)

 

And is there no way of hiding this error message? It seems as though the estimator works, but it doesn't look very pretty with that message there ;)

 

Thanks for the heads-up anyway! =)

Edited by Duroniel
Link to comment
Share on other sites

If the estimator actually works for you, you can hide the error messages by changing the error display in application_top.php, around line 16-17, to:

 

// set the level of error reporting
 error_reporting(0);

 

You should do this in a live store in any case. Customers should never see error messages. Of course the opposite is true if you are developing or modifying a site in a test setup.

 

Regards

Jim

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

Link to comment
Share on other sites

I did not know that you should hide error messages in a live store, it does make a lot of sense though! I always kept them on for fixing problems with addons and the like (and for not knowing anything else), so thank you! I do have both a localhost and a "live" test, so I will keep that in mind and only hide the errors in the live one.

 

Thank you both for all the help, I really do appreciate it! :D

Link to comment
Share on other sites

  • 4 years later...

I realize this is an old thread, however,.. while redoing the Shipping Cost Estimator addon for BS Edge, I came across the same error message. See below:

[08-Jun-2018 20:41:53 America/New_York] PHP Warning:  Creating default object from empty value in /home/ ... /public_html/dev2/ship_estimator.php on line 90

I fixed it via this - in catalog/ship_estimator.php

Find the following code (around line 90 to 92):

        $country_info = tep_get_countries($shipcountry, true);

        $order->delivery = array('postcode' => $shippostcode,
                                 'country' => array('id' => $shipcountry, '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' => $shipcountry,
                                 'format_id' => tep_get_address_format_id($shipcountry));

Add just above it:

        require_once('includes/classes/order.php');
        $order = new order;

I tested it with different scenarios, both logged in and not, no errors at all.

I hope this helps anyone who may stumble upon this thread in search for a solution.

Demitry

 

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

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...