LemonStand Forum: Product size item count? - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Product size item count?

#1 User is offline   melawn 

  • Member
  • Group: Members
  • Posts: 16
  • Joined: 25-January 12

Posted 27 January 2012 - 08:42 PM

Does anyone know if its possible to keep track of the amount of the options for a product?

Example being:

"Little Red Dress"
Its comes in Small, Medium, and Large

Can I assign an inventory count to each size of that dress? and if yes, how can I display on the public view how many of each are in stock?

thanks in advance for anyone willing to answer this one :)
0

#2 User is offline   apepp 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 233
  • Joined: 30-October 11

Posted 28 January 2012 - 07:26 AM

...have you looked into "grouped products"?

...this will allow you to apply a different SKU number to each size.

...on my test development site I have this on my product page to render in grouped products:

<? if ($product->grouped_products->count): ?>
<div>
<? $this->render_partial('shop_grouped_products') ?>
</div>
<? endif ?>


...the partial shows a table list of sizes (sizes are setup on the product in "grouped products")...so the main initial product (or parent product) is the small size...of which "medium" and "large" are added to the small size in "grouped products" tab...

...the "shop_grouped_products" partial is coded like this to render out a table that lists grouped products, the price and the in stock quantity...do note that you will need to modify the "$click_handler" to properly update the product page, mine won't work for you by just a straight copy of the "$click_handler" function:

<h1>Select your <?= h(mb_strtolower($product->grouped_menu_label)) ?></h1>


<input type="hidden" value="<?= $product->id ?>" name="product_id"/>


<table>


<thead>
<tr>
<th class="th_col1"><?= h($product->grouped_menu_label) ?></th>
<th class="th_col2">Price</th>
<th class="th_col3">Stock</th>
</tr>
</thead>


<tbody>


<? $current_product_id = null;
foreach ($product->grouped_products as $grouped_product):
$current_product_id = $current_product_id ? $current_product_id : post('product_id', $grouped_product->id);
$is_current = $current_product_id == $grouped_product->id;
        
$click_handler = "return $(this).getForm().sendRequest(
'on_action',
{onAfterUpdate: init_effects,
update: {'product_page_div': 'shop_product'},
extraFields: {'product_id': '".$grouped_product->id."'}
})";
?>


<tr onclick="<?= $click_handler ?>" class="<?= $is_current ? 'current' : null ?>">
<th>
<a onclick="<?= $click_handler ?>" href="#">
<?= h($grouped_product->grouped_option_desc) ?>
<? if ($is_current): ?><span class="marker"> - (X)</span><? endif ?>
</a>
</th>

<td>
<a onclick="<?= $click_handler ?>" href="#"><?= format_currency($grouped_product->get_discounted_price()) ?></a>
</td>

<td>
<a onclick="<?= $click_handler ?>" href="#"><?= $grouped_product->in_stock ?></a>
</td>
</tr>


<? endforeach ?>

</tbody>
</table>


...hope this helps!

Andrew

This post has been edited by apepp: 28 January 2012 - 08:11 AM

0

#3 User is offline   melawn 

  • Member
  • Group: Members
  • Posts: 16
  • Joined: 25-January 12

Posted 30 January 2012 - 07:06 PM

That's freaking awesome! did not know you could do that with those options, pretty fantastic stuff, and thanks for the template of code to spit out the results, it works like a charm :)
0

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users