Jump to content

Which file is responsible for adding an order to the database


Guest TeKn1qu3z

Recommended Posts

Guest TeKn1qu3z

I, with the help of a friend made a few modifications to my store.

Now I have discovered a flaw and would like to look more closely at the changes I made.

I'm having a problem with a customers order being overwritten if an order is placed more than once consecutively.

I'm just wondering which file is responsible for adding a new order to the database.

Link to comment
Share on other sites

That would be the file: \includes\content\gateway.inc.php where the customer's cookie is used to fetch their shopping cart contents (called a 'basket') and creates a store order (cart_order_id). The code then deposits a record of every item in the basket into the order_inv table, sends an email to the store manager, deposits a record of the overall transaction into the order_sum table, and finally fills in the placeholders in the STEP 5 checkout process with payment options.

If the line that creates a cart_order_id has been changed, it may no longer be creating unique ids.

If a customer returns to here (STEP 5 of checkout) with a cart_order_id already memorized in the basket details (say, a customer gets to STEP 5 and decides to do more shopping), the order_inv and order_sum records that match that cart_order_id is first deleted before being re-recorded with the current basket contents.

Link to comment
Share on other sites

I think the issue is that your basket contents (in the session table, based on a sessionId which is tied to a customer's cookie) aren't being destroyed by a successful checkout workflow. An incomplete or malfunctioning payment gateway that does not unset a session will be as if a customer is still present in the store and just before making final payment decides to do more shopping. See the previous paragraph.

The file you want here is: \includes\orderSuccess.inc.php whose job is to send a "Thank you" email (with links to the digital products), update the order status to Processing in the order_sum table, and unset the customer's session.

Link to comment
Share on other sites

Guest TeKn1qu3z

Thank would make sense.

I have noticed thru some testing that my gateway does have a problem and does keep what is left over in their cart.

Is there a way to make it somehow destroy the cookie, or empty the cart?

Link to comment
Share on other sites

Guest TeKn1qu3z

What is the name of the session that holds all the cart information?

Would it work if I had an unset($_SESSION['cart']) somewhere at the end of my gateway?

Link to comment
Share on other sites

What is the name of the session that holds all the cart information?

Look carefully at the contents of the Cubecart_sessions table. The `basket` field contains a serialized string of data that contains the customer's shopping cart.

Would it work if I had an unset($_SESSION['cart']) somewhere at the end of my gateway?

No. Look at the last lines of the orderSuccess.inc.php file. If you copy those lines to your gateway, that will delete the session. However, your gateway probably does not connect to the database, so you will need to include the db class and instantiate a db instance before you execute the class's method.

Link to comment
Share on other sites

Guest TeKn1qu3z

Could you point me in the right direction to do that?

This is the empty basket function from orderSuccess

// empty basket

$emptyBasket['basket'] = "''";

$where = "basket LIKE '%".$cart_order_id."%'";

$delete = $db->update($glob['dbprefix']."CubeCart_sessions",$emptyBasket ,$where);

How do I connect to the DB and get these commands to work?

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