I did all the changes, but then I just get a white store. The admin-area works fine, the Stock by Attributes is there in my 1.5, but my store is just plain white.
Anyone knows why that is?
Printable View
I did all the changes, but then I just get a white store. The admin-area works fine, the Stock by Attributes is there in my 1.5, but my store is just plain white.
Anyone knows why that is?
Did you merge the code or copy it? In order for this to work, you must merge the code and merge only those sections labeled for stock by attributes. The problem here is that the code sections were not labeled in some of the files, and it gets a little tricky - but still doable.
Toneklone,
Did you resolve this issue? If so how? I am having the same problem and I did merge the files. I'm pretty sure the issue is with the file: admin/includes/functions/general.php
But you have to restore all the original ZC files that were modified or overwritten before the white screen returns to normal. I checked my site each time I uploaded a merged file and the one stated above was what sent my site to a white screen. Just restoring that file didn't fix it though.
If anyone else could help it would be much appreciated. Thank you.
ATTENTION: Restock Feature has been FIXED!!!!
Sorry for the caps, but I am just too excited :D
I really had to get the functionality of this feature to start working, well because, a typical order for my store might contain numerous products, and having to manually edit the stock for each product when I deleted a large order was not practical.
So without further Adieu! -
In \admin\includes\functions\general.php look for the following code:
And replace with...Code:function zen_remove_order($order_id, $restock = false) {
global $db, $order;
if ($restock == 'on') {
$order = $db->Execute("select products_id, products_quantity
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'");
while (!$order->EOF) {
//restored db
$restored_attributes = $db->Execute("select pa.products_attributes_id
from ".TABLE_ORDERS_PRODUCTS_ATTRIBUTES." opa, ".TABLE_PRODUCTS_ATTRIBUTES." pa
where opa.orders_id='".(int)$order_id."'
and opa.products_options_id = pa.options_id
and pa.options_values_id = opa.products_options_values_id
and pa.products_id='".(int)$order->fields['products_id']."'
ORDER BY pa.products_attributes_id ASC
");
while(!$restored_attributes->EOF) {
$attr_array[] = $restored_attributes->fields['products_attributes_id'];
$restored_attributes->MoveNext();
}
//echo implode(',', $attr_array);die;
$db->Execute("update ".TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK."
set quantity = quantity + " . $order->fields['products_quantity'] . "
where products_id = '" . (int)$order->fields['products_id'] . "'
and stock_attributes = '".implode(',', $attr_array)."'
");
$db->Execute("update " . TABLE_PRODUCTS . "
set products_quantity = products_quantity + " . $order->fields['products_quantity'] . ", products_ordered = products_ordered - " . $order->fields['products_quantity'] . " where products_id = '" . (int)$order->fields['products_id'] . "'");
$order->MoveNext();
}
}
But just a little background and forewarning, I am by no means a programmer, just a noobie, but proficient computer nerd who has had a little background in programming back in college. I sat down for the past 12 hours trying to dissect the logic of tying the line items of the ORDERS_PRODUCTS table (which records each of your unique products sold and in what quantities) to the PRODUCTS_WITH_ATTRIBUTES_STOCK table (which contains your master list of stock for each unique attribute of your product inventory) in the zen-cart database, and realized that the arguments utilized were not specific enough to appropriately identify tie the two tables together accurately.Code:function zen_remove_order($order_id, $restock = false) {
global $db, $order;
if ($restock == 'on') {
$order = $db->Execute("select orders_products_id, products_id, products_quantity
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'");
while (!$order->EOF) {
//restored db
$restored_attributes = $db->Execute("select pa.products_attributes_id
from ".TABLE_ORDERS_PRODUCTS_ATTRIBUTES." opa, ".TABLE_PRODUCTS_ATTRIBUTES." pa
where opa.orders_id='".(int)$order_id."'
and opa.products_options_id = pa.options_id
and opa.products_options_values_id = pa.options_values_id
and opa.orders_products_id='".(int)$order->fields['orders_products_id']."'
and pa.products_id='".(int)$order->fields['products_id']."'
ORDER BY pa.products_attributes_id ASC
");
while(!$restored_attributes->EOF) {
$attr_array[] = $restored_attributes->fields['products_attributes_id'];
$restored_attributes->MoveNext();
}
$db->Execute("update ".TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK."
set quantity = quantity + " . $order->fields['products_quantity'] . "
where products_id = '" . (int)$order->fields['products_id'] . "'
and stock_attributes = '".implode(',', $attr_array)."'
");
$db->Execute("update " . TABLE_PRODUCTS . "
set products_quantity = products_quantity + " . $order->fields['products_quantity'] . ", products_ordered = products_ordered - " . $order->fields['products_quantity'] . " where products_id = '" . (int)$order->fields['products_id'] . "'");
unset($attr_array);
$order->MoveNext();
}
}
Furthermore, $attr_array needs to be unset after each iteration, or else data just gets appended to the end of it, causing the whole function to simply not work.
PLEASE NOTE:
This needs more testing and input from the rest of you guys who use this module, because my store's attributes are set up where the only unique attribute I use is color.
So if your store's products are similar to mine, I'm sure that the fix above will work, but if you have multiple attribute combinations (such as size and color), then please test cautiously, and provide your feedback. From looking at the code, I believe it should work in all scenarios...but I can't be for certain.
Also, PLEASE test with caution!!! I would suggest creating a few dummy orders and taking note of your quantities before and after placing your dummy order then monitoring the stock levels after you delete the dummy order and choose to restock the items! It should go without saying, but...obviously don't test this on real live orders :)
Hopefully this helps out a lot of you out there, and this code (or at least the logic to make the restock feature work) make it to the 1.5 version of SBA!
Sorry, also important to note for my above solution, this is for ZC 1.3.9h only! I don't have any experience with 1.5 and don't know if the code has changed much, if any, in 1.5...so I can only guarantee this to be working with the latest verion of SBA for ZC 1.3.9h.
My site is getting this error
http://www.nothingbutcostumes.com/bi...me-p-9007.htmlQuote:
1064 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 ') AND pa2.products_attributes_id IN (19821) ' at line 3
in:
[SELECT count(DISTINCT pa1.options_id) AS matches FROM products_attributes pa1, products_attributes pa2 WHERE pa1.products_attributes_id IN () AND pa2.products_attributes_id IN (19821) AND pa1.options_id = pa2.options_id]
Any suggestion on how I can fix this???
Thanks in advance
I searched my store for pa1 and narrowed the problem. Is there something I can comment out to remove this problem??
/home/nothingb/public_html/includes/functions/functions_lookups.php
Quote:
Line #272 : SELECT pov1.products_options_id FROM (products_attributes pa1
Line #274 : ON pa1.options_values_id = pov1.products_options_values_id)
Line #278 : WHERE pa1.products_attributes_id IN ( $atr ) AND pa2.products_attributes_id IN ( $atr2 )
Line #288 : $res2 = $db->Execute("SELECT count(DISTINCT pa1.options_id) AS matches
Line #289 : FROM products_attributes pa1, products_attributes pa2
Line #290 : WHERE pa1.products_attributes_id IN ($atr)
Line #292 : AND pa1.options_id = pa2.options_id");
Line #321 : $res2 = $db->Execute("SELECT DISTINCT pa1.products_attributes_id AS needed
Line #322 : FROM products_attributes pa1, products_attributes pa2
Line #323 : WHERE pa1.products_attributes_id IN ($atr)
Line #325 : AND pa1.options_id = pa2.options_id
Line #326 : ORDER BY pa1.products_attributes_id");
/home/nothingb/public_html/snickers/includes/functions/extra_functions/functions_qty_attribute.php
Quote:
Line #34 : (products_attributes pa1 INNER JOIN products_options_values_to_products_options pov1
Line #35 : ON pa1.options_values_id = pov1.products_options_values_id)
Line #42 : WHERE pa1.products_attributes_id IN ( $atr )
Line #53 : $res2 = $db->Execute("SELECT count(DISTINCT pa1.options_id) AS matches
Line #54 : FROM products_attributes pa1, products_attributes pa2
Line #55 : WHERE pa1.products_attributes_id IN ($atr)
Line #57 : AND pa1.options_id = pa2.options_id;");
Dr Byte once said
So I see the 2 places... What can I do now?Quote:
"WHERE pa1.products_attributes_id IN ()"
You're telling it to lookup a products_attributes_id in the list of values specified inside the parentheses, but your list is empty, thus you're creating a MySQL syntax error. Hence the error message.
Is the problem..Code:WHERE pa1.products_attributes_id IN ($atr)
inQuote:
$atr = implode(',',$attributes);
/home/nothingb/public_html/includes/functions/functions_lookups.php
Can I change this to something?