guys,
if you created a variation and (yet) no attributes inside, subproducts module will go crazy during product creation. Problems also happen when you dont chose at least one attribute of each variation.
to solve it, it should be added a checker just before some codes.
if ($variation->attributes) {
...
}
in subproducts.inc
in subproducts_generate_wizard1, before
foreach ($variation->attributes as $attribute) {
$form['settings'][$variation->vid][$attribute->aid]['use'] = array(
'#type' => 'checkbox',
'#title' => '',
'#return_value' => 1,
'#default_value' => ($defaults && ($defaults[$variation->vid][$attribute->aid]['use'] == 0)) ? 0 : 1
);
$form['settings'][$variation->vid][$attribute->aid]['name'] = array(
'#type' => 'markup',
'#value' => $attribute->name
);
$form['settings'][$variation->vid][$attribute->aid]['surcharge'] = array(
'#type' => 'markup',
'#value' => $attribute->surcharge
);
$form['settings'][$variation->vid][$attribute->aid]['stock'] = array(
'#type' => 'textfield',
'#title' => '',
'#default_value' => ($defaults && $defaults[$variation->vid][$attribute->aid]['stock']) ? $defaults[$variation->vid][$attribute->aid]['stock'] : 0,
'#size' => 10,
'#maxlength' => 10
);
}in subproducts_generate_wizard2, before
foreach ($variation->attributes as $attribute) {
// Only include this option in the array if it was selected in the previous screen.
if ($settings[$variation->vid][$attribute->aid]['use']) {
$options[$variation->vid][] = $attribute->aid;
}
}
in subproducts.module, function subproducts_nodeapi, before
foreach($variation->attributes as $attribute) {
if (in_array($attribute->aid, $child_variations)) {
$options[$attribute->aid] = subproducts_surcharge_extra($attribute);
}
}
$form['variations'][$variation->vid] = array(
'#type' => 'select',
'#title' => $variation->name,
'#default_value' => $node->variations[$variation->vid],
'#options' => $options,
'#description' => t('The %name of this product', array('%name' => theme('placeholder', $variation->name)))
);
}
and also in subproducts_generate_wizard2 (also in subproducts.inc), it should be deleted
if(count($options) < count($variations)) {
return t('Error. You must select at least one option from each of the variations.');
}
regards,
massa
Comments
Comment #1
darren ohDuplicate of issue 65342.
Comment #2
nedjoPart of this has been applied.
I'm not sure that removing the test for all variations is a good solution though. What happens when a product is displayed for purchase? Do we get an empty drop-down selection for the variation that has no registered attributes? What happens when we later add a product that has attributes from the previously-omitted variation?
Comment #3
nedjoComment #4
brmassa commentednedjo,
great point. since my last comment i modified many things in subproducts.module, so i dont remember exactly how i did for this. i think that i created a new function that looks all attributes (and variations) for a given product (nid). it completely solved the empty drop-down menus and later created products with diferent variations.
i found a new issue using the module:
you can have tshirts:
blue and green
small and big
BUT even if you runned out of big blue tshirts, this combination can be selected and ADDED TO CART (in fact, it adds some other product)!!! the only solution possible is check ON THE FLY (thru javascript or ajax) if that combination has stock more than zero (or if even exists). i did this script and a couple others to my professional site (i sell customized computers that have more than 45000 combinations of processors, memory, hd, video, motherboards...... [you should have seen how long it took to process!!!])
i have a real problem that my subproducts.module, inc and install are heavily modified, so i shall post a issue called something like "advanced subproducts module" to address all these features and fixes togheter.
regards,
massa
Comment #5
nedjobrmassa, please go ahead and post your modified version. I'd like to work with you on getting your improvements into the version in ecommerce core. We need to do this as individual patches, but a good starting point may be to post what you have.
For the question of stock, I originally wanted to decrement the base product stock automatically every time a custom product was purchased, but this conflicted with the inventory management system of the client for whom subproducts.module was written (goodstorm.com). Would this sort of automatic decrementing meet your need? Or do you need to check stock of the individual computer components (the 'attributes')?
Comment #6
brmassa commentednedjo
as promissed, i submmited my subproducts module on the issue http://drupal.org/node/85844. take a look. there are some new features and a couple bug fixes.
regards,
massa
Comment #7
brmassa commented