本文整理汇总了PHP中Pack::getPacksTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Pack::getPacksTable方法的具体用法?PHP Pack::getPacksTable怎么用?PHP Pack::getPacksTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pack
的用法示例。
在下文中一共展示了Pack::getPacksTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
// If the product is not active, it's the admin preview mode
if (!$this->product->active) {
$this->context->smarty->assign('adminActionDisplay', true);
}
// Product pictures management
require_once 'images.inc.php';
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} else {
if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
}
}
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
$pictures = array();
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
$text_fields = array();
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons'), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK')));
}
$this->context->smarty->assign('errors', $this->errors);
$this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
}
示例2: foreach
}
}
}
}
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . intval($id_attribute) . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
}
$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getApplicableTax(intval($product->id_tax), 1), 'customizationFields' => $product->getCustomizationFields(intval($cookie->id_lang))));
// Pack management
$smarty->assign('packItems', Pack::getItemTable($product->id, intval($cookie->id_lang), true));
$smarty->assign('packs', Pack::getPacksTable($product->id, intval($cookie->id_lang), true, 1));
}
}
$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')), 'errors' => $errors, 'categories' => Category::getHomeCategories(intval($cookie->id_lang)), 'have_image' => Product::getCover(intval(Tools::getValue('id_product'))), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => intval(Configuration::get('PS_DISPLAY_QTIES')), 'display_ht' => !Tax::excludeTaxeOption()));
if (file_exists(_PS_THEME_DIR_ . 'thickbox.tpl')) {
$smarty->display(_PS_THEME_DIR_ . 'thickbox.tpl');
}
$smarty->assign(array('currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank));
$smarty->display(_PS_THEME_DIR_ . 'product.tpl');
include dirname(__FILE__) . '/footer.php';
示例3: process
//.........这里部分代码省略.........
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . (int) $id_attribute . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
if ((int) Tools::getValue('pp') == 1) {
$time72 = time();
echo 'time72: ' . $time72;
}
//$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc');
/*$categoryProducts = $this->getRandomCatProducts();
self::$smarty->assign('cat_products', $categoryProducts);*/
//$brandProducts = $this->getRandomBrandProducts();
//self::$smarty->assign('brand_products', $brandProducts);
if ((int) Tools::getValue('pp') == 1) {
$time73 = time();
echo ' time73: ' . $time73;
}
self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang)));
if ((int) Tools::getValue('pp') == 1) {
$time74 = time();
echo 'time74: ' . $time74;
}
// Pack management
self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
if ((int) Tools::getValue('pp') == 1) {
print_r('pack done');
}
}
}
if ((int) Tools::getValue('pp') == 1) {
$time8 = time();
echo 'time8: ' . $time8;
}
if ($this->is_saree || $this->is_lehenga) {
if ($this->is_lehenga) {
self::$smarty->assign('is_lehenga', $this->is_lehenga);
}
self::$smarty->assign('as_shown', (bool) $this->product->as_shown);
/*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1))
self::$smarty->assign('measurement_info', $blouse_measurements);
if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2))
self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/
if ((int) Tools::getValue('pp') == 1) {
$time81 = time();
echo 'time81: ' . $time81;
}
if ($this->is_saree) {
//count of all styles mapped to this product
$res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1");
$style_count = (int) $res['style_count'];
if ($style_count === 0) {
// show the default style for sarees
$style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round');
} else {
$res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1");
if (!empty($res)) {
示例4: process
//.........这里部分代码省略.........
$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);
}
/* Attributes / Groups & colors */
$colors = array();
$attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang);
// @todo (RM) should only get groups and not all declination ?
if (is_array($attributesGroups) and $attributesGroups) {
$groups = array();
$combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang);
foreach ($attributesGroups as $k => $row) {
/* Color management */
if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) {
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) {
$colors[$row['id_attribute']]['attributes_quantity'] = 0;
}
$colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity'];
}
if (!isset($groups[$row['id_attribute_group']])) {
$groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1);
}
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) {
$groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
}
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) {
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
}
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
$combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
$combinations[$row['id_product_attribute']]['price'] = (double) $row['price'];
$combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax'];
$combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight'];
$combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity'];
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
$combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
}
//wash attributes list (if some attributes are unavailables and if allowed to wash it)
if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
foreach ($groups as &$group) {
foreach ($group['attributes_quantity'] as $key => &$quantity) {
if (!$quantity) {
unset($group['attributes'][$key]);
}
}
}
foreach ($colors as $key => $color) {
if (!$color['attributes_quantity']) {
unset($colors[$key]);
}
}
}
foreach ($groups as &$group) {
natcasesort($group['attributes']);
}
foreach ($combinations as $id_product_attribute => $comb) {
$attributeList = '';
foreach ($comb['attributes'] as $id_attribute) {
$attributeList .= '\'' . (int) $id_attribute . '\',';
}
$attributeList = rtrim($attributeList, ',');
$combinations[$id_product_attribute]['list'] = $attributeList;
}
self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
}
self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->customizable ? $this->product->getCustomizationFields((int) self::$cookie->id_lang) : false));
// Pack management
self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
}
}
self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => isset($cover) ? (int) $cover['id_image'] : false, 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')));
}
示例5: initContent
//.........这里部分代码省略.........
if (!isset($decoration->areasimp->ItemNumber)) {
$decoration = $decoration->areasimp;
}
foreach ($decoration as $deco) {
$decoration_list .= $deco->TecnicaFull . ', ';
}
$decoration_list = substr($decoration_list, 0, -2);
if ($this->product->quick_quote != '') {
$quote = json_decode($this->product->quick_quote);
//var_dump($this->product->quick_quote);
foreach ($quote->PricesArray->Prices as $price) {
$quote_table .= "<tr><td>" . $price->Piezas;
$precio = explode('.', $price->Precio);
$precio_imp = explode('.', $price->PrecioImp);
if (intval($price->Piezas) < 10) {
$quote_table .= " Muestra";
} else {
$quote_table .= " Piezas";
}
$quote_table .= "</td>";
$quote_table .= "<td>\$" . $precio[0] . "." . substr($precio[1], 0, 2) . "</td>";
$quote_table .= "<td>\$" . $precio_imp[0] . "." . substr($precio_imp[1], 0, 2) . "</td></tr>";
}
}
$link = new Link();
$productUrl = $link->getProductLink($this->product);
$margin = Configuration::get('PROFIT_MARGIN');
$price_type = Configuration::get('PRODUCT_DYNAMIC_PRICE');
if (isset($margin) && $price_type == 1) {
$margin = floatval($margin) / 100;
$margin = 1 - $margin;
$this->product->base_price = $this->product->base_price / $margin;
}
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} else {
if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customizationFields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customizationFields)) {
foreach ($customizationFields as $customizationField) {
if ($this->product->customization_required = $customizationField['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customizationFields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE_CONTENT' => Hook::exec('productFileContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE' => Hook::exec('productFile', array('product' => $this->product)), 'HOOK_CUSTOM_QUOTE' => Hook::exec('displayProductcustomquote', array('product' => $this->product, 'customizationFields' => $customizationFields)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'quote_table_detail' => $quote_table, 'inventory' => $inventory, 'decoration_list' => $decoration_list, 'product_url' => $productUrl, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
}
$this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
}
示例6: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as $customization_field) {
if ($this->product->customization_required = $customization_field['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$accessories = $this->product->getAccessories($this->context->language->id);
if ($this->product->cache_is_pack || count($accessories)) {
$this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
}
if ($this->product->customizable) {
$customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
}
// by webkul
$htl_features = array();
$obj_hotel_room_type = new HotelRoomType();
$room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
$hotel_id = $room_info_by_product_id['id_hotel'];
if (isset($hotel_id) && $hotel_id) {
$obj_hotel_branch = new HotelBranchInformation();
$hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id);
$hotel_policies = $hotel_info_by_id['policies'];
$hotel_name = $hotel_info_by_id['hotel_name'];
$country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']);
$state = State::getNameById($hotel_info_by_id['state_id']);
$hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country;
$obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
foreach ($obj_hotel_feaures_ids as $key => $value) {
$obj_htl_ftr = new HotelFeatures();
$htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
$htl_features[] = $htl_info['name'];
}
}
}
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
//.........这里部分代码省略.........
示例7: initContent
/**
* Assign template vars related to page content.
*
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
$priceDisplay = Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer);
$productPrice = 0;
$productPriceWithoutReduction = 0;
if (!$priceDisplay || $priceDisplay == 2) {
$productPrice = $this->product->getPrice(true, null, 6);
$productPriceWithoutReduction = $this->product->getPriceWithoutReduct(false, null);
} elseif ($priceDisplay == 1) {
$productPrice = $this->product->getPrice(false, null, 6);
$productPriceWithoutReduction = $this->product->getPriceWithoutReduct(true, null);
}
if (Tools::isSubmit('submitCustomizedData')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = $this->trans('An error occurred while deleting the selected picture.', array(), 'Shop.Notifications.Error');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as &$customization_field) {
if ($customization_field['type'] == 0) {
$customization_field['key'] = 'pictures_' . $this->product->id . '_' . $customization_field['id_customization_field'];
} elseif ($customization_field['type'] == 1) {
$customization_field['key'] = 'textFields_' . $this->product->id . '_' . $customization_field['id_customization_field'];
}
}
unset($customization_field);
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$assembler = new ProductAssembler($this->context);
$presenter = new ProductListingPresenter(new ImageRetriever($this->context->link), $this->context->link, new PriceFormatter(), new ProductColorsRetriever(), $this->getTranslator());
$presentationSettings = $this->getProductPresentationSettings();
$presentedPackItems = array();
foreach ($pack_items as $item) {
$presentedPackItems[] = $presenter->present($this->getProductPresentationSettings(), $assembler->assembleProduct($item), $this->context->language);
}
$this->context->smarty->assign('packItems', $presentedPackItems);
$this->context->smarty->assign('noPackPrice', $this->product->getNoPackPrice());
$this->context->smarty->assign('displayPackPrice', $pack_items && $productPrice < $this->product->getNoPackPrice() ? true : false);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
$accessories = $this->product->getAccessories($this->context->language->id);
if (is_array($accessories)) {
foreach ($accessories as &$accessory) {
$accessory = $presenter->present($presentationSettings, Product::getProductProperties($this->context->language->id, $accessory, $this->context), $this->context->language);
}
unset($accessory);
}
if ($this->product->customizable) {
$customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
}
$product_for_template = $this->getTemplateVarProduct();
$this->context->smarty->assign(array('priceDisplay' => $priceDisplay, 'productPriceWithoutReduction' => $productPriceWithoutReduction, 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'product' => $product_for_template, 'displayUnitPrice' => !empty($this->product->unity) && $this->product->unit_price_ratio > 0.0 ? true : false, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id)));
// Assign attribute groups to the template
$this->assignAttributesGroups($product_for_template);
}
}
示例8: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$flag_pack = true;
if (!$this->errors) {
// if(!isset($_GET['quick_view']))
// if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
// if (Pack::isPack((int)$this->product->id))
// $this->product->quantity = 0;
// else
// $flag_pack = false;
// else
// $flag_pack = false;
if (!Pack::isPack((int) $this->product->id)) {
$flag_pack = false;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} else {
if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
$this->assign3dImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
if (is_array($pack_items) && count($pack_items)) {
foreach ($pack_items as &$pack_item) {
$pack_item['features'] = Product::getFrontFeaturesStatic($this->context->language->id, $pack_item['id_product']);
}
}
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
//reviews
// $average = ProductComment::getAverageGrade((int)Tools::getValue('id_product'));
$nbComments = (int) ProductComment::getCommentNumber((int) Tools::getValue('id_product'));
$act_pack = 0;
//паки
if (!$flag_pack) {
$sql = "SELECT DISTINCT(id_product_pack) FROM " . _DB_PREFIX_ . "pack WHERE id_product_item={$this->product->id}";
$pack_products = array();
$result_packs = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (is_array($result_packs) && count($result_packs)) {
foreach ($result_packs as $k => $id_product_pack) {
$prod = new Product($id_product_pack['id_product_pack'], $this->context->language->id, true);
$cover = $prod->getCover((int) $prod->id);
if ($cover) {
$pack_products[$k]['id_image'] = $cover['id_image'];
} else {
$pack_products[$k]['id_image'] = null;
}
$price = $prod->getPrice(true, null, 2);
$price_old = $prod->getPriceWithoutReduct(false, null, 2);
if (isset($prod->specificPrice) && is_array($prod->specificPrice)) {
$pack_products[$k]['sale_percentage'] = $prod->specificPrice['reduction_type'] == 'percentage' ? $prod->specificPrice['reduction'] * 100 : $prod->specificPrice['reduction'] / $price_old * 100;
}
//.........这里部分代码省略.........
示例9: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!$this->errors) {
if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
$this->product->quantity = 0;
}
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas')) {
// If cart has not been saved, we need to do it so that customization fields can have an id_cart
// We check that the cookie exists first to avoid ghost carts
if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
$this->context->cart->add();
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
$this->pictureUpload();
$this->textRecord();
$this->formTargetFormat();
} elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
}
$pictures = array();
$text_fields = array();
if ($this->product->customizable) {
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
foreach ($files as $file) {
$pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
}
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
foreach ($texts as $text_field) {
$text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
}
}
$this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
$this->product->customization_required = false;
$customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
if (is_array($customization_fields)) {
foreach ($customization_fields as $customization_field) {
if ($this->product->customization_required = $customization_field['required']) {
break;
}
}
}
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
// Assign attributes combinations to the template
$this->assignAttributesCombinations();
// Pack management
$pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
$this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
if (isset($this->category->id) && $this->category->id) {
$return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
} else {
$return_link = 'javascript: history.back();';
}
$category_id = $this->category->id;
if ($category_id === 13) {
$foundations = array();
$foundations_ids = array(28, 29, 30, 31);
foreach ($foundations_ids as $id) {
$product = new Product($id, true, $this->context->language->id);
$cover = $product->getCover($id);
$foundations[$id]['img_src'] = $this->context->link->getImageLink($product->link_rewrite, $cover['id_image'], 'large_default');
$foundations[$id]['name'] = $product->name;
$foundations[$id]['href'] = $this->context->link->getProductLink($product->id);
$combListArr = $product->getAttributeCombinations($this->context->language->id);
$foundations[$id]['combs'] = $combListArr;
$foundations[$id]['price'] = $product->price;
}
// echo '<pre>'.print_r($foundations,true).'</pre>';
$this->context->smarty->assign(array('foundations' => $foundations));
// echo '<pre>'.print_r(get_class_methods($product),true).'</pre>';
unset($product);
}
$this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')));
}
$this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
}