SQL Statement to install the new "feature" of controlling the display of CustomID on the attributes dropdown without using the Install/update option in the SBA install list. This will add the option to the end of the Attribute Settings Menu:
Code:
SELECT @sort_order := (c.sort_order + 1) FROM configuration c
WHERE c.configuration_group_id = 13
order by c.sort_order desc limit 1;
INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,
configuration_description, configuration_group_id, sort_order,
date_added, use_function, set_function)
VALUES
('SBA Display CustomID in Attribute Dropdowns', 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID', '2',
'Display the CustomID in the Attribute Dropdown list(s) for the customer to see while selecting an option.<br /><br /> 0 - Hide the Custom ID<br /> 1 - Display the Custom ID depending on the setting for display throughout<br ?> 2 - Always display the Custom ID (default)<br />',
13,@sort_order ,now(),null,'zen_cfg_select_drop_down(array(array(\'id\'=>\'0\', \'text\'=>\'Off\'), array(\'id\'=>\'1\', \'text''=>\'On Pending SBA Stock\'), array(\'id\'=>\'2\', \'text''=>\'Always On\'), ),');
Deletion SQL if needed:
Code:
DELETE FROM `configuration` WHERE configuration_key = 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID';
Code will be incorporated into the plugin as well as a change of the default option for the HTML away from defaulting to true. That default will change in the future when Dynamic Dropdowns (or appropriate variation) does fully/sufficiently handles all of the basic types of option name.
Code change needed in includes/classes/observers/class.products_with_attributes_stock.php:
from line 163 through 184 inclusive changing (text to be changed is in red here):
Code:
if (STOCK_SBA_DISPLAY_CUSTOMID == 'true' AND ! empty($products_options->fields['customid'])) {
$PWA_STOCK_QTY .= ' (' . $products_options->fields['customid'] . ') ';
}
}
} elseif (STOCK_SHOW_ATTRIB_LEVEL_STOCK == 'true' && $products_options->fields['pasqty'] < 1 && $products_options->fields['pasid'] < 1) {
//test, only applicable to products with-out the display-only attribute set
if ($products_options_DISPLAYONLY->fields['attributes_display_only'] < 1) {
//use the qty from the product, unless it is 0, then set to out of stock.
if ($this->_products_options_names_count <= 1) {
if ($products_options->fields['products_quantity'] > 0) {
$PWA_STOCK_QTY = PWA_STOCK_QTY . $products_options->fields['products_quantity'] . ' ';
} else {
$products_options->fields['products_options_values_name'] = $products_options->fields['products_options_values_name'] . PWA_OUT_OF_STOCK;
}
}
//show custom ID if flag set to true
if (STOCK_SBA_DISPLAY_CUSTOMID == 'true' AND ! empty($products_options->fields['customid'])) {
$PWA_STOCK_QTY .= ' (' . $products_options->fields['customid'] . ') ';
}
}
} elseif (STOCK_SBA_DISPLAY_CUSTOMID == 'true' AND ! empty($products_options->fields['customid'])) {
To (replacing above red with below blue):
Code:
if (!empty($products_options->fields['customid']) && (!defined('ATTRIBUTES_SBA_DISPLAY_CUSTOMID') || (STOCK_SBA_DISPLAY_CUSTOMID == 'true' && ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '1') || ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '2')) {
$PWA_STOCK_QTY .= ' (' . $products_options->fields['customid'] . ') ';
}
}
} elseif (STOCK_SHOW_ATTRIB_LEVEL_STOCK == 'true' && $products_options->fields['pasqty'] < 1 && $products_options->fields['pasid'] < 1) {
//test, only applicable to products with-out the display-only attribute set
if ($products_options_DISPLAYONLY->fields['attributes_display_only'] < 1) {
//use the qty from the product, unless it is 0, then set to out of stock.
if ($this->_products_options_names_count <= 1) {
if ($products_options->fields['products_quantity'] > 0) {
$PWA_STOCK_QTY = PWA_STOCK_QTY . $products_options->fields['products_quantity'] . ' ';
} else {
$products_options->fields['products_options_values_name'] = $products_options->fields['products_options_values_name'] . PWA_OUT_OF_STOCK;
}
}
//show custom ID if flag set to true
if (!empty($products_options->fields['customid']) && (!defined('ATTRIBUTES_SBA_DISPLAY_CUSTOMID') || (STOCK_SBA_DISPLAY_CUSTOMID == 'true' && ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '1') || ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '2')) {
$PWA_STOCK_QTY .= ' (' . $products_options->fields['customid'] . ') ';
}
}
} elseif (!empty($products_options->fields['customid']) && (!defined('ATTRIBUTES_SBA_DISPLAY_CUSTOMID') || (STOCK_SBA_DISPLAY_CUSTOMID == 'true' && ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '1') || ATTRIBUTES_SBA_DISPLAY_CUSTOMID == '2')) {
Now in testing this (which worked) I noticed that I may have left behind some errant code in the includes/functions/extra_functions/products_with_attributes.php file that cause an error... On lines 568 and 569 there is " . at the end of each that should be deleted (will be fixed momentarily on github). Also I hadn't incorporated the changes into the ZC 1.5.1 version of the plugin so need to do that as well... Anyways... Above should address the "concerns" expressed today by both michael_rebreathe and jnabird333...
products_with_attributes.php
Bookmarks