We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Shopping Cart From Hell

Development and Programming

johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

I inherited an unidentified php shopping cart distributed among several EE templates (cart/index, cart/info, cart/complete) The cart/index template includes an algorithm that sets a discount price on seminars IF the date is less than 30 days before seminar, ELSE the price is full:

thetime= time() if($_POST[‘radGenConf’] == ‘Mohegan Sun April 2011’ && $thetime < mktime(24, 0, 0, 3, 22, 2011)) { $theprice = ‘150.00’; } elseif($_POST[‘radGenConf’] == ‘Trump Marina October 2011’ && $thetime < mktime(24, 0, 0, 9, 4, 2011)) { $theprice = ‘150.00’; } else { $theprice = ‘175.00’;

The cart has worked for years without problems - all I’ve had to do is tweak the dates each year. But suddenly, some demon has gotten into the code, and the price for the upcoming April 22 conference didn’t change from $150 to $175 on March 22. This is costing my client money every day.

I’ve done everything I can think of, even commenting out the IF clauses entirely. No joy. Even when I manually assign a different value to $theprice, it always stays at $150 in the shopping cart. Where can it be coming from? Is there some way to view the value of $theprice and mktime as I run the code? Some independent list of variables and values and strings and their current values? I suppose I could install phpMyAdmin, but that process seems tremendously complicated and I need this solved ASAP. Doesn’t EE have some kind of functionality to handle this?

Thanks

       
lebisol's avatar
lebisol
2,234 posts
15 years ago
lebisol's avatar lebisol

To see if the variable is hardcoded somewhere else or before this snip use use php print:

print "Price is at: $theprice";

EE can run query modulee where you can slap raw sql to look for things in the database or use: CP Home / Tools / Data / SQL Manager / Manage Database Tables if that is what you are after. There are (google for your OS) also free mysql gui tools so you don’t have to mess with phpMyAdmin.

Hard to say what is going on without being able to follow the breadcrumbs of your templates.

       
johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

Lebisol, Thanks for replying.

I pasted your command exactly into Database Query Form (CP/ADMIN/Utilities/SQL Manager/Database Query Form) and got “The query you submitted did not produce any results”

Don’t know exactly what to make of that.

I get the basic idea, that I can run lots of stuff in the Query Manager beyond basic SQL commands. Unfortunately, I’m just learning SQL - SELECT and APPEND were new to me a week ago. My experience is all dBase FoxPro Access VB.

If you can help further, I’ll happily give you better breadcrumbs. Just tell me how to do it.

       
lebisol's avatar
lebisol
2,234 posts
15 years ago
lebisol's avatar lebisol

No I am sorry I should have said, place that snip into your php enabled template to see if the variable is coming form somewhere else. So comment out what you shared above and just use the snip. If you do get some output that means there this variable is defined somewhere else in the template. Did the server undergo some updates that would change its system date/time and especially php updates?

The CP/ADMIN/Utilities/SQL Manager/Database Query Form is in case you wanted to look into specific table - a non-EE table such as ‘cart’ or something in that sense and run a simple SELECT query.

Edit: I just noticed that viable is not defined right or not copy-pasted right:

thetime= time()

should be

$thetime= time()
       
johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

Thanks for staying with me on this.

It’s “$the time” - my copy & paste error. Re: server updates, there has been some trouble with our ISP. Is there a quick way to check the system date?

I don’t understand what you mean by “place that snip into your php enabled template” - you mean just add it into the same template that’s running the shopping cart? If I do that, where will it print? I’m working with the actual site and I don’t want to scare customers away.
JB

       
JT Thompson's avatar
JT Thompson
745 posts
15 years ago
JT Thompson's avatar JT Thompson

IMO the firs task would be creating a dev environment. you should never be working on production templates on a live site.

Just make a new group, call it ‘dev’ or whatever, and copy your cart group contents. of course you’d also need to duplicate the includes, or whatever other groups, and set things to use the dev side. that way you can test without affecting the live site

       
johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

Thanks JT. I agree. The original developer apparently never set up a dev area, but up until now the stuff I’ve had to do on the site has very minor, quick and easy, so I’ve gotten away with working with the actual site. I’d love to have a dev area, but I need step-by-step directions at a newbie level on how to set that up. Intuitively I imagine duplicating the whole site in the dev area, but I don’t know how to begin doing that. I’ve never even created a new group, just worked with what’s there, changing as little as possible, and trying to learn as I go how it works. CP/Templates?Template Management shows 9 groups - site; seminars, vacations, products (the three things we sell); and includes, scripts, style, cart, and orders. How do I “set things to use the dev side” ? I’ll start searching help on this but the pressing need right now is to get the emergency handled quickly.

       
JT Thompson's avatar
JT Thompson
745 posts
15 years ago
JT Thompson's avatar JT Thompson

Well, it’d take a little knowledge to do. you’d need to go through all the templates in the newly created group and make sure it’s calling everything from the dev side.

you’d also need to look at your global vars and make sure they’d work in a new dev environment too.

You’ll need to set things up so adapt to the new URL. since you’d be adding a /dev/ before the group name, you’d need to change anything that says segment_x to go up one. so change segment_2 to segment_3 if they used that. and of course embeds would all need to be edited to call from the dev/group too.

it really does need some EE knowledge though if the original dev leveraged the functions of EE. don’t think i’d attempt it without a good understanding.

       
JT Thompson's avatar
JT Thompson
745 posts
15 years ago
JT Thompson's avatar JT Thompson
To see if the variable is hardcoded somewhere else or before this snip use use php print:
print "Price is at: $theprice";
EE can run query modulee where you can slap raw sql to look for things in the database or use: CP Home / Tools / Data / SQL Manager / Manage Database Tables if that is what you are after. There are (google for your OS) also free mysql gui tools so you don’t have to mess with phpMyAdmin. Hard to say what is going on without being able to follow the breadcrumbs of your templates.

just a note here. i always used CLI or phpMyAdmin for MySQL management, but if you have the ability allow remote access to the db’s I highly recommend Navicat. it’s been a big time saver for me.

       
johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

Thanks again. I’ll check out Navicat. At this point however I think I need to hire someone who’s php shopping-cart knowledgable to get in to the code with me and just fix it. Probably wouldn’t take long as I can act as a guide through the setup. Hopefully someone willing to work at non-profit rates. Any ideas?

       
johnnyb's avatar
johnnyb
45 posts
15 years ago
johnnyb's avatar johnnyb

This particular cycle has ended well. This old Tyrannosaurus finally bit the bullet and hired one of those speedy little Velociraptors from India at $15/hr - Hemang Dani ([email protected]) and he Skyped me through it in no time at all. Turns out it had nothing to do with the sql or php price/date algorithm. I’d simply forgotten to update the name of the form in the path of the FORM ACTION= statement, way down in the HTML, when I updated the name of the the template for 2011. Hemang just had me debug it with ECHO $_SERVER [‘PHP_SELF’]; after IF($_POST) { - and boom, that was that, problem revealed.

I promised Hemang I’d tell my friends. It’s really a new world out there. Programmers for $10, $15/hr! And they VOLUNTEER to Skype you - no more unwieldy wait for emails, no more having to type long descriptions of the problem - you can just talk to a real human being and work on the problem together. EE, take note. Skype is the future of support. You just click Share and pick a window for the other person to view.

JB

       
lebisol's avatar
lebisol
2,234 posts
15 years ago
lebisol's avatar lebisol

‘register’ vs. ‘register-2011’ 😊 Glad you got it resolved.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.