Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Shipping cost in shopping cart infobox


Recommended Posts

OK I give up, I've been trying to do this for ages now and just can't work it out.


All I want to do is display the cost for the only shipping option I've got in the shopping cart infobox. It's turning out to be much harder than I thought, as it seems quite a simple thing to do.


I was thinking that maybe you need to go to checkout_shipping.php first and select the shipping option before it can give you a price, but as I only have one it's already selected.


I also tired modifying the 'Ship In Cart' contrib, it worked OK until I reached the checkout and then I just got a load of 'Cannot redeclare class' errors.


I'm completely stumped about how to get around this one.


Any help would be much appreciated.

Link to comment
Share on other sites

Anyone? :(


Surely it can't be as hard as I think, I'm probably overlooking something really obvious here.


I am really desperate for an answer to this one, so I would really appreciate it if someone shared their knowledge if they know how to get around this one.


Thanks. :D

Link to comment
Share on other sites



The ShipInCart should work for you. The "cannot redeclare class" errors are most likely because you added or amended a shipping module and there's another one still in your shipping module directory that has the same class declaration.


For example, zones.php has a line in it "class zones". If you create another zones module, say zones_2.php, which also has the line "class zones" instead of "class zones_2" - you will get this error.

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

Thanks for your reply Stuart.


I'm sure the reason I was getting the errors is because the classes (there are a few that couldn't be redeclared) had already been declared in the checkout_*.php files.


I say this because it works perfectly on other pages such as index.php where no other shipping info is displayed on the main page.


I only currently have one shipping module, which is table rate.


I am interested in the last part of your reply, the example about zones, although I'm not sure I understand. Are you saying that if I copy the class and rename it it should work?

Link to comment
Share on other sites

I probably misunderstood what you were trying to do if you're trying to show the shipping cost in the infobox that appears in column_right by default. I thought you were talking about the page that appears when you actually look at your shopping cart for which ShipInCart should work just fine - unless (this is what the last part of my previous response was about)


If you had 2 shipping modules, the second of which had been created by making a copy of the first, you would need to rename the class in your second module or you would get the "cannot redeclare class" error. This would be true even if one of the two modules wasn't "activated" in your Admin area - as long as the file is on the server in the shipping directory with a php extension, I think it will be parsed.


Back to the shipping amount in the Shopping Cart InfoBox...


If the customer has not told the system yet where they are, I'm not sure that the shipping information exists yet. In the case of ShipInCart, the information is presented by virtue of their zipcode (or by default, the store's zipcode) being entered, if I'm not mistaken. In the cart infobox, the only info the system has initially is what item(s) were added to it.


That being said, I would think you could do what you're trying to do, but I think you would need an input field also for the shipping destination unless you have the same rate to every location, otherwise the best you could hope for would be a rate to your store location's zipcode. I'll have to look at ShipInCart a little closer in the next couple of days to see if I can determine what would work without causing the redeclare errors.


PS- I'm not very familiar with PHP, but don't I recall seeing a declare_once command or something similar? That might get around the problem if such a command exists.

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

Thanks again for your reply Stuart.


I'll have a play around and see if I can work something out.


What I'm thinking is to include the shipping_estimator.php file (from the Ship In Cart contrib), and copy and rename the classes that it calls upon.


Does anyone know if this is likely to work before I start, as I don't really want to try and do something that will never work.


Any suggestions would be appreciated.

Link to comment
Share on other sites

  • 2 years later...


This topic is now archived and is closed to further replies.

  • Create New...