This is a discussion on Attribute Stock within the osCMax v2 Features Discussion forums, part of the osCMax v2.0 Forums category; I am selling t-shirts and using attribute stock quantities for sizes. Example 20 in Medium, 26 in Large and 26 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| I am selling t-shirts and using attribute stock quantities for sizes. Example 20 in Medium, 26 in Large and 26 in X-large. When i a shirt is purchased the total quantity in the info window is adjusted but when i go select the stock button i go to the page showing the attribute quantities and nothing has changed. How do i go about fixing this, i've tried to search here but come up with nothing. Thanks |
| Sponsored Links | ||
| ||
| |
|
#2
| |||
| |||
| nobody else having this problem? |
|
#3
| |||
| |||
| You may be having the same problem as me. I've got a heavily modified oscommerce store (only found oscmax yesterday and am playing with it) and have found that when someone purchases using their credit card (worldpay), the attribute stock is reduced. When someone uses paypal, it's not. This is because when the Paypal IPN module returns to the site, it goes to catalog/includes/modules/payment/paypal/checkout_process.php instead of catalog/checkout_process.php (which is the next logical step when paying by cheque for example). You'll need to add the code relating to the attribute stock reduction into one of the paypal files. I've not seriously tried to debug it yet but it's probably checkout_update.php. Mike |
|
#4
| |||
| |||
| Hey Mike, Thanks for the response. That sounds logical and i haven't tested with anything other than paypal so again makes perfect sense. The Coding thing however is beyond my skill level i think, i will see what i can work out. If anyone has any knowledge they can throuw my way it will be greatly appreciated. |
|
#5
| |||
| |||
| I'm glad I could point you in the right direction. It's a bug I've been meaning to fix for so long. I'm going to put a couple of hours to one side this weekend to sort it out. If I manage to fix it I'll post the fixes here. Mike |
|
#6
| |||
| |||
| I've just done a bit of digging, and the paypal IPN I'm using, and the OSCMax version are two different modules so the files I mentioned above aren't applicable. But this one is: /includes/modules/payment/paypal_ipn.php You need to add the code in there. BACKUP PAYPAL_IPN.PHP BEFORE TRYING THIS. Open up /includes/modules/payment/paypal_ipn.php and search for Code: // Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
Code: $products_attributes = $order->products[$i]['attributes']; Next find (a few lines further down) Code: if (is_array($products_attributes)) {
$stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
}
$stock_query = tep_db_query($stock_query_raw);
} else {
Code: if (is_array($products_attributes)) {
$allspecial = true;
$products_stock_attributes_array = array();
For($k = 0, $n3 = sizeof($products_attributes); $k < $n3; $k++) {
if ($products_attributes[$k]['special'] == 0) {
$products_stock_attributes_array[] = $products_attributes[$k]['option_id'] . "-" . $products_attributes[$k]['value_id'];
$allspecial = false;
}
}
if (!$allspecial) {
asort($products_stock_attributes_array, SORT_NUMERIC);
reset($products_stock_attributes_array);
$products_stock_attributes = implode(",", $products_stock_attributes_array);
$attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if (tep_db_num_rows($attributes_stock_query) > 0) {
$attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
$attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
if ($attributes_stock_left < 1) {
tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '0' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$actual_stock_bought = $attributes_stock_values['products_stock_quantity'];
} else {
tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$actual_stock_bought = $order->products[$i]['qty'];
}
} else {
$actual_stock_bought = 0;
}
} else {
$actual_stock_bought = $order->products[$i]['qty'];
}
} else {
$actual_stock_bought = $order->products[$i]['qty'];
}
Mike |
|
#7
| |||
| |||
| OK first let me say you are AWESOME, got it modified and it all seems to be working like a charm. Thanks again. |
|
#8
| |||
| |||
| Not a problem. |
|
#9
| |||
| |||
| homersbrain, I did the same change but my file looks like this: Code: if (is_array($products_attributes)) {
$allspecial = true;
$products_stock_attributes_array = array();
For($k = 0, $n3 = sizeof($products_attributes); $k < $n3; $k++) {
if ($products_attributes[$k]['special'] == 0) {
$products_stock_attributes_array[] = $products_attributes[$k]['option_id'] . "-" . $products_attributes[$k]['value_id'];
$allspecial = false;
}
}
if (!$allspecial) {
asort($products_stock_attributes_array, SORT_NUMERIC);
reset($products_stock_attributes_array);
$products_stock_attributes = implode(",", $products_stock_attributes_array);
$attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
if (tep_db_num_rows($attributes_stock_query) > 0) {
$attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
$attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
if ($attributes_stock_left < 1) {
tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '0' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$actual_stock_bought = $attributes_stock_values['products_stock_quantity'];
} else {
tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$actual_stock_bought = $order->products[$i]['qty'];
}
} else {
$actual_stock_bought = 0;
}
} else {
$actual_stock_bought = $order->products[$i]['qty'];
}
} else {
$actual_stock_bought = $order->products[$i]['qty'];
}
Nootkan Update: I understand why you didn't answer, after reading the first two chapters of Php for the World Wide Web I understand. Oh well before I bought the book I had to ask, if you don't know ask right? |
|
#10
| |||
| |||
| Quote:
I've implemented this code change, and now stock(attributes) is updating through the paypal IPN but only if the customer returns to merchant...anybody know a way around this? |
| Sponsored Links | ||
| ||
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Needing: Attribute Weight, Hide Price if 0, Actual Attribute | crystina | osCMax v2 Customization/Mods | 0 | 11-22-2006 04:08 PM |
| Maximum Stock Quantity on Stock Page? | Dubious | osCMax v2 Features Discussion | 0 | 08-18-2006 02:17 PM |
| Yet another attribute stock question | landshark | osCMax v2 Features Discussion | 6 | 01-25-2006 04:31 AM |
| Yet another attribute stock level updating question | kc_davis | osCMax v2 Features Discussion | 0 | 01-22-2006 08:50 PM |
| attribute "out of stock" | nootkan | osCMax v2 Features Discussion | 24 | 01-02-2006 08:17 PM |