Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

General OSC and PHP question


Recommended Posts

Hi folks,


Trying to modify my site and searching through various posts and threads and the code I'm trying basically isn't working the way I would expect it to.


If I add code to application_top.php is that code executed every time someone changes page on the site?


Do I have to call the code as a function and should I add that function to general.php?


Basically, to tie in with other mods I'm using I need to test the contents of the cart while the customer is adding and removing items. It's a discount mod I'm working with but need to test for conditions as to the contents of the cart whether to apply the discount or not.


Any help much appreciated - I need this to go live on Jan 1st!


Many thanks,



Link to comment
Share on other sites

It should probably be in application_top.php and worked into the shopping cart functions; Add to cart and update cart and then it will only run when cust does something to the cart contents.

My Contributions


Stylesheet With Descriptions Glassy Grey Boxtops Our Products Meta Tags On The Fly

Password Protect Admin

"No matter where you go....There you are" - Buccaroo Bonsai

Link to comment
Share on other sites

Thanks for the reply. I have been working on this for the past 36 hrs without a break and I'm pretty square eyed at the mo!


I have discovered something peculiar, which leads me to believe that the code I was trying was actually correct. The problem lies with the Update of the cart when customers get part way through checkout, then decide to hit "Edit".


Say the customer has 3 items in the cart, gets to Checkout Confirmation and decided not to buy all 3. Hits "edit" which returns to Shopping_cart.php, but when they make changes is where things get wierd.


I remove one of the 3 items, (checkbox & hit Update) to be presented with a Cart which now has 4 items in it - 2 I want and 2 duplicate copies of the ones I want. I can then remove those 2 extra ones to be left with the 2 items I want in the Cart on the webpage.


Looking at the database while all this is happening shows ALL the items, 3 original, plus 2 duplicates, shows 5 items even though there are only 2 visible in the Cart.


Now, the code I'm trying to sort out is to allow a discount if the customer buys the Design of the Day, but if they add that to the cart then remove it, it still gives the extra discount since what's still "in the cart" doesn't match what is on the screen.


The customer still only pays for the items visible, which is where the whole thing has me flummoxed!


I have obviously screwed up shopping_cart.php with various mods so have to try to sort through which code does what.


If anyone can explain the logic of what should be happening and at what points in the checkout process that would be a really big help. The function names are pretty intuitive but troubleshooting this sort of stuff is a real pain - eg. if you don't know the sequence of "suck, squeeze, bang, blow" for a car engine how can you tell if things are happening in the right order?


Rather long but I'm wondering if anyone else has had this sort of problem?






Link to comment
Share on other sites


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

  • Create New...