Доброго времени суток.Требуется помощь в выводе атрибута корзины selectom, сейчас вывод работает через radio button, собственно вот
public function getProductCustomsFieldCart ($product) {
// group by virtuemart_custom_id
$query = 'SELECT C.`virtuemart_custom_id`, `custom_title`, C.`custom_value`,`custom_field_desc` ,`custom_tip`,`field_type`,field.`virtuemart_customfield_id`,`is_hidden`
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
Where `virtuemart_product_id` =' . (int)$product->virtuemart_product_id . ' and `field_type` != "G" and `field_type` != "R" and `field_type` != "Z"';
$query .= ' and is_cart_attribute = 1 group by virtuemart_custom_id ORDER BY field.`ordering`';
$this->_db->setQuery ($query);
$groups = $this->_db->loadObjectList ();
if (!class_exists ('VmHTML')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php');
}
$row = 0;
if (!class_exists ('CurrencyDisplay')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
}
$currency = CurrencyDisplay::getInstance ();
if (!class_exists ('calculationHelper')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php');
}
$calculator = calculationHelper::getInstance ();
if (!class_exists ('vmCustomPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
}
$free = JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
// render select list
foreach ($groups as $group) {
// $query='SELECT field.`virtuemart_customfield_id` as value ,concat(field.`custom_value`," :bu ", field.`custom_price`) AS text
$query = 'SELECT field.`virtuemart_product_id`, `custom_params`,`custom_element`, field.`virtuemart_custom_id`,
field.`virtuemart_customfield_id`,field.`custom_value`, field.`custom_price`, field.`custom_param`
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
Where `virtuemart_product_id` =' . (int)$product->virtuemart_product_id;
$query .= ' and is_cart_attribute = 1 and C.`virtuemart_custom_id`=' . (int)$group->virtuemart_custom_id;
// We want the field to be ordered as the user defined
$query .= ' ORDER BY field.`ordering`';
$this->_db->setQuery ($query);
$options = $this->_db->loadObjectList ();
//vmdebug('getProductCustomsFieldCart options',$options);
$group->options = array();
foreach ($options as $option) {
$group->options[$option->virtuemart_customfield_id] = $option;
}
if ($group->field_type == 'V') {
$default = current ($group->options);
foreach ($group->options as $productCustom) {
if ((float)$productCustom->custom_price) {
$price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price)));
}
else {
$price = ($productCustom->custom_price === '')? '' : $free;
}
$productCustom->text = $productCustom->custom_value . ' ' . $price;
}
$group->display = VmHTML::select ('customPrice[' . $row . '][' . $group->virtuemart_custom_id . ']', $group->options, $default->custom_value, '', 'virtuemart_customfield_id', 'text', FALSE);
}
else {
if ($group->field_type == 'G') {
$group->display .= ''; // no direct display done by plugin;
}
else {
if ($group->field_type == 'E') {
$group->display = '';
foreach ($group->options as $k=> $productCustom) {
if ((float)$productCustom->custom_price) {
$price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
}
else {
$price = ($productCustom->custom_price === '')? '' : $free;
}
$productCustom->text = $productCustom->custom_value . ' ' . $price;
$productCustom->virtuemart_customfield_id = $k;
if (!class_exists ('vmCustomPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
}
//legacy, it will be removed 2.2
$productCustom->value = $productCustom->virtuemart_customfield_id;
JPluginHelper::importPlugin ('vmcustom');
$dispatcher = JDispatcher::getInstance ();
$fieldsToShow = $dispatcher->trigger ('plgVmOnDisplayProductVariantFE', array($productCustom, &$row, &$group));
// $group->display .= '<input type="hidden" value="' . $k . '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . ']" /> ';
$group->display .= '<input type="hidden" value="' . $productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /> ';
if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
$group->display .= '<div class="price-plugin">' . JText::_ ('COM_VIRTUEMART_CART_PRICE'). '<span class="price-plugin">' . $price . '</span></div>';
}
$row++;
}
$row--;
}
else {
if ($group->field_type == 'U') {
foreach ($group->options as $productCustom) {
if ((float)$productCustom->custom_price) {
$price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
}
else {
$price = ($productCustom->custom_price === '')? '' : $free;
}
$productCustom->text = $productCustom->custom_value . ' ' . $price;
$group->display .= '<input type="text" value="' . JText::_ ($productCustom->custom_value). '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . '][' . $productCustom->value . ']" /> ';
if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
$group->display .= '<div class="price-plugin">' . JText::_ ('COM_VIRTUEMART_CART_PRICE'). '<span class="price-plugin">' . $price . '</span></div>';
}
}
}
else {
if ($group->field_type == 'A') {
$group->display = '';
foreach ($group->options as $productCustom) {
/* if ((float)$productCustom->custom_price) {
$price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
}
else {
$price = ($productCustom->custom_price === '')? '' : $free;
}*/
$productCustom->field_type = $group->field_type;
$productCustom->is_cart = 1;
$group->display .= $this->displayProductCustomfieldFE ($product, $productCustom, $row);
$checked = '';
}
}
else {
$group->display = '';
$checked = 'checked="checked"';
foreach ($group->options as $productCustom) {
//vmdebug('getProductCustomsFieldCart',$productCustom);
if ((float)$productCustom->custom_price) {
$price = $currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price));
}
else {
$price = ($productCustom->custom_price === '')? '' : $free;
}
$productCustom->field_type = $group->field_type;
$productCustom->is_cart = 1;
// $group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '" ' . $checked . ' type="radio" value="' .
// $productCustom->virtuemart_custom_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_customfield_id . ']" /><label
// for="' . $productCustom->virtuemart_custom_id . '">' . $this->displayProductCustomfieldFE ($productCustom, $row). ' ' . $price . '</label>';
//MarkerVarMods
$group->display .= '<input id="' . $productCustom->virtuemart_custom_id . '" ' . $checked . ' type="radio" value="' .
$productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /><label
for="' . $productCustom->virtuemart_custom_id . '">' . $this->displayProductCustomfieldFE ($product, $productCustom, $row). ' ' . $price . '</label>';
$checked = '';
}
}
}
}
}
}
$row++;
}
return $groups;
}