Re: Product Attribute Grid
Whenever I try to add more than one attribute with a qty box it all reverts to radio fields. Take a look here.
I added Color as a radio field the same way as adding the Qty radio, so it has a sort order of -9998. Then I added a separate drop down option name "colors" with option values "black" and "white". It's probably something I'm just missing in the way I'm doing it :dontgetit
Re: Product Attribute Grid
There you have 5 different attributes. You should only ever have TWO.
One attribute, set as a RADIO type should be colour, with RED, GREEN, BLUE etc as the VALUES.
The other should be SIZE with the VALUES XXL, XL, L, M, S
Thats all. Remove the other three attributes and it will work as expected.
You only need a quantity attribute if you only have 1 attribute, and want to force the single attribute into a grid format.
Absolute
Re: Product Attribute Grid
Ooooh :blush: Ok I got it now & that worked, thank you!
Re: Product Attribute Grid
Re: Product Attribute Grid
Absolute, sorry to bother you. Is there a way to have the price in it's own column.
Like
[attribute] [price] [qty box]
??
Thank you!
Re: Product Attribute Grid
You can. However, this is a little beyond the scope of this module. The existing could certainly be updated to reflect any setup/layout you are looking for.
Absolute
Re: Product Attribute Grid
Quote:
Originally Posted by
Absolute
In terms of replacing the input boxes with a red cross image or similar, you would need to have "Stock by Attribute" module installed, and then use the following code:
In includes/modules/attributes.php, the
FOR statement found around line 136 should be replaced with the following:
Code:
for($grh=0; $grh < $grh_size; $grh++) {
$attributes_ids = array( $grid_records['H']['id'] => $grid_records['H']['options'][$grh]['id'],
$grid_records['V']['id'] => $grid_records['V']['options'][$grv]['id']
);
$products_attribs_id = zen_get_uprid((int)$_GET['products_id'], $attributes_ids);
$stock_check_array = array();
if (zen_not_null($grid_records['H']['options'][$grh]['name'])) $stock_check_array[] = $grid_records['H']['options'][$grh]['id'];
if (zen_not_null($grid_records['V']['options'][$grv]['name'])) $stock_check_array[] = $grid_records['V']['options'][$grv]['id'];
$attrib_grid .= '<td class="attrib-grid-cell" id="attrib-grid-cell-'.$grid_records['H']['options'][$grh]['id'].'-'.$grid_records['V']['options'][$grv]['id'].'">'.
(zen_get_products_stock($_GET['products_id'], $stock_check_array) > 0 ?
zen_draw_input_field('products_id['.$products_attribs_id.']', '', 'size="3"').
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['H']['id'].']', $grid_records['H']['options'][$grh]['id']).
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['V']['id'].']', $grid_records['V']['options'][$grv]['id'])
: zen_image(DIR_WS_IMAGES.'item_out_stock.gif)).
'</td>';
}
Hope this helps.
Absolute
Yes I do have the stock by attributes installed and your fix worked. But there was one small error in the code it was missing a '. So for anyone else wanting this to little fix to work:
In includes/modules/attributes.php (or if you are like me that uses the template override system includes/modules/YOUR_TEMPLATE/attributes.php)
Find:
Code:
for($grh=0; $grh < $grh_size; $grh++) {
$attributes_ids = array( $grid_records['H']['id'] => $grid_records['H']['options'][$grh]['id'],
$grid_records['V']['id'] => $grid_records['V']['options'][$grv]['id']
);
$products_attribs_id = zen_get_uprid((int)$_GET['products_id'], $attributes_ids);
$attrib_grid .= '<td class="attrib-grid-cell" id="attrib-grid-cell-'.$grid_records['H']['options'][$grh]['id'].'-'.$grid_records['V']['options'][$grv]['id'].'">'.
zen_draw_input_field('products_id['.$products_attribs_id.']', '', 'size="3"').'<br />'.
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['H']['id'].']', $grid_records['H']['options'][$grh]['id']).
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['V']['id'].']', $grid_records['V']['options'][$grv]['id']).
'</td>';
}
Replace:
Code:
for($grh=0; $grh < $grh_size; $grh++) {
$attributes_ids = array( $grid_records['H']['id'] => $grid_records['H']['options'][$grh]['id'],
$grid_records['V']['id'] => $grid_records['V']['options'][$grv]['id']
);
$products_attribs_id = zen_get_uprid((int)$_GET['products_id'], $attributes_ids);
$stock_check_array = array();
if (zen_not_null($grid_records['H']['options'][$grh]['name'])) $stock_check_array[] = $grid_records['H']['options'][$grh]['id'];
if (zen_not_null($grid_records['V']['options'][$grv]['name'])) $stock_check_array[] = $grid_records['V']['options'][$grv]['id'];
$attrib_grid .= '<td class="attrib-grid-cell" id="attrib-grid-cell-'.$grid_records['H']['options'][$grh]['id'].'-'.$grid_records['V']['options'][$grv]['id'].'">'.
(zen_get_products_stock($_GET['products_id'], $stock_check_array) > 0 ?
zen_draw_input_field('products_id['.$products_attribs_id.']', '', 'size="3"').
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['H']['id'].']', $grid_records['H']['options'][$grh]['id']).
zen_draw_hidden_field('attribs['.$products_attribs_id.']['.$grid_records['V']['id'].']', $grid_records['V']['options'][$grv]['id']).
:zen_image(DIR_WS_IMAGES.'item_out_stock.gif')).
'</td>';
}
Also remember to upload the image to /images/item_out_stock.gif
We just used a similar X like on Absoulte's website.
Thanks again to Absolute for a great module and very simple fix.
Re: Product Attribute Grid
The code above works great for two option attributes. But if I use it the grid for single attributes, and still want to have all options with a Quantity box next to them then I have a problem.
I have followed the readme and set up an attribute called Quantity, which is a Radio type option and then setup one option value, which has no text defined, so it is just a completely blank value, but then even with stock by attribute setup normally I get my X image in all the boxes. But if I put text in the option value the quantity box appears for each single attribute again.
So what do I need to do with this code so it still works with single attributes?
Re: Product Attribute Grid
Does anyone think (or know) that this mod could be combined with the "drop down attributes at product listing mod", so that I could create a "quick order on steroids". The grid format would be on the product listing page rather than product info. That way a customer could order for example 5 of one size of shoe and 10 of another size of product a then order 20 of one size and 30 of another of product b on the same page.
I tried combining the 2 modules on my test site with no success. Probably because of my lack of php knowledge.
Re: Product Attribute Grid
The two modules would not function together, as the module we have created relies on a number of product specific hidden variables when the form is submitted.
The solution to the problem you are looking to solve has been created already however! We have it running on a couple of our sites. If you want a pointer in the right direction, you would need to update your cart action script to add the items to cart with attributes, and then on your product listing page, show all the product attributes with speific field names.
It can be done, but requires a little PHP knowledge.
Absolute