Post by comiclair » Sun Sep 06, 2009 1:13 pm

I am not sure this a bug or I am not understanding how the missing order is suppose to work

I just noticed when I deleted my missing orders it add back all the quantities which it should if it deducted them but it turns out the quantities are at more than what I actually started with. I would think if the order never got placed it shouldn't pull quantities from the item or add them back when I clear the missing order section . So has anyone else experience this

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Sun Sep 06, 2009 11:55 pm

Weird, I dont seem to have this problem. I have alot of missing orders, as I have been coding a payment module, but it doesn't seem like it touches the quantity.

Do you have any contributions installed?

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 12:15 am

I do have contributions added and some other things I bought but I don't do programming so I am not sure if they had an effect on it.

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 12:38 am

Hi again,

I did some testing, and I DO have this problem, if "Stock Subtract" is enabled under Settings. Hmm, I'll look into it later.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 12:46 am

thanks and I appreciate any help.

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 1:35 am

Open this file: admin/model/customer/order.php

Find this at around line 53:

Code: Select all

		if ($this->config->get('config_stock_subtract')) {
			foreach($products as $product) {
				$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
			}
		}
Replace with:

Code: Select all

		if ($this->config->get('config_stock_subtract')) {
			foreach($products as $product) {
                if ($product['order_status_id'] != 0) {
				    $this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
                }
            }
		}
Find this, at around line 122:

Code: Select all

	public function getOrderProducts($order_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
	
		return $query->rows;
	}
Replace with:

Code: Select all

	public function getOrderProducts($order_id) {
		$query = $this->db->query("SELECT op.*, o.order_id, o.order_status_id FROM " . DB_PREFIX . "order_product op, " . DB_PREFIX . "order o WHERE op.order_id='" . (int)$order_id ."' AND op.order_id = o.order_id");

		return $query->rows;
	}
That should do the trick. Please let me know if you run into problems. I just tested it quickly, and it seems to work.
Last edited by dbstr on Mon Sep 07, 2009 3:02 am, edited 1 time in total.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 2:14 am

I changed the code and when I went to log in into the admin i get and error:

Parse error: syntax error, unexpected T_PUBLIC in /hermes/web09/b2036/xxxxxxx/htdocs/shop/admin/model/customer/order.php on line 61

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 2:16 am

Could you paste line 61, and the 10 lines above it?

But I'm pretty sure it's because you miss a } somewhere near line 60. :)

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 2:33 am

here is line 51 - 61:

$this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");

if ($this->config->get('config_stock_subtract')) {
foreach($products as $product) {
if ($product['order_status_id'] != 0) {
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
}
}
}

public function getOrder($order_id) {

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 2:35 am

Code: Select all

	$this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");

	if ($this->config->get('config_stock_subtract')) {
		foreach($products as $product) {
			if ($product['order_status_id'] != 0) {
				$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
			}
		}
	}
}

public function getOrder($order_id) {
Should work. :)

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 2:41 am

I can now log in but when i go to order section in admin I get an error when I click on the order : The error is :

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order o WHERE op.order_id='155' AND op.order_id = o.order_id' at line 1
Error No: 1064
SELECT op.*, o.order_status_id FROM order_product op, order o WHERE op.order_id='155' AND op.order_id = o.order_id

I checked my completed orders and they have a similar error

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 2:48 am

Ok. Could you tell me your mysql version?

And you should probably undo the changes, till I got a fix for you. >:(

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by comiclair » Mon Sep 07, 2009 2:54 am

The MySQL is version 5 if you need more info let me know.

Active Member

Posts

Joined
Sun Jun 07, 2009 5:08 am
Location - Trenton, NJ

Post by dbstr » Mon Sep 07, 2009 4:23 am

We figured it out in private messages.

Should others run into the same problem, add `` around the database tables in the getOrderProducts sql query.

Code: Select all

   public function getOrderProducts($order_id) {
      $query = $this->db->query("SELECT op.*, o.order_id, o.order_status_id FROM `" . DB_PREFIX . "order_product` op, `" . DB_PREFIX . "order` o WHERE op.order_id='" . (int)$order_id ."' AND op.order_id = o.order_id");

      return $query->rows;
   }
It's simply because ORDER is a reserved SQL word, and if you dont use prefixed tables it will cause an error. My bad, no-brainer...

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am
Who is online

Users browsing this forum: No registered users and 20 guests