guys,

i dont know why the attribute stocks are summed during permutations creations. imo, it should be the least attribute stock. (i know thats is a warning on the top of the page saying "Settings you put here for stock will be summed to give a default stock amount for each subproduct.")

example:
variation: color
attribute: green
stock: 100

variation: size
attribute: big
stock: 200

so should be 100 big green stairs, not 300.

to correct this, change this code (in subproducts.inc)

    foreach ($permutation as $vid => $aid) {
      $form['name'][$fields][$aid] = array('#type' => 'markup', '#value' => $variations[$vid]->attributes[$aid]->name);
      $price += $variations[$vid]->attributes[$aid]->surcharge;
      $stock += $settings[$vid][$aid]['stock'];
    }

to this

    $stocktoggle = 0;
    foreach ($permutation as $vid => $aid) {
      $form['name'][$fields][$aid] = array('#type' => 'markup', '#value' => $variations[$vid]->attributes[$aid]->name);
      $price += $variations[$vid]->attributes[$aid]->surcharge;
      if ($stocktoggle != 0) {
        $stock = ($settings[$vid][$aid]['stock'] >= $stock) ? $stock : $settings[$vid][$aid]['stock'] ;
      }
      else {
        $stock = $settings[$vid][$aid]['stock'] ;
      }
      $stocktoggle += 1;
    }

PS: the instructions on the top of the page will continue to show "Settings you put here for stock will be summed to give a default stock amount for each subproduct."

regards,

massa

CommentFileSizeAuthor
#2 subproducts.inc_minimunstock1.patch.txt1.07 KBbrmassa

Comments

darren oh’s picture

Status: Needs review » Active

No patch is attached.

brmassa’s picture

Title: Attributes stocks summed during permutations creation » Subproducts: Attributes stocks summed during permutations creation
Status: Active » Reviewed & tested by the community
StatusFileSize
new1.07 KB
recidive’s picture

Status: Reviewed & tested by the community » Needs review

Someone else besides the author needs to test the code before it can be commited.

brmassa’s picture

Status: Needs review » Closed (fixed)
darren oh’s picture

Status: Closed (fixed) » Active

Setting to active until the resolution of this issue has been reported.

brmassa’s picture

Version: 4.7.x-1.x-dev » 5.x-4.x-dev
Assigned: Unassigned » brmassa
Status: Active » Fixed

Guys,

Since the EC Live Subproducts has this feature and next Ecommerce version (v4) will merge this code to subproducts, i suggest to all to migrate to EC Live Subproducts.

regards,

massa

brmassa’s picture

Status: Fixed » Closed (fixed)