本文整理汇总了PHP中Customer::getDefaultGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::getDefaultGroupId方法的具体用法?PHP Customer::getDefaultGroupId怎么用?PHP Customer::getDefaultGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::getDefaultGroupId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReduction
public static function getReduction($id_customer = null)
{
if (!isset(self::$cache_reduction['customer'][(int) $id_customer])) {
$id_group = $id_customer ? Customer::getDefaultGroupId((int) $id_customer) : (int) Group::getCurrent()->id;
self::$cache_reduction['customer'][(int) $id_customer] = Group::getReductionByIdGroup($id_group);
}
return self::$cache_reduction['customer'][(int) $id_customer];
}
示例2: getReduction
public static function getReduction($id_customer = null)
{
if (!isset(self::$cache_reduction['customer'][(int) $id_customer])) {
$id_group = $id_customer ? Customer::getDefaultGroupId((int) $id_customer) : (int) Configuration::get('PS_CUSTOMER_GROUP');
self::$cache_reduction['customer'][(int) $id_customer] = Group::getReductionByIdGroup($id_group);
}
return self::$cache_reduction['customer'][(int) $id_customer];
}
示例3: getTaxCalculator
/**
* Return the tax calculator associated to this address.
*
* @return TaxCalculator
*/
public function getTaxCalculator()
{
static $tax_enabled = null;
if (isset($this->tax_calculator)) {
return $this->tax_calculator;
}
if ($tax_enabled === null) {
$tax_enabled = Configuration::get('PS_TAX');
}
if (!$tax_enabled) {
return new TaxCalculator(array());
}
$taxes = array();
$postcode = 0;
if (!empty($this->address->postcode)) {
$postcode = $this->address->postcode;
}
$context = Context::getContext();
$cache_id = (int) $this->address->id_country . '-' . (int) $this->address->id_state . '-' . $postcode . '-' . (int) $this->type;
if (!Cache::isStored($cache_id)) {
$rows = Db::getInstance()->executeS('
SELECT tr.*
FROM `' . _DB_PREFIX_ . 'tax_rule` tr
JOIN `' . _DB_PREFIX_ . 'tax_rules_group` trg ON (tr.`id_tax_rules_group` = trg.`id_tax_rules_group`)
WHERE trg.`active` = 1
AND tr.`id_country` = ' . (int) $this->address->id_country . '
AND tr.`id_tax_rules_group` = ' . (int) $this->type . '
AND tr.`id_state` IN (0, ' . (int) $this->address->id_state . ')
AND (tr.`id_group` = ' . (int) Customer::getDefaultGroupId((int) $context->customer->id) . ' OR tr.`id_group` = 0)
AND (\'' . pSQL($postcode) . '\' BETWEEN tr.`zipcode_from` AND tr.`zipcode_to` OR (tr.`zipcode_to` = 0 AND tr.`zipcode_from` IN(0, \'' . pSQL($postcode) . '\')))
ORDER BY tr.`zipcode_from` DESC, tr.`zipcode_to` DESC, tr.`id_state` DESC, tr.`id_country` DESC');
$behavior = 0;
$first_row = true;
foreach ($rows as $row) {
$tax = new Tax((int) $row['id_tax']);
$taxes[] = $tax;
// the applied behavior correspond to the most specific rules
if ($first_row) {
$behavior = $row['behavior'];
$first_row = false;
}
if ($row['behavior'] == 0) {
break;
}
}
Cache::store($cache_id, new TaxCalculator($taxes, $behavior));
}
return Cache::retrieve($cache_id);
}
示例4: process
public function process()
{
global $cart, $currency;
parent::process();
if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) {
$this->errors[] = Tools::displayError('Product not found');
} else {
if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) {
header('HTTP/1.1 404 page not found');
$this->errors[] = Tools::displayError('Product is no longer available.');
} elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) {
$this->errors[] = Tools::displayError('You do not have access to this product.');
} else {
self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
if (!$this->product->active) {
self::$smarty->assign('adminActionDisplay', true);
}
/* rewrited url set */
$rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
/* Product pictures management */
require_once 'images.inc.php';
self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
$this->pictureUpload($this->product, $cart);
$this->textRecord($this->product, $cart);
$this->formTargetFormat();
} elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
}
$files = self::$cookie->getFamily('pictures_' . (int) $this->product->id);
$textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id);
foreach ($textFields as $key => $textField) {
$textFields[$key] = str_replace('<br />', "\n", $textField);
}
self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
if ((int) Tools::getValue('pp') == 1) {
echo 'here1';
}
$productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6);
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
}
if ((int) Tools::getValue('pp') == 1) {
$time2 = time();
echo 'time2: ' . $time2;
}
$productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
$configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES'));
/* Features / Values */
$features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
$attachments = $this->product->getAttachments((int) self::$cookie->id_lang);
/* Category */
$category = false;
if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
if (isset($regs[2]) and is_numeric($regs[2])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) {
$category = new Category((int) $regs[2], (int) self::$cookie->id_lang);
}
} elseif (isset($regs[5]) and is_numeric($regs[5])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) {
$category = new Category((int) $regs[5], (int) self::$cookie->id_lang);
}
}
}
if (!$category) {
$category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang);
}
if (isset($category) and Validate::isLoadedObject($category)) {
self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name)));
} else {
self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
}
self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
$lang = Configuration::get('PS_LANG_DEFAULT');
if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) {
$this->product->quantity = 0;
}
$group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100;
$id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
$id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
if ((int) Tools::getValue('pp') == 1) {
$time3 = time();
echo 'time3: ' . $time3;
}
// Tax
$tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
self::$smarty->assign('tax_rate', $tax);
$ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
}
$manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1);
$sizechart = new Sizechart((int) $this->product->id_sizechart, 1);
//see if the product is already in the wishlist
if ($id_customer) {
$sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id;
$res = Db::getInstance()->ExecuteS($sql);
if ($res) {
//.........这里部分代码省略.........
示例5: getPriceStatic
public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null, $only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null, $id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null, $use_customer_price = true)
{
if (!$context) {
$context = Context::getContext();
}
$cur_cart = $context->cart;
if ($divisor !== null) {
Tools::displayParameterAsDeprecated('divisor');
}
if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product)) {
die(Tools::displayError());
}
$id_group = null;
if ($id_customer) {
$id_group = Customer::getDefaultGroupId((int) $id_customer);
}
if (!$id_group) {
$id_group = (int) Group::getCurrent()->id;
}
if (!is_object($cur_cart) || Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart) {
/*
* When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
* When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
* When called from the back office, cart ID can be inexistant
*/
if (!$id_cart && !isset($context->employee)) {
die(Tools::displayError());
}
$cur_cart = new Cart($id_cart);
if (!Validate::isLoadedObject($context->cart)) {
$context->cart = $cur_cart;
}
}
$qty = $quantity;
if (is_array($quantity)) {
$quantity = PP::resolveQty($qty[0], $qty[1]);
}
$cart_quantity = 0;
if ((int) $id_cart) {
$cache_id = 'Product::getPriceStatic_' . (int) $id_product . '-' . (int) $id_cart;
if (!Cache::isStored($cache_id) || ($cart_quantity = Cache::retrieve($cache_id) != (double) $quantity)) {
$sql = 'SELECT SUM(' . PP::sqlQty('quantity') . ')
FROM `' . _DB_PREFIX_ . 'cart_product`
WHERE `id_product` = ' . (int) $id_product . '
AND `id_cart` = ' . (int) $id_cart;
$cart_quantity = (double) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
Cache::store($cache_id, $cart_quantity);
}
$cart_quantity = Cache::retrieve($cache_id);
}
$id_currency = (int) Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
$id_country = (int) $context->country->id;
$id_state = 0;
$zipcode = 0;
if (!$id_address && Validate::isLoadedObject($cur_cart)) {
$id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
}
if ($id_address) {
$address_infos = Address::getCountryAndState($id_address);
if ($address_infos['id_country']) {
$id_country = (int) $address_infos['id_country'];
$id_state = (int) $address_infos['id_state'];
$zipcode = $address_infos['postcode'];
}
} elseif (isset($context->customer->geoloc_id_country)) {
$id_country = (int) $context->customer->geoloc_id_country;
$id_state = (int) $context->customer->id_state;
$zipcode = $context->customer->postcode;
}
if (Tax::excludeTaxeOption()) {
$usetax = false;
}
if ($usetax != false && !empty($address_infos['vat_number']) && $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') && Configuration::get('VATNUMBER_MANAGEMENT')) {
$usetax = false;
}
if (is_null($id_customer) && Validate::isLoadedObject($context->customer)) {
$id_customer = $context->customer->id;
}
return Product::priceCalculation($context->shop->id, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $qty, $usetax, $decimals, $only_reduc, $usereduc, $with_ecotax, $specific_price_output, $use_group_reduction, $id_customer, $use_customer_price, $id_cart, $cart_quantity);
}
示例6: isDiscounted
public static function isDiscounted($id_product, $quantity = 1)
{
global $cookie, $cart;
$id_customer = (Validate::isCookie($cookie) and isset($cookie->id_customer) and $cookie->id_customer) ? (int) $cookie->id_customer : NULL;
$id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$cart_quantity = !$cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(`quantity`)
FROM `' . _DB_PREFIX_ . 'cart_product`
WHERE `id_product` = ' . (int) $id_product . ' AND `id_cart` = ' . (int) $cart->id);
$quantity = $cart_quantity ? $cart_quantity : $quantity;
$id_currency = (int) (Validate::isLoadedObject($cart) ? $cart->id_currency : ((isset($cookie->id_currency) and (int) $cookie->id_currency) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));
$ids = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
$id_shop = (int) Shop::getCurrentShop();
return (bool) SpecificPrice::getSpecificPrice((int) $id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity);
}
示例7: process
public function process()
{
global $cart, $currency;
parent::process();
if (!Validate::isLoadedObject($this->product)) {
$this->errors[] = Tools::displayError('Product not found');
} else {
if (!$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) {
header('HTTP/1.1 404 page not found');
$this->errors[] = Tools::displayError('Product is no longer available.');
} elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) {
$this->errors[] = Tools::displayError('You do not have access to this product.');
} else {
self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
if (!$this->product->active) {
self::$smarty->assign('adminActionDisplay', true);
}
/* Product pictures management */
require_once 'images.inc.php';
if ($this->product->customizable) {
self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
$this->pictureUpload($this->product, $cart);
$this->textRecord($this->product, $cart);
$this->formTargetFormat();
} elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
}
$files = self::$cookie->getFamily('pictures_' . (int) $this->product->id);
$textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id);
foreach ($textFields as $key => $textField) {
$textFields[$key] = str_replace('<br />', "\n", $textField);
}
self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
}
/* Features / Values */
$features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
$attachments = $this->product->cache_has_attachments ? $this->product->getAttachments((int) self::$cookie->id_lang) : array();
/* Category */
$category = false;
if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
if (isset($regs[2]) and is_numeric($regs[2])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) {
$category = new Category((int) $regs[2], (int) self::$cookie->id_lang);
}
} elseif (isset($regs[5]) and is_numeric($regs[5])) {
if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) {
$category = new Category((int) $regs[5], (int) self::$cookie->id_lang);
}
}
}
if (!$category) {
$category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang);
}
if (isset($category) and Validate::isLoadedObject($category)) {
self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name)));
} else {
self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
}
self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
if (Pack::isPack((int) $this->product->id) and !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100;
$id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
$id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
// Tax
$tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
self::$smarty->assign('tax_rate', $tax);
$productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6);
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
}
$productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
$ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
}
self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, self::$cookie->id_lang), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_));
self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
$images = $this->product->getImages((int) self::$cookie->id_lang);
$productImages = array();
foreach ($images as $k => $image) {
if ($image['cover']) {
self::$smarty->assign('mainImage', $images[0]);
$cover = $image;
$cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
$cover['id_image_only'] = (int) $image['id_image'];
}
$productImages[(int) $image['id_image']] = $image;
}
if (!isset($cover)) {
$cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
}
$size = Image::getSize('large');
self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang)));
if (count($productImages)) {
self::$smarty->assign('images', $productImages);
//.........这里部分代码省略.........
示例8: get_moreAttributesPrice
$request_attr_3 = $row['id_attribute'];
break;
}
$counter++;
}
}
// Get price changes
$more_attributes_price = 0;
if (count($more_attributes)) {
$more_attributes_price = get_moreAttributesPrice($more_attributes, $request_product);
}
// Get the group reduction
$group_reduction = 1;
$group_id = 0;
if (isset($cookie->id_customer)) {
$group_id = Customer::getDefaultGroupId($cookie->id_customer);
$groupReduction = GroupReduction::getValueForProduct($request_product, $group_id);
if (!$groupReduction) {
$group_reduction -= floatval(Group::getReduction($cookie->id_customer)) / 100;
} else {
$group_reduction -= floatval($groupReduction);
}
}
$more_attributes_price *= $group_reduction;
// If other return only the attributes price
if ($request_others && ($request_attr_2 == '' && $request_attr_3 == '-1' || $request_attr_2 != '' && $request_attr_3 == '' || $request_value == '')) {
die('Price->' . $more_attributes_price);
}
$group = str_replace('group_', '', $request_group);
$result = DB::getInstance()->ExecuteS('SELECT attribute.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS attribute, ' . _DB_PREFIX_ . 'attribute_lang AS lang WHERE attribute.id_attribute_group = ' . $group . ' AND lang.name = "' . $param1 . '" AND lang.id_lang = ' . (int) $cookie->id_lang . ' AND attribute.id_attribute = lang.id_attribute');
// Value creation if needed
示例9: getReduction
public static function getReduction($id_customer = NULL)
{
if (!isset(self::$_cacheReduction['customer'][(int) $id_customer])) {
$id_group = $id_customer ? Customer::getDefaultGroupId((int) $id_customer) : 1;
self::$_cacheReduction['customer'][(int) $id_customer] = Group::getReductionByIdGroup($id_group);
}
return self::$_cacheReduction['customer'][(int) $id_customer];
}
示例10: hookLeftColumn
public function hookLeftColumn($params)
{
global $smarty, $cookie;
$id_customer = (int) $params['cookie']->id_customer;
$id_group = $id_customer ? Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_product = (int) Tools::getValue('id_product', 0);
$id_category = (int) Tools::getValue('id_category', 0);
$id_lang = (int) $params['cookie']->id_lang;
$smartyCacheId = 'blockcategories|' . $id_group . '_' . $id_lang . '_' . $id_product . '_' . $id_category;
Tools::enableCache();
if (!$this->isCached('blockcategories.tpl', $smartyCacheId)) {
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `' . _DB_PREFIX_ . 'category` c
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
' . ((int) $maxdepth != 0 ? ' AND `level_depth` <= ' . (int) $maxdepth : '') . '
AND cg.`id_group` = ' . $id_group . '
ORDER BY `level_depth` ASC, c.`position` ASC'))) {
return;
}
$resultParents = array();
$resultIds = array();
foreach ($result as &$row) {
$resultParents[$row['id_parent']][] =& $row;
$resultIds[$row['id_category']] =& $row;
}
$blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'));
unset($resultParents);
unset($resultIds);
$isDhtml = Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false;
if (Tools::isSubmit('id_category')) {
$cookie->last_visited_category = $id_category;
$smarty->assign('currentCategoryId', $cookie->last_visited_category);
}
if (Tools::isSubmit('id_product')) {
if (!isset($cookie->last_visited_category) or !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $cookie->last_visited_category)))) {
$product = new Product($id_product);
if (isset($product) and Validate::isLoadedObject($product)) {
$cookie->last_visited_category = (int) $product->id_category_default;
}
}
$smarty->assign('currentCategoryId', (int) $cookie->last_visited_category);
}
$smarty->assign('blockCategTree', $blockCategTree);
if (file_exists(_PS_THEME_DIR_ . 'modules/blockcategories/blockcategories.tpl')) {
$smarty->assign('branche_tpl_path', _PS_THEME_DIR_ . 'modules/blockcategories/category-tree-branch.tpl');
} else {
$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_ . 'blockcategories/category-tree-branch.tpl');
}
$smarty->assign('isDhtml', $isDhtml);
}
$smarty->cache_lifetime = 31536000;
// 1 Year
$display = $this->display(__FILE__, 'blockcategories.tpl', $smartyCacheId);
Tools::restoreCacheSettings();
return $display;
}
示例11: sendReminders
public function sendReminders()
{
$id_order_state_for_reminder = (int) Configuration::get('PS_OS_MF_REMINDER');
$id_order_state_for_lastreminder = (int) Configuration::get('PS_OS_MF_LASTREMINDER');
if ($id_order_state_for_reminder == 0 && !Validate::isObjectLoaded(new OrderState((int) $id_order_state_for_reminder))) {
self::logToFile('cron has been stopped - "Reminder" order state has not been defined. Please check configuration.', 'cron');
} elseif ($id_order_state_for_lastreminder == 0 && !Validate::isObjectLoaded(new OrderState((int) $id_order_state_for_lastreminder))) {
self::logToFile('cron has been stopped - "Last Reminder" order state has not been defined. Please check configuration.', 'cron');
} else {
$reminder_init_os = array();
$reminder_days = array();
$active_euro_shops = array();
$orders = Db::getInstance()->executeS('SELECT a.`id_order`, a.`id_shop`, a.`current_state`, a.`id_lang`, a.`id_customer`, a.`id_currency`
FROM ' . _DB_PREFIX_ . 'orders a LEFT JOIN ' . _DB_PREFIX_ . 'mf_claims c ON a.`id_order`=c.`id_order` WHERE c.`id_order` IS NULL');
foreach ($orders as $order) {
//check currency
if (!isset($active_euro_shops[$order['id_shop']])) {
$active_euro_shops[$order['id_shop']] = $this->getActiveEuroCurrencyID($order['id_shop']);
$active_euro = $active_euro_shops[$order['id_shop']];
} else {
$active_euro = $active_euro_shops[$order['id_shop']];
}
//$active_euro = 1; // for testing
if ((int) $active_euro == 0) {
self::logToFile('Order ' . $order['id_order'] . ' - euro is not active for shop', 'cron');
} elseif ($active_euro != $order['id_currency']) {
self::logToFile('Order ' . $order['id_order'] . ' - euro is not currency of order', 'cron');
} else {
//get customer group
$id_customer_group = Customer::getDefaultGroupId($order['id_customer']);
// *send reminder*
//check current order state
if (!isset($reminder_init_os[$order['id_shop']])) {
$reminder_init_os[$order['id_shop']] = Tools::jsonDecode(Configuration::get('MEDIAFINANZ_REMINDER_INIT_OS', null, null, $order['id_shop']), true);
$init_os = $reminder_init_os[$order['id_shop']];
} else {
$init_os = $reminder_init_os[$order['id_shop']];
}
if (in_array($order['current_state'], $init_os)) {
// get days
if (!isset($reminder_days[$order['id_shop']])) {
$reminder_days[$order['id_shop']] = Tools::jsonDecode(Configuration::get('MEDIAFINANZ_GROUP_REM', null, null, $order['id_shop']), true);
$days = $reminder_days[$order['id_shop']];
} else {
$days = $reminder_days[$order['id_shop']];
}
$days_x = (int) $days[(string) $id_customer_group];
$order_obj = new Order($order['id_order']);
$history_entities = $order_obj->getHistory($order['id_lang'], $order['current_state']);
$last_history_entity = end($history_entities);
$date_reminder = $last_history_entity['date_add'];
$days_between = ceil(abs(strtotime(date('Y-m-d H:i:s')) - strtotime($date_reminder)) / 86400);
if ($days_between >= $days_x) {
try {
if ($this->changeOrderState($order['id_order'], $id_order_state_for_reminder)) {
self::logToFile('Order ' . $order['id_order'] . ' - send reminder - successful - mail has been sent', 'cron');
} else {
self::logToFile('Order ' . $order['id_order'] . ' - send reminder - successful - mail has not been sent ', 'cron');
}
} catch (Exception $e) {
self::logToFile('Order ' . $order['id_order'] . ' - send reminder - failed - ' . $e->getMessage(), 'cron');
}
}
}
//*send last reminder*
if ($order['current_state'] == $id_order_state_for_reminder) {
// get days
if (!isset($reminder_days[$order['id_shop']])) {
$reminder_days[$order['id_shop']] = Tools::jsonDecode(Configuration::get('MEDIAFINANZ_GROUP_LASTREM', null, null, $order['id_shop']), true);
$days = $reminder_days[$order['id_shop']];
} else {
$days = $reminder_days[$order['id_shop']];
}
$days_y = (int) $days[(string) $id_customer_group];
$order_obj = new Order($order['id_order']);
$history_entities = $order_obj->getHistory($order['id_lang'], $order['current_state']);
$last_history_entity = end($history_entities);
$date_reminder = $last_history_entity['date_add'];
$days_between = ceil(abs(strtotime(date('Y-m-d H:i:s')) - strtotime($date_reminder)) / 86400);
if ($days_between >= $days_y) {
try {
if ($this->changeOrderState($order['id_order'], $id_order_state_for_lastreminder)) {
self::logToFile('Order ' . $order['id_order'] . ' - send lastreminder - successful - mail has been sent', 'cron');
} else {
self::logToFile('Order ' . $order['id_order'] . ' - send lastreminder - successful - mail has not been sent ', 'cron');
}
} catch (Exception $e) {
self::logToFile('Order ' . $order['id_order'] . ' - send lastreminder - failed - ' . $e->getMessage(), 'cron');
}
}
}
}
}
}
}
示例12: _getPricesDropProductsIds
private function _getPricesDropProductsIds()
{
$sqlGroups = '';
if (version_compare(_PS_VERSION_, '1.6.0.0', '>=') && Group::isFeatureActive() && version_compare(_PS_VERSION_, '1.6.0.0', '<')) {
$currentGroups = FrontController::getCurrentCustomerGroups();
$sqlGroups = 'AND cg.`id_group` ' . (is_array($currentGroups) && sizeof($currentGroups) ? 'IN (' . implode(',', $currentGroups) . ')' : '= 1');
}
$currentDate = date('Y-m-d H:i:s');
if (version_compare(_PS_VERSION_, '1.5.0.0', '<')) {
global $cookie, $cart;
$id_group = $cookie->id_customer ? (int) Customer::getDefaultGroupId((int) $cookie->id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$ids = Address::getCountryAndState($id_address);
$id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
$ids_product = SpecificPrice::getProductIdByDate((int) Shop::getCurrentShop(), (int) $cookie->id_currency, $id_country, $id_group, $currentDate, $currentDate);
} else {
$id_address = $this->_context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$ids = Address::getCountryAndState($id_address);
$id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
$ids_product = SpecificPrice::getProductIdByDate($this->_context->shop->id, $this->_context->currency->id, $id_country, $this->_context->customer->id_default_group, $currentDate, $currentDate, 0, false);
}
$tab_id_product = array();
foreach ($ids_product as $product) {
if (is_array($product)) {
$tab_id_product[] = (int) $product['id_product'];
} else {
$tab_id_product[] = (int) $product;
}
}
Db::getInstance()->Execute('SET group_concat_max_len := @@max_allowed_packet');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT GROUP_CONCAT(p.id_product) as pid_list
FROM `' . _DB_PREFIX_ . 'product` p
' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlAssociation('product', 'p') : '') . '
WHERE ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`active` = 1
AND ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`show_price` = 1
' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND product_shop.`visibility` IN ("both", "catalog") ' : '') . '
AND ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`id_product` IN (' . (is_array($tab_id_product) && count($tab_id_product) ? implode(', ', $tab_id_product) : 0) . ')
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_group` cg
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . $sqlGroups . '
)');
if ($result && isset($result['pid_list']) && !empty($result['pid_list'])) {
return explode(',', $result['pid_list']);
}
return array(0);
}
示例13: getReduction
public static function getReduction($id_customer = NULL)
{
if (!isset(self::$_cacheReduction['customer'][(int) $id_customer])) {
self::$_cacheReduction['customer'][(int) $id_customer] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `reduction`
FROM `' . _DB_PREFIX_ . 'group`
WHERE `id_group` = ' . ((int) $id_customer ? Customer::getDefaultGroupId((int) $id_customer) : 1));
}
return self::$_cacheReduction['customer'][(int) $id_customer];
}