osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

Attribute Stock

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


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Features Discussion

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 10-30-2005, 02:11 AM
New Member
 
Join Date: Oct 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
landshark
Default Attribute Stock

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
  #2  
Old 11-03-2005, 11:06 PM
New Member
 
Join Date: Oct 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
landshark
Default RE: Attribute Stock

nobody else having this problem?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #3  
Old 11-04-2005, 08:43 AM
Lurker
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
homersbrain
Default RE: Attribute Stock

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #4  
Old 11-04-2005, 08:51 AM
New Member
 
Join Date: Oct 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
landshark
Default RE: Attribute Stock

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #5  
Old 11-04-2005, 10:38 AM
Lurker
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
homersbrain
Default RE: Attribute Stock

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #6  
Old 11-04-2005, 12:02 PM
Lurker
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
homersbrain
Default RE: Attribute Stock

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') {
After that, add the line
Code:
        $products_attributes = $order->products[$i]['attributes'];
You'll find that same line about 10 lines down. You can remove it from there.

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 {
and add after

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'];
            }
That should be it. Save it and give it a go. I've not tested it yet but that's the code I've added into my live site and it works!

Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #7  
Old 11-05-2005, 04:27 AM
New Member
 
Join Date: Oct 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
landshark
Default RE: Attribute Stock

OK first let me say you are AWESOME, got it modified and it all seems to be working like a charm. Thanks again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #8  
Old 11-05-2005, 07:45 AM
Lurker
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
homersbrain
Default RE: Attribute Stock

Not a problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #9  
Old 11-27-2005, 02:58 PM
New Member
 
Join Date: Nov 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
nootkan
Default

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']; 
}
Is this okay or should it look like the rest of the code with normal spaces etc. All I did was copy and paste from your post.
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #10  
Old 06-09-2006, 04:09 PM
New Member
 
Join Date: May 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jonnyl
Default Re: RE: Attribute Stock

Quote:
Originally Posted by homersbrain
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') {
After that, add the line
Code:
        $products_attributes = $order->products[$i]['attributes'];
You'll find that same line about 10 lines down. You can remove it from there.

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 {
and add after

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'];
            }
That should be it. Save it and give it a go. I've not tested it yet but that's the code I've added into my live site and it works!

Mike


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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -8. The time now is 04:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax