当前位置: 首页>>代码示例>>PHP>>正文


PHP JSFactory::getAllAttributes方法代码示例

本文整理汇总了PHP中JSFactory::getAllAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP JSFactory::getAllAttributes方法的具体用法?PHP JSFactory::getAllAttributes怎么用?PHP JSFactory::getAllAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSFactory的用法示例。


在下文中一共展示了JSFactory::getAllAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBuildSelectAttributes

 function getBuildSelectAttributes($attributeValues, $attributeActive, $displayonlyattrtype = null)
 {
     $jshopConfig = JSFactory::getConfig();
     if (!$jshopConfig->admin_show_attributes) {
         return array();
     }
     $dispatcher = JDispatcher::getInstance();
     $attrib = JSFactory::getAllAttributes();
     $userShop = JSFactory::getUserShop();
     $selects = array();
     foreach ($attrib as $k => $v) {
         $attr_id = $v->attr_id;
         if ($displayonlyattrtype) {
             $v->attr_type = $displayonlyattrtype;
         }
         if (isset($attributeValues[$attr_id]) && $attributeValues[$attr_id]) {
             if (isset($attributeActive[$attr_id])) {
                 $_firstval = $attributeActive[$attr_id];
             } else {
                 $_firstval = 0;
             }
             $selects[$attr_id] = new stdClass();
             $selects[$attr_id]->attr_id = $attr_id;
             $selects[$attr_id]->attr_name = $v->name;
             $selects[$attr_id]->attr_description = $v->description;
             $selects[$attr_id]->groupname = $v->groupname;
             $selects[$attr_id]->firstval = $_firstval;
             $options = $attributeValues[$attr_id];
             $attrimage = array();
             foreach ($options as $k2 => $v2) {
                 $attrimage[$v2->val_id] = $v2->image;
                 $addPrice = $v2->addprice;
                 $addPrice = getPriceFromCurrency($addPrice, $this->currency_id);
                 $addPrice = getPriceCalcParamsTax($addPrice, $this->product_tax_id);
                 if ($userShop->percent_discount) {
                     $addPrice = getPriceDiscount($addPrice, $userShop->percent_discount);
                 }
                 $options[$k2]->addprice = $addPrice;
             }
             if ($v->attr_type == 1) {
                 // attribut type select
                 if ($jshopConfig->attr_display_addprice) {
                     foreach ($options as $k2 => $v2) {
                         if (($v2->price_mod == "+" || $v2->price_mod == "-" || $jshopConfig->attr_display_addprice_all_sign) && $v2->addprice > 0) {
                             $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice, null, 0, -1) . ")";
                             $options[$k2]->value_name .= $ext_price_info;
                         }
                     }
                 }
                 if ($jshopConfig->product_attribut_first_value_empty) {
                     $first = array();
                     $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'val_id', 'value_name');
                     $options = array_merge($first, $options);
                 }
                 if (isset($attributeActive[$attr_id]) && isset($attrimage[$attributeActive[$attr_id]])) {
                     $_active_image = $attrimage[$attributeActive[$attr_id]];
                 } else {
                     $_active_image = '';
                 }
                 if (isset($attributeActive[$attr_id])) {
                     $_select_active = $attributeActive[$attr_id];
                 } else {
                     $_select_active = '';
                 }
                 $html_select_attribute_param = 'class="' . $jshopConfig->frontend_attribute_select_class_css . '" size = "' . $jshopConfig->frontend_attribute_select_size . '" onchange="setAttrValue(\'' . $attr_id . '\', this.value);"';
                 $selects[$attr_id]->selects = JHTML::_('select.genericlist', $options, 'jshop_attr_id[' . $attr_id . ']', $html_select_attribute_param, 'val_id', 'value_name', $_select_active) . "<span class='prod_attr_img'>" . $this->getHtmlDisplayProdAttrImg($attr_id, $_active_image) . "</span>";
                 $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects);
             } else {
                 // attribut type radio
                 foreach ($options as $k2 => $v2) {
                     if ($v2->image) {
                         $options[$k2]->value_name = "<img src='" . $jshopConfig->image_attributes_live_path . "/" . $v2->image . "' alt='' /> " . $v2->value_name;
                     }
                 }
                 if ($jshopConfig->attr_display_addprice) {
                     foreach ($options as $k2 => $v2) {
                         if (($v2->price_mod == "+" || $v2->price_mod == "-" || $jshopConfig->attr_display_addprice_all_sign) && $v2->addprice > 0) {
                             $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice) . ")";
                             $options[$k2]->value_name .= $ext_price_info;
                         }
                     }
                 }
                 $radioseparator = '';
                 if ($jshopConfig->radio_attr_value_vertical) {
                     $radioseparator = "<br/>";
                 }
                 foreach ($options as $k2 => $v2) {
                     $options[$k2]->value_name = "<span class='radio_attr_label'>" . $v2->value_name . "</span>";
                 }
                 $selects[$attr_id]->selects = sprintRadioList($options, 'jshop_attr_id[' . $attr_id . ']', 'onclick="setAttrValue(\'' . $attr_id . '\', this.value);"', 'val_id', 'value_name', $attributeActive[$attr_id], $radioseparator);
                 $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects);
             }
             $dispatcher->trigger('onBuildSelectAttribute', array(&$attributeValues, &$attributeActive, &$selects, &$options, &$attr_id, &$v));
         }
     }
     $grname = '';
     foreach ($selects as $k => $v) {
         if ($v->groupname != $grname) {
             $grname = $v->groupname;
             $selects[$k]->grshow = 1;
//.........这里部分代码省略.........
开发者ID:panickylemon,项目名称:joomlastayn,代码行数:101,代码来源:product.php

示例2: changeProductQTYinStock

 /**
  * get or return product in Stock
  * @param $change ("-" - get, "+" - return) 
  */
 function changeProductQTYinStock($change = "-")
 {
     $db = JFactory::getDBO();
     $dispatcher = JDispatcher::getInstance();
     $query = "SELECT OI.*, P.unlimited FROM `#__jshopping_order_item` as OI left join `#__jshopping_products` as P on P.product_id=OI.product_id\n                  WHERE order_id = '" . $db->escape($this->order_id) . "'";
     $db->setQuery($query);
     $items = $db->loadObjectList();
     $dispatcher->trigger('onBeforechangeProductQTYinStock', array(&$items, &$this, &$change));
     foreach ($items as $item) {
         if ($item->unlimited) {
             continue;
         }
         if ($item->attributes != "") {
             $attributes = unserialize($item->attributes);
         } else {
             $attributes = array();
         }
         if (!is_array($attributes)) {
             $attributes = array();
         }
         $allattribs = JSFactory::getAllAttributes(1);
         $dependent_attr = array();
         foreach ($attributes as $k => $v) {
             if ($allattribs[$k]->independent == 0) {
                 $dependent_attr[$k] = $v;
             }
         }
         if (count($dependent_attr)) {
             $where = "";
             foreach ($dependent_attr as $k => $v) {
                 $where .= " and `attr_{$k}`='" . intval($v) . "'";
             }
             $query = "update `#__jshopping_products_attr` set `count`=`count`  " . $change . " " . $item->product_quantity . " where product_id='" . intval($item->product_id) . "' " . $where;
             $db->setQuery($query);
             $db->query();
             $query = "select sum(count) as qty from `#__jshopping_products_attr` where product_id='" . intval($item->product_id) . "' and `count`>0 ";
             $db->setQuery($query);
             $qty = $db->loadResult();
             $query = "UPDATE `#__jshopping_products` SET product_quantity = '" . $qty . "' WHERE product_id = '" . intval($item->product_id) . "'";
             $db->setQuery($query);
             $db->query();
         } else {
             $query = "UPDATE `#__jshopping_products` SET product_quantity = product_quantity " . $change . " " . $item->product_quantity . " WHERE product_id = '" . intval($item->product_id) . "'";
             $db->setQuery($query);
             $db->query();
         }
         $dispatcher->trigger('onAfterchangeProductQTYinStock', array(&$item, &$change, &$this));
     }
     if ($change == '-') {
         $product_stock_removed = 1;
     } else {
         $product_stock_removed = 0;
     }
     $query = "update #__jshopping_orders set product_stock_removed=" . $product_stock_removed . " WHERE order_id = '" . $db->escape($this->order_id) . "'";
     $db->setQuery($query);
     $db->query();
     $dispatcher->trigger('onAfterchangeProductQTYinStockPSR', array(&$items, &$this, &$change, &$product_stock_removed));
 }
开发者ID:olegverstka,项目名称:monax.dev,代码行数:62,代码来源:order.php

示例3: getBuildSelectAttributes

 function getBuildSelectAttributes($attributeValues, $attributeActive)
 {
     $jshopConfig = JSFactory::getConfig();
     if (!$jshopConfig->admin_show_attributes) {
         return array();
     }
     JPluginHelper::importPlugin('jshoppingproducts');
     $dispatcher = JDispatcher::getInstance();
     $attrib = JSFactory::getAllAttributes();
     $selects = array();
     foreach ($attrib as $k => $v) {
         $attr_id = $v->attr_id;
         if (isset($attributeValues[$attr_id]) && $attributeValues[$attr_id]) {
             if (isset($attributeActive[$attr_id])) {
                 $_firstval = $attributeActive[$attr_id];
             } else {
                 $_firstval = 0;
             }
             $selects[$attr_id] = new stdClass();
             $selects[$attr_id]->attr_id = $attr_id;
             $selects[$attr_id]->attr_name = $v->name;
             $selects[$attr_id]->attr_description = $v->description;
             $selects[$attr_id]->firstval = $_firstval;
             $options = $attributeValues[$attr_id];
             $attrimage = array();
             foreach ($options as $k2 => $v2) {
                 $attrimage[$v2->val_id] = $v2->image;
             }
             if ($v->attr_type == 1) {
                 // attribut type select
                 if ($jshopConfig->attr_display_addprice) {
                     foreach ($options as $k2 => $v2) {
                         if (($v2->price_mod == "+" || $v2->price_mod == "-") && $v2->addprice > 0) {
                             $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice, null, 1) . ")";
                             $options[$k2]->value_name .= $ext_price_info;
                         }
                     }
                 }
                 if ($jshopConfig->product_attribut_first_value_empty) {
                     $first = array();
                     $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'val_id', 'value_name');
                     $options = array_merge($first, $options);
                 }
                 if (isset($attributeActive[$attr_id]) && isset($attrimage[$attributeActive[$attr_id]])) {
                     $_active_image = $attrimage[$attributeActive[$attr_id]];
                 } else {
                     $_active_image = '';
                 }
                 if (isset($attributeActive[$attr_id])) {
                     $_select_active = $attributeActive[$attr_id];
                 } else {
                     $_select_active = '';
                 }
                 $selects[$attr_id]->selects = JHTML::_('select.genericlist', $options, 'jshop_attr_id[' . $attr_id . ']', 'class = "inputbox" size = "1" onchange="setAttrValue(\'' . $attr_id . '\', this.value);"', 'val_id', 'value_name', $_select_active) . "<span class='prod_attr_img'>" . $this->getHtmlDisplayProdAttrImg($attr_id, $_active_image) . "</span>";
                 $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects);
             } else {
                 // attribut type radio
                 foreach ($options as $k2 => $v2) {
                     if ($v2->image) {
                         $options[$k2]->value_name = "<img src='" . $jshopConfig->image_attributes_live_path . "/" . $v2->image . "' alt='' /> " . $v2->value_name;
                     }
                 }
                 if ($jshopConfig->attr_display_addprice) {
                     foreach ($options as $k2 => $v2) {
                         if (($v2->price_mod == "+" || $v2->price_mod == "-") && $v2->addprice > 0) {
                             $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice, null, 1) . ")";
                             $options[$k2]->value_name .= $ext_price_info;
                         }
                     }
                 }
                 $radioseparator = '';
                 if ($jshopConfig->radio_attr_value_vertical) {
                     $radioseparator = "<br/>";
                 }
                 foreach ($options as $k2 => $v2) {
                     $options[$k2]->value_name = "<span class='radio_attr_label'>" . $v2->value_name . "</span>";
                 }
                 $selects[$attr_id]->selects = sprintRadioList($options, 'jshop_attr_id[' . $attr_id . ']', 'onclick="setAttrValue(\'' . $attr_id . '\', this.value);"', 'val_id', 'value_name', $attributeActive[$attr_id], $radioseparator);
                 $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects);
             }
             $dispatcher->trigger('onBuildSelectAttribute', array(&$attributeValues, &$attributeActive, &$selects, &$options, &$attr_id, &$v));
         }
     }
     return $selects;
 }
开发者ID:ngogiangthanh,项目名称:damtvnewversion,代码行数:85,代码来源:product.php


注:本文中的JSFactory::getAllAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。