本文整理汇总了PHP中GroupReduction::getGroupReductions方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupReduction::getGroupReductions方法的具体用法?PHP GroupReduction::getGroupReductions怎么用?PHP GroupReduction::getGroupReductions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupReduction
的用法示例。
在下文中一共展示了GroupReduction::getGroupReductions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatCategoryDiscountList
protected function formatCategoryDiscountList($id)
{
$category = GroupReduction::getGroupReductions((int) $id, $this->context->language->id);
$category_reductions = array();
$category_reduction = Tools::getValue('category_reduction');
foreach ($category as $category) {
if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction)) {
$category['reduction'] = $category_reduction[$category['id_category']];
}
$tmp = array();
$tmp['path'] = getPath(self::$currentIndex . '?tab=AdminCategories', (int) $category['id_category']);
$tmp['reduction'] = (double) $category['reduction'] * 100;
$tmp['id_category'] = (int) $category['id_category'];
$category_reductions[(int) $category['id_category']] = $tmp;
}
if (is_array($category_reduction)) {
foreach ($category_reduction as $key => $val) {
if (!array_key_exists($key, $category_reductions)) {
$tmp = array();
$tmp['path'] = getPath(self::$currentIndex . '?tab=AdminCategories', $key);
$tmp['reduction'] = (double) $val * 100;
$tmp['id_category'] = (int) $key;
$category_reductions[(int) $category['id_category']] = $tmp;
}
}
}
return $category_reductions;
}
示例2: formatCategoryDiscountList
protected function formatCategoryDiscountList($id_group)
{
$group_reductions = GroupReduction::getGroupReductions((int) $id_group, $this->context->language->id);
$category_reductions = array();
$category_reduction = Tools::getValue('category_reduction');
foreach ($group_reductions as $category) {
if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction)) {
$category['reduction'] = $category_reduction[$category['id_category']];
}
$category_reductions[(int) $category['id_category']] = array('path' => getPath(Context::getContext()->link->getAdminLink('AdminCategories'), (int) $category['id_category']), 'reduction' => (double) $category['reduction'] * 100, 'id_category' => (int) $category['id_category']);
}
if (is_array($category_reduction)) {
foreach ($category_reduction as $key => $val) {
if (!array_key_exists($key, $category_reductions)) {
$category_reductions[(int) $key] = array('path' => getPath(Context::getContext()->link->getAdminLink('AdminCategories'), $key), 'reduction' => (double) $val * 100, 'id_category' => (int) $key);
}
}
}
return $category_reductions;
}
示例3: displayForm
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true))) {
return;
}
$groupReductions = $obj->id ? GroupReduction::getGroupReductions($obj->id, (int) $cookie->id_lang) : array();
$categories = Category::getSimpleCategories((int) $cookie->id_lang);
echo '
<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
<fieldset class="width3"><legend><img src="../img/admin/tab-groups.gif" alt="" />' . $this->l('Customer group') . '</legend>
<label>' . $this->l('Name:') . ' </label>
<div class="margin-form">';
foreach ($this->_languages as $language) {
echo '
<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
<input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span></span>
</div>';
}
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
$reduction = htmlentities($this->getFieldValue($obj, 'reduction'), ENT_COMPAT, 'UTF-8');
echo '
</div>
<div class="clear"> </div>
<label>' . $this->l('Discount:') . ' </label>
<div class="margin-form">
<input type="text" size="5" name="reduction" value="' . ($reduction ? $reduction : '0') . '" /> ' . $this->l('%') . '
<p>' . $this->l('Will automatically apply this value as a discount on ALL shop\'s products for this group\'s members.') . '</p>
</div>';
if ($obj->id) {
echo '
<label>' . $this->l('Current category discount:') . '</label>
<div class="margin-form">';
if ($groupReductions) {
echo '<table>
<tr>
<th>' . $this->l('Category') . '</th>
<th>' . $this->l('Value') . '</th>
<th>' . $this->l('Action') . '</th>
</tr>';
foreach ($groupReductions as $groupReduction) {
echo '
<tr>
<td>' . Tools::htmlentitiesUTF8($groupReduction['category_name']) . '</td>
<td><input type="hidden" name="gr_id_group_reduction[]" value="' . (int) $groupReduction['id_group_reduction'] . '" /><input type="text" name="gr_reduction[]" value="' . $groupReduction['reduction'] * 100 . '" /></td>
<td><a href="' . $currentIndex . '&deleteGroupReduction&id_group_reduction=' . (int) $groupReduction['id_group_reduction'] . '&id_group=' . (int) $obj->id . '&token=' . $this->token . '"><img src="" alt="' . $this->l('Delete') . '" /></a></td>
</tr>';
}
echo '</table>';
} else {
echo $this->l('No discount');
}
echo ' </div>';
}
echo '
<label>' . $this->l('Price display method:') . ' </label>
<div class="margin-form">
<select name="price_display_method">
<option value="' . PS_TAX_EXC . '"' . ((int) $this->getFieldValue($obj, 'price_display_method') == PS_TAX_EXC ? ' selected="selected"' : '') . '>' . $this->l('Tax excluded') . '</option>
<option value="' . PS_TAX_INC . '"' . ((int) $this->getFieldValue($obj, 'price_display_method') == PS_TAX_INC ? ' selected="selected"' : '') . '>' . $this->l('Tax included') . '</option>
</select>
<p>' . $this->l('How the prices are displayed on order summary for this customer group (tax included or excluded).') . '</p>
</div>
<div class="clear"> </div>
<div class="margin-form">
<input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" />
</div>
<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
</fieldset>
</form><br />';
if ($obj->id) {
echo '
<form action="' . $currentIndex . '&update' . $this->table . '&id_group=' . $obj->id . '&token=' . $this->token . '" method="post" class="width3">
<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />
<fieldset><legend><img src="../img/admin/tab-groups.gif" />' . $this->l('New group discount') . '</legend>
<label>' . $this->l('Category:') . ' </label>
<div class="margin-form">
<select name="id_category">';
foreach ($categories as $category) {
echo ' <option value="' . (int) $category['id_category'] . '">' . Tools::htmlentitiesUTF8($category['name']) . '</option>';
}
echo ' </select><sup>*</sup>
<p>' . $this->l('Only products that have this category as default category will be affected') . '.</p>
</div>
<label>' . $this->l('Discount (in %):') . ' </label>
<div class="margin-form">
<input type="text" name="reductionByCategory" value="" /><sup>*</sup>
</div>
<div class="clear"> </div>
<div class="margin-form">
<input type="submit" value="' . $this->l(' Add ') . '" name="submitAddGroupReduction" class="button" />
</div>
<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
</fieldset>
</form>';
}
}