本文整理汇总了PHP中Combination::getAttributesName方法的典型用法代码示例。如果您正苦于以下问题:PHP Combination::getAttributesName方法的具体用法?PHP Combination::getAttributesName怎么用?PHP Combination::getAttributesName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Combination
的用法示例。
在下文中一共展示了Combination::getAttributesName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignPriceAndTax
/**
* Assign price and tax to the template
*/
protected function assignPriceAndTax()
{
die('coucou');
$id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
$id_group = (int) Group::getCurrent()->id;
$id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
$group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
// Tax
$tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate', $tax);
$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
}
$product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
$ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
}
$id_currency = (int) $this->context->cookie->id_currency;
$id_product = (int) $this->product->id;
$id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
foreach ($quantity_discounts as &$quantity_discount) {
if ($quantity_discount['id_product_attribute']) {
$combination = new Combination((int) $quantity_discount['id_product_attribute']);
$attributes = $combination->getAttributesName((int) $this->context->language->id);
foreach ($attributes as $attribute) {
$quantity_discount['attributes'] = $attribute['name'] . ' - ';
}
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
}
if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
}
}
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
}
示例2: dirname
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
$context = Context::getContext();
$action = Tools::getValue('action');
$add = !strcmp($action, 'add') ? 1 : 0;
$id_product = (int) Tools::getValue('id_product');
$quantity = (int) Tools::getValue('quantity');
$id_product_attribute = (int) Tools::getValue('id_product_attribute');
$result = array();
$data = array();
$result['data'] = date('Y-m-d H:i:s');
$result['action'] = $action;
$product = new Product($id_product, false, $context->cookie->id_lang);
$result['name'] = $product->name;
$result['quantity'] = $quantity ? $quantity : 1;
$result['price'] = $product->price;
if ($id_product_attribute) {
$combination = new Combination($id_product_attribute);
$attributes = $combination->getAttributesName($context->cookie->id_lang);
$name = array();
foreach ($attributes as $a) {
$name[] = $a['name'];
}
$name = implode(' ', $name);
$result['name'] = $result['name'] . ' ' . $name;
$result['price'] = $result['price'] + $combination->price;
}
$result['price'] = Tools::displayPrice($result['price']);
$data['params'] = $result;
$data['number'] = Configuration::get('YA_METRIKA_NUMBER');
die(Tools::jsonEncode($data));
示例3: postProduct
public function postProduct($iId, $type, $id_attribute = 0, $title = '', $overrideCategories = false)
{
$mResult = false;
$product = new Product((int) $iId, true, (int) $this->_configuration['FBWALLPOSTS_LANG_ID']);
if ($product && Validate::isLoadedObject($product)) {
// use case - post in FB now for active product or forced product
if ($product->active || $overrideCategories) {
if (!$overrideCategories) {
if (!$this->productIsInModuleCategories((int) $product->id)) {
return $mResult;
}
}
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$link = Context::getContext()->link;
} else {
$link = new Link();
}
/* Image */
$image = Image::getCover((int) $product->id);
if ($image) {
if ($this->_configuration['FBWALLPOSTS_IMG_SIZE']) {
$image_link = $link->getImageLink($product->link_rewrite, (int) $product->id . '-' . (int) $image['id_image'], $this->_configuration['FBWALLPOSTS_IMG_SIZE']);
} else {
$image_link = $link->getImageLink($product->link_rewrite, (int) $product->id . '-' . (int) $image['id_image']);
}
/* Before version 1.4 */
if (strpos($image_link, 'http://') === FALSE && strpos($image_link, 'https://') === FALSE && version_compare(_PS_VERSION_, '1.4', '<')) {
$image_link = 'http://' . $_SERVER['HTTP_HOST'] . $image_link;
}
} else {
$image_link = false;
}
/* Product URL */
$category = new Category((int) $product->id_category_default, (int) $this->_configuration['FBWALLPOSTS_LANG_ID']);
if (version_compare(_PS_VERSION_, '1.5.5', '>=')) {
$product_url = $link->getProductLink((int) $product->id, null, null, null, (int) $this->_configuration['FBWALLPOSTS_LANG_ID'], null, 0, false);
} elseif (version_compare(_PS_VERSION_, '1.5', '>')) {
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$product_url = $link->getProductLink((int) $product->id, null, null, null, (int) $this->_configuration['FBWALLPOSTS_LANG_ID'], null, 0, true);
} else {
$product_url = $link->getProductLink((int) $product->id, null, null, null, (int) $this->_configuration['FBWALLPOSTS_LANG_ID'], null, 0, false);
}
} else {
$product_url = $link->getProductLink((int) $product->id, $product->link_rewrite, $category->link_rewrite, $product->ean13, (int) $this->_configuration['FBWALLPOSTS_LANG_ID']);
}
/* Product description */
$product_description = strip_tags($product->{$this->_configuration['FBWALLPOSTS_P_DESCR_TYPE']});
if ($type == 'free') {
$mResult = $this->createFBPost($title, $product->name, $product_url, $product_description, $image_link);
} elseif ($type == 'new') {
$mResult = $this->createFBPost($this->_configuration['FBWALLPOSTS_NEW_PROD_TXT'], $product->name, $product_url, $product_description, $image_link);
} elseif ($type == 'stock' && (int) $id_attribute == 0) {
$this->deleteProductFromOOS((int) $product->id, 0);
$mResult = $this->createFBPost($this->_configuration['FBWALLPOSTS_STOCK_PROD_TXT'], $product->name, $product_url, $product_description, $image_link);
} elseif ($type == 'stock' && (int) $id_attribute != 0) {
// Version 1.x to 1.4
if (version_compare(_PS_VERSION_, '1.5', '<')) {
/* Attribute names */
if (Tools::getValue('attribute_combinaison_list') || Tools::getValue('attribute_combination_list')) {
if (Tools::getValue('attribute_combinaison_list')) {
$combo_list = Tools::getValue('attribute_combinaison_list');
} elseif (Tools::getValue('attribute_combination_list')) {
$combo_list = Tools::getValue('attribute_combination_list');
}
$attributes_txt = ' -';
$combo_labels = $this->getProductComboAttributes($combo_list, (int) $this->_configuration['FBWALLPOSTS_LANG_ID']);
if ($combo_labels && is_array($combo_labels) && sizeof($combo_labels)) {
foreach ($combo_labels as $c) {
$attributes_txt .= ' ' . stripslashes($c['name']);
}
}
} else {
$attributes_txt = '';
}
} else {
/* Attribute names */
$attributes_txt = ' -';
$combination = new Combination((int) $id_attribute);
$combo_labels = $combination->getAttributesName((int) $this->_configuration['FBWALLPOSTS_LANG_ID']);
if ($combo_labels && is_array($combo_labels) && sizeof($combo_labels)) {
foreach ($combo_labels as $c) {
$attributes_txt .= ' ' . stripslashes($c['name']);
}
} else {
$attributes_txt = '';
}
}
$this->deleteProductFromOOS((int) $product->id, (int) $id_attribute);
$mResult = $this->createFBPost($this->_configuration['FBWALLPOSTS_STOCK_PROD_TXT'], $product->name . $attributes_txt, $product_url, $product_description, $image_link);
}
}
}
unset($product);
return $mResult;
}