本文整理汇总了PHP中Product::hasAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::hasAttributes方法的具体用法?PHP Product::hasAttributes怎么用?PHP Product::hasAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::hasAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewsupplier
public function viewsupplier()
{
global $cookie;
$supplier = $this->loadObject();
echo '<h2>' . $supplier->name . '</h2>';
$products = $supplier->getProductsLite(intval($cookie->id_lang));
echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>';
foreach ($products as $product) {
$product = new Product($product['id_product'], false, intval($cookie->id_lang));
echo '<hr />';
if (!$product->hasAttributes()) {
echo '
<table border="0" cellpadding="0" cellspacing="0" class="table width3">
<tr>
<th><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></th>
' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . '
' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . '
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . '
</tr>
</table>';
} else {
echo '
<h3><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></h3>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
<tr>
<th>' . $this->l('Attribute name') . '</th>
<th width="80">' . $this->l('Reference') . '</th>
<th width="80">' . $this->l('EAN13') . '</th>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . '
</tr>';
/* Build attributes combinaisons */
$combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang));
foreach ($combinaisons as $k => $combinaison) {
$combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
$combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
$combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
$combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
}
$irow = 0;
foreach ($combArray as $id_product_attribute => $product_attribute) {
$list = '';
foreach ($product_attribute['attributes'] as $attribute) {
$list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
}
$list = rtrim($list, ', ');
echo '
<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' >
<td>' . stripslashes($list) . '</td>
<td>' . $product_attribute['reference'] . '</td>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td>' : '') . '
<td class="right">' . $product_attribute['quantity'] . '</td>
</tr>';
}
unset($combArray);
echo '</table>';
echo '</td></tr></table>';
}
}
}
示例2: unset
if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
$id_product_old = $product->id;
for ($i = 1; $i <= $quantity; $i++) {
echo $i;
unset($product->id);
unset($product->id_product);
$product->indexed = 0;
$product->active = 0;
if (!$product->add()) {
echo "Parent_F:" . $product->id . " ";
}
if (!Category::duplicateProductCategories($id_product_old, $product->id)) {
echo "Cat_F:" . $product->id . " ";
}
if (($combinationImages = Product::duplicateAttributes($id_product_old, $product->id)) !== false and GroupReduction::duplicateReduction($id_product_old, $product->id) and Product::duplicateAccessories($id_product_old, $product->id) and Product::duplicateFeatures($id_product_old, $product->id) and Product::duplicateSpecificPrices($id_product_old, $product->id) and Pack::duplicate($id_product_old, $product->id) and Product::duplicateCustomizationFields($id_product_old, $product->id) and Product::duplicateTags($id_product_old, $product->id) and Product::duplicateDownload($id_product_old, $product->id)) {
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
}
if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combinationImages)) {
echo 'An error occurred while copying images.';
} else {
echo ' done. ';
}
} else {
echo 'An error occurred while duplicating some object properties.';
}
}
}
}
if ($Version >= 15000) {
$type = Tools::getValue('context_type');
示例3: initFormQuantities
/**
* @param Product $obj
* @throws Exception
* @throws SmartyException
*/
public function initFormQuantities($obj)
{
if (!$this->default_form_language) {
$this->getLanguages();
}
$data = $this->createTemplate($this->tpl_form);
$data->assign('default_form_language', $this->default_form_language);
if ($obj->id) {
if ($this->product_exists_in_shop) {
// Get all id_product_attribute
$attributes = $obj->getAttributesResume($this->context->language->id);
if (empty($attributes)) {
$attributes[] = array('id_product_attribute' => 0, 'attribute_designation' => '');
}
// Get available quantities
$available_quantity = array();
$product_designation = array();
foreach ($attributes as $attribute) {
// Get available quantity for the current product attribute in the current shop
$available_quantity[$attribute['id_product_attribute']] = isset($attribute['id_product_attribute']) && $attribute['id_product_attribute'] ? (int) $attribute['quantity'] : (int) $obj->quantity;
// Get all product designation
$product_designation[$attribute['id_product_attribute']] = rtrim($obj->name[$this->context->language->id] . ' - ' . $attribute['attribute_designation'], ' - ');
}
$show_quantities = true;
$shop_context = Shop::getContext();
$shop_group = new ShopGroup((int) Shop::getContextShopGroupID());
// if we are in all shops context, it's not possible to manage quantities at this level
if (Shop::isFeatureActive() && $shop_context == Shop::CONTEXT_ALL) {
$show_quantities = false;
} elseif (Shop::isFeatureActive() && $shop_context == Shop::CONTEXT_GROUP) {
// if quantities are not shared between shops of the group, it's not possible to manage them at group level
if (!$shop_group->share_stock) {
$show_quantities = false;
}
} else {
// if quantities are shared between shops of the group, it's not possible to manage them for a given shop
if ($shop_group->share_stock) {
$show_quantities = false;
}
}
$data->assign('ps_stock_management', Configuration::get('PS_STOCK_MANAGEMENT'));
$data->assign('has_attribute', $obj->hasAttributes());
// Check if product has combination, to display the available date only for the product or for each combination
if (Combination::isFeatureActive()) {
$data->assign('countAttributes', (int) Db::getInstance()->getValue('SELECT COUNT(id_product) FROM ' . _DB_PREFIX_ . 'product_attribute WHERE id_product = ' . (int) $obj->id));
} else {
$data->assign('countAttributes', false);
}
// if advanced stock management is active, checks associations
$advanced_stock_management_warning = false;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $obj->advanced_stock_management) {
$p_attributes = Product::getProductAttributesIds($obj->id);
$warehouses = array();
if (!$p_attributes) {
$warehouses[] = Warehouse::getProductWarehouseList($obj->id, 0);
}
foreach ($p_attributes as $p_attribute) {
$ws = Warehouse::getProductWarehouseList($obj->id, $p_attribute['id_product_attribute']);
if ($ws) {
$warehouses[] = $ws;
}
}
$warehouses = Tools::arrayUnique($warehouses);
if (empty($warehouses)) {
$advanced_stock_management_warning = true;
}
}
if ($advanced_stock_management_warning) {
$this->displayWarning($this->l('If you wish to use the advanced stock management, you must:'));
$this->displayWarning('- ' . $this->l('associate your products with warehouses.'));
$this->displayWarning('- ' . $this->l('associate your warehouses with carriers.'));
$this->displayWarning('- ' . $this->l('associate your warehouses with the appropriate shops.'));
}
$pack_quantity = null;
// if product is a pack
if (Pack::isPack($obj->id)) {
$items = Pack::getItems((int) $obj->id, Configuration::get('PS_LANG_DEFAULT'));
// gets an array of quantities (quantity for the product / quantity in pack)
$pack_quantities = array();
foreach ($items as $item) {
/** @var Product $item */
if (!$item->isAvailableWhenOutOfStock((int) $item->out_of_stock)) {
$pack_id_product_attribute = Product::getDefaultAttribute($item->id, 1);
$pack_quantities[] = Product::getQuantity($item->id, $pack_id_product_attribute) / ($item->pack_quantity !== 0 ? $item->pack_quantity : 1);
}
}
// gets the minimum
if (count($pack_quantities)) {
$pack_quantity = $pack_quantities[0];
foreach ($pack_quantities as $value) {
if ($pack_quantity > $value) {
$pack_quantity = $value;
}
}
}
//.........这里部分代码省略.........
示例4: ajaxProcessDeleteProductAttribute
public function ajaxProcessDeleteProductAttribute()
{
if (!Combination::isFeatureActive()) {
return;
}
if ($this->tabAccess['delete'] === '1') {
$id_product = (int) Tools::getValue('id_product');
$id_product_attribute = (int) Tools::getValue('id_product_attribute');
if ($id_product && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product))) {
if (($depends_on_stock = StockAvailable::dependsOnStock($id_product)) && StockAvailable::getQuantityAvailableByProduct($id_product, $id_product_attribute)) {
$json = array('status' => 'error', 'message' => $this->l('It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.'));
} else {
$product->deleteAttributeCombination((int) $id_product_attribute);
$product->checkDefaultAttributes();
Tools::clearColorListCache((int) $product->id);
if (!$product->hasAttributes()) {
$product->cache_default_attribute = 0;
$product->update();
} else {
Product::updateDefaultAttribute($id_product);
}
if ($depends_on_stock && !Stock::deleteStockByIds($id_product, $id_product_attribute)) {
$json = array('status' => 'error', 'message' => $this->l('Error while deleting the stock'));
} else {
$json = array('status' => 'ok', 'message' => $this->_conf[1], 'id_product_attribute' => (int) $id_product_attribute);
}
}
} else {
$json = array('status' => 'error', 'message' => $this->l('You cannot delete this attribute.'));
}
} else {
$json = array('status' => 'error', 'message' => $this->l('You do not have permission to delete this.'));
}
die(json_encode($json));
}
示例5: viewmanufacturer
public function viewmanufacturer()
{
global $cookie;
$manufacturer = $this->loadObject();
echo '<h2>' . $manufacturer->name . '</h2>';
$products = $manufacturer->getProductsLite(intval($cookie->id_lang));
$addresses = $manufacturer->getAddresses(intval($cookie->id_lang));
echo '<h3>' . $this->l('Total addresses:') . ' ' . sizeof($addresses) . '</h3>';
echo '<hr />';
foreach ($addresses as $addresse) {
echo '
<h3></h3>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
<tr>
<th><b>' . $addresse['firstname'] . ' ' . $addresse['lastname'] . '</b></th>
</tr>
<tr>
<td>
<div style="padding:5px; float:left; width:350px;">
' . $addresse['address1'] . '<br />
' . ($addresse['address2'] ? $addresse['address2'] . '<br />' : '') . '
' . $addresse['postcode'] . ' ' . $addresse['city'] . '<br />
' . ($addresse['state'] ? $addresse['state'] . '<br />' : '') . '
<b>' . $addresse['country'] . '</b><br />
</div>
<div style="padding:5px; float:left;">
' . ($addresse['phone'] ? $addresse['phone'] . '<br />' : '') . '
' . ($addresse['phone_mobile'] ? $addresse['phone_mobile'] . '<br />' : '') . '
</div>
' . ($addresse['other'] ? '<div style="padding:5px; clear:both;"><br /><i>' . $addresse['other'] . '</i></div>' : '') . '
</td>
</tr>
</table>';
}
if (!sizeof($addresses)) {
echo 'No address for this manufacturer.';
}
echo '<br /><br />';
echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>';
foreach ($products as $product) {
$product = new Product($product['id_product'], false, intval($cookie->id_lang));
echo '<hr />';
if (!$product->hasAttributes()) {
echo '
<table border="0" cellpadding="0" cellspacing="0" class="table width3">
<tr>
<th>' . $product->name . '</th>
' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . '
' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . '
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . '
</tr>
</table>';
} else {
echo '
<h3>' . $product->name . '</h3>
<table>
<tr>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
<tr>
<th>' . $this->l('Attribute name') . '</th>
<th width="80">' . $this->l('Reference') . '</th>
<th width="80">' . $this->l('EAN13') . '</th>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . '
</tr>';
/* Build attributes combinaisons */
$combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang));
foreach ($combinaisons as $k => $combinaison) {
$combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
$combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
$combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
$combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
}
$irow = 0;
foreach ($combArray as $id_product_attribute => $product_attribute) {
$list = '';
foreach ($product_attribute['attributes'] as $attribute) {
$list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
}
$list = rtrim($list, ', ');
echo '
<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' >
<td>' . stripslashes($list) . '</td>
<td>' . $product_attribute['reference'] . '</td>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td>' : '') . '
<td class="right">' . $product_attribute['quantity'] . '</td>
</tr>';
}
unset($combArray);
echo '</table>';
}
}
}
示例6: hookAdminStatsModules
public function hookAdminStatsModules($params)
{
global $cookie, $currentIndex;
$id_category = intval(Tools::getValue('id_category'));
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
if ($id_product = intval(Tools::getValue('id_product'))) {
$product = new Product($id_product, false, intval($cookie->id_lang));
$totalBought = $this->getTotalBought($product->id);
$totalViewed = $this->getTotalViewed($product->id);
$this->_html .= '<h3>' . $product->name . ' - ' . $this->l('Details') . '</h3>
<p>' . $this->l('Conversion rate:') . ' ' . number_format($totalViewed ? $totalBought / $totalViewed : 0, 2) . '</p>
<p>' . $this->l('Total bought:') . ' ' . $totalBought . '</p>
<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '1-' . $id_product)) . '</center>
<p>' . $this->l('Total viewed:') . ' ' . $totalViewed . '</p>
<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '2-' . $id_product)) . '</center>';
if ($hasAttribute = $product->hasAttributes() and $totalBought) {
$this->_html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center>';
}
if ($totalBought) {
$sales = $this->getSales($id_product, $cookie->id_lang);
$this->_html .= '<br class="clear" />
<h3>' . $this->l('Sales') . '</h3>
<div style="overflow-y: scroll; height: 600px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
<tr>
<th>' . $this->l('Date') . '</th>
<th>' . $this->l('Order') . '</th>
' . ($hasAttribute ? '<th>' . $this->l('Attribute') . '</th>' : '') . '
<th>' . $this->l('Qty') . '</th>
<th>' . $this->l('Price') . '</th>
<th>' . $this->l('Tax') . '</th>
</tr>
</thead><tbody>';
foreach ($sales as $sale) {
$this->_html .= '
<tr>
<td>' . Tools::displayDate($sale['date_add'], intval($cookie->id_lang), false) . '</td>
<td>' . intval($sale['id_order']) . '</td>
' . ($hasAttribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
<td>' . intval($sale['product_quantity']) . '</td>
<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
<td>' . $sale['tax_name'] . '</td>
</tr>';
}
$this->_html .= '</tbody></table></div>';
}
} else {
$categories = Category::getCategories(intval($cookie->id_lang), true, false);
$this->_html .= '
<label>' . $this->l('Choose a category') . '</label>
<div class="margin-form">
<form action="" method="post" id="categoriesForm">
<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
<option value="0">' . $this->l('All') . '</option>';
foreach ($categories as $category) {
$this->_html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
}
$this->_html .= '
</select>
</form>
</div>
<div class="clear space"></div>
' . $this->l('Click on a product to access its statistics.') . '
<div class="clear space"></div>
<h2>' . $this->l('Products available') . '</h2>
<div style="overflow-y: scroll; height: 600px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
<tr>
<th>' . $this->l('Ref.') . '</th>
<th>' . $this->l('Name') . '</th>
<th>' . $this->l('Stock') . '</th>
</tr>
</thead><tbody>';
foreach ($this->getProducts($cookie->id_lang) as $product) {
$this->_html .= '<tr><td>' . $product['reference'] . '</td><td><a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&module=' . $this->name . '&id_product=' . $product['id_product'] . '">' . $product['name'] . '</a></td><td>' . $product['quantity'] . '</td></tr>';
}
$this->_html .= '</tbody></table></div>';
}
$this->_html .= '</fieldset><br />
<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
<h2>' . $this->l('Number of purchases compared to number of viewings') . '</h2>
<p>
' . $this->l('After choosing a category and selecting a product available in this category, some graphs appear. Then, you can analyze them.') . '
<ul>
<li class="bullet">' . $this->l('If you notice that a product is successful, very purchased, but also little viewed: you should put it more prominently on your webshop front-office.') . '</li>
<li class="bullet">' . $this->l('On the other hand, if a product knows a lot of viewings but is not really purchased: we advise you to check or modify this product\'s information, description and photography again.') . '
</li>
</ul>
</p>
</fieldset>';
return $this->_html;
}
示例7: hookAdminStatsModules
public function hookAdminStatsModules()
{
$id_category = (int) Tools::getValue('id_category');
$currency = Context::getContext()->currency;
if (Tools::getValue('export')) {
if (!Tools::getValue('exportType')) {
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
}
}
$this->html = '
<div class="panel-heading">
' . $this->displayName . '
</div>
<h4>' . $this->l('Guide') . '</h4>
<div class="alert alert-warning">
<h4>' . $this->l('Number of purchases compared to number of views') . '</h4>
<p>
' . $this->l('After choosing a category and selecting a product, informational graphs will appear.') . '
<ul>
<li class="bullet">' . $this->l('If you notice that a product is often purchased but viewed infrequently, you should display it more prominently in your Front Office.') . '</li>
<li class="bullet">' . $this->l('On the other hand, if a product has many views but is not often purchased, we advise you to check or modify this product\'s information, description and photography again, see if you can find something better.') . '
</li>
</ul>
</p>
</div>';
if ($id_product = (int) Tools::getValue('id_product')) {
if (Tools::getValue('export')) {
if (Tools::getValue('exportType') == 1) {
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product));
} elseif (Tools::getValue('exportType') == 2) {
$this->csvExport(array('type' => 'pie', 'option' => '3-' . $id_product));
}
}
$product = new Product($id_product, false, $this->context->language->id);
$total_bought = $this->getTotalBought($product->id);
$total_sales = $this->getTotalSales($product->id);
$total_viewed = $this->getTotalViewed($product->id);
$this->html .= '<h4>' . $product->name . ' - ' . $this->l('Details') . '</h4>
<div class="row row-margin-bottom">
<div class="col-lg-12">
<div class="col-lg-8">
' . $this->engine(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product)) . '
</div>
<div class="col-lg-4">
<ul class="list-unstyled">
<li>' . $this->l('Total bought') . ' ' . $total_bought . '</li>
<li>' . $this->l('Sales (tax excluded)') . ' ' . Tools::displayprice($total_sales, $currency) . '</li>
<li>' . $this->l('Total viewed') . ' ' . $total_viewed . '</li>
<li>' . $this->l('Conversion rate') . ' ' . number_format($total_viewed ? $total_bought / $total_viewed : 0, 2) . '</li>
</ul>
<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=1">
<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
</a>
</div>
</div>
</div>';
if ($has_attribute = $product->hasAttributes() && $total_bought) {
$this->html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . $this->engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center><br />
<a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a>';
}
if ($total_bought) {
$sales = $this->getSales($id_product);
$this->html .= '
<h4>' . $this->l('Sales') . '</h4>
<div style="overflow-y: scroll; height: ' . min(400, (count($sales) + 1) * 32) . 'px;">
<table class="table">
<thead>
<tr>
<th>
<span class="title_box active">' . $this->l('Date') . '</span>
</th>
<th>
<span class="title_box active">' . $this->l('Order') . '</span>
</th>
<th>
<span class="title_box active">' . $this->l('Customer') . '</span>
</th>
' . ($has_attribute ? '<th><span class="title_box active">' . $this->l('Attribute') . '</span></th>' : '') . '
<th>
<span class="title_box active">' . $this->l('Quantity') . '</span>
</th>
<th>
<span class="title_box active">' . $this->l('Price') . '</span>
</th>
</tr>
</thead>
<tbody>';
$token_order = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id);
$token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
foreach ($sales as $sale) {
$this->html .= '
<tr>
<td>' . Tools::displayDate($sale['date_add'], null, false) . '</td>
<td align="center"><a href="?tab=AdminOrders&id_order=' . $sale['id_order'] . '&vieworder&token=' . $token_order . '">' . (int) $sale['id_order'] . '</a></td>
<td align="center"><a href="?tab=AdminCustomers&id_customer=' . $sale['id_customer'] . '&viewcustomer&token=' . $token_customer . '">' . (int) $sale['id_customer'] . '</a></td>
' . ($has_attribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
<td>' . (int) $sale['product_quantity'] . '</td>
<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
</tr>';
}
//.........这里部分代码省略.........
示例8: processDuplicate
public function processDuplicate()
{
if (!Module::isInstalled('agilemultipleseller')) {
parent::processDuplicate();
} else {
if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
$id_product_old = $product->id;
if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) {
$shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID());
foreach ($shops as $shop) {
if ($product->isAssociatedToShop($shop['id_shop'])) {
$product_price = new Product($id_product_old, false, null, $shop['id_shop']);
$product->price = $product_price->price;
}
}
}
unset($product->id);
unset($product->id_product);
$product->indexed = 0;
$product->active = 0;
if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) {
if ($product->hasAttributes()) {
Product::updateDefaultAttribute($product->id);
}
AgileSellerManager::assignObjectOwner('product', $product->id, AgileSellerManager::getObjectOwnerID('product', $id_product_old));
if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
$this->errors[] = Tools::displayError('An error occurred while copying images.');
} else {
Hook::exec('actionProductAdd', array('product' => $product));
if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
Search::indexation(false, $product->id);
}
$this->redirect_after = self::$currentIndex . (Tools::getIsset('id_category') ? '&id_category=' . (int) Tools::getValue('id_category') : '') . '&conf=19&token=' . $this->token;
}
} else {
$this->errors[] = Tools::displayError('An error occurred while creating an object.');
}
}
}
}
示例9: hookActionUpdateQuantity
public function hookActionUpdateQuantity($params)
{
$id_product = (int) $params['id_product'];
$id_product_attribute = (int) $params['id_product_attribute'];
$quantity = (int) $params['quantity'];
$context = Context::getContext();
$id_shop = (int) $context->shop->id;
$id_lang = (int) $context->language->id;
$product = new Product($id_product, false, $id_lang, $id_shop, $context);
$product_has_attributes = $product->hasAttributes();
$configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), null, null, $id_shop);
$ma_last_qties = (int) $configuration['MA_LAST_QTIES'];
$check_oos = $product_has_attributes && $id_product_attribute || !$product_has_attributes && !$id_product_attribute;
if ($check_oos && $product->active == 1 && (int) $quantity <= $ma_last_qties && !(!$this->merchant_oos || empty($this->merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) {
$iso = Language::getIsoById($id_lang);
$product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);
$template_vars = array('{qty}' => $quantity, '{last_qty}' => $ma_last_qties, '{product}' => $product_name);
// Do not send mail if multiples product are created / imported.
if (!defined('PS_MASS_PRODUCT_CREATION') && file_exists(dirname(__FILE__) . '/mails/' . $iso . '/productoutofstock.txt') && file_exists(dirname(__FILE__) . '/mails/' . $iso . '/productoutofstock.html')) {
// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails);
foreach ($merchant_mails as $merchant_mail) {
Mail::Send($id_lang, 'productoutofstock', Mail::l('Product out of stock', $id_lang), $template_vars, $merchant_mail, null, (string) $configuration['PS_SHOP_EMAIL'], (string) $configuration['PS_SHOP_NAME'], null, null, dirname(__FILE__) . '/mails/', false, $id_shop);
}
}
}
if ($this->customer_qty && $quantity > 0) {
MailAlert::sendCustomerAlert((int) $product->id, (int) $params['id_product_attribute']);
}
}
示例10: intval
$qty = intval(abs(Tools::getValue('qty', 1)));
if ($qty == 0) {
$errors[] = Tools::displayError('null quantity');
} elseif (!$idProduct) {
$errors[] = Tools::displayError('product not found');
} else {
$producToAdd = new Product(intval($idProduct), false, intval($cookie->id_lang));
if ((!$producToAdd->id or !$producToAdd->active) and !$delete) {
$errors[] = Tools::displayError('product is no longer available');
} else {
/* Check the quantity availability */
if ($idProductAttribute and is_numeric($idProductAttribute)) {
if (!$delete and !$producToAdd->isAvailableWhenOutOfStock($producToAdd->out_of_stock) and !Attribute::checkAttributeQty(intval($idProductAttribute), intval($qty))) {
$errors[] = Tools::displayError('product is no longer available');
}
} elseif ($producToAdd->hasAttributes() and !$delete) {
$idProductAttribute = Product::getDefaultAttribute(intval($producToAdd->id), intval($producToAdd->out_of_stock) == 2 ? !intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')) : !intval($producToAdd->out_of_stock));
if (!$idProductAttribute) {
Tools::redirectAdmin($link->getProductLink($producToAdd));
} elseif (!$delete and !$producToAdd->isAvailableWhenOutOfStock($producToAdd->out_of_stock) and !Attribute::checkAttributeQty(intval($idProductAttribute), intval($qty))) {
$errors[] = Tools::displayError('product is no longer available');
}
} elseif (!$delete and !$producToAdd->checkQty(intval($qty))) {
$errors[] = Tools::displayError('product is no longer available');
}
/* Check vouchers compatibility */
if ($add and (intval($producToAdd->reduction_price) or intval($producToAdd->reduction_percent) or $producToAdd->on_sale)) {
$discounts = $cart->getDiscounts();
foreach ($discounts as $discount) {
if (!$discount['cumulable_reduction']) {
$errors[] = Tools::displayError('cannot add this product because current voucher doesn\'t allow additional discounts');
示例11: viewmanufacturer
public function viewmanufacturer()
{
global $cookie;
if (!($manufacturer = $this->loadObject())) {
return;
}
echo '<h2>' . $manufacturer->name . '</h2>';
$products = $manufacturer->getProductsLite((int) $cookie->id_lang);
$addresses = $manufacturer->getAddresses((int) $cookie->id_lang);
echo '<h3>' . $this->l('Total addresses:') . ' ' . sizeof($addresses) . '</h3>';
echo '<hr />';
foreach ($addresses as $addresse) {
echo '
<h3></h3>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
<tr>
<th><b>' . $addresse['firstname'] . ' ' . $addresse['lastname'] . '</b></th>
</tr>
<tr>
<td>
<div style="padding:5px; float:left; width:350px;">
' . $addresse['address1'] . '<br />
' . ($addresse['address2'] ? $addresse['address2'] . '<br />' : '') . '
' . $addresse['postcode'] . ' ' . $addresse['city'] . '<br />
' . ($addresse['state'] ? $addresse['state'] . '<br />' : '') . '
<b>' . $addresse['country'] . '</b><br />
</div>
<div style="padding:5px; float:left;">
' . ($addresse['phone'] ? $addresse['phone'] . '<br />' : '') . '
' . ($addresse['phone_mobile'] ? $addresse['phone_mobile'] . '<br />' : '') . '
</div>
' . ($addresse['other'] ? '<div style="padding:5px; clear:both;"><br /><i>' . $addresse['other'] . '</i></div>' : '') . '
</td>
</tr>
</table>';
}
if (!sizeof($addresses)) {
echo 'No address for this manufacturer.';
}
echo '<br /><br />';
echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>';
foreach ($products as $product) {
$product = new Product($product['id_product'], false, (int) $cookie->id_lang);
echo '<hr />';
if (!$product->hasAttributes()) {
echo '
<div style="float:right;">
<a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button">' . $this->l('Edit') . '</a>
<a href="?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button" onclick="return confirm(\'' . $this->l('Delete item #', __CLASS__, TRUE) . $product->id . ' ?\');">' . $this->l('Delete') . '</a>
</div>
<table border="0" cellpadding="0" cellspacing="0" class="table width3">
<tr>
<th>' . $product->name . '</th>
' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . '
' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . '
' . (!empty($product->upc) ? '<th width="120">' . $this->l('UPC:') . ' ' . $product->upc . '</th>' : '') . '
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . '
</tr>
</table>';
} else {
echo '
<div style="float:right;">
<a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button">' . $this->l('Edit') . '</a>
<a href="?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" class="button" onclick="return confirm(\'' . $this->l('Delete item #', __CLASS__, TRUE) . $product->id . ' ?\');">' . $this->l('Delete') . '</a>
</div>
<h3><a href="?tab=AdminCatalog&id_product=' . $product->id . '&updateproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">' . $product->name . '</a></h3>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
<tr>
<th>' . $this->l('Attribute name') . '</th>
<th width="80">' . $this->l('Reference') . '</th>
<th width="80">' . $this->l('EAN13') . '</th>
<th width="80">' . $this->l('UPC') . '</th>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . '
</tr>';
/* Build attributes combinaisons */
$combinaisons = $product->getAttributeCombinaisons((int) $cookie->id_lang);
foreach ($combinaisons as $k => $combinaison) {
$combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
$combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
$combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc'];
$combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
$combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
}
$irow = 0;
foreach ($combArray as $id_product_attribute => $product_attribute) {
$list = '';
foreach ($product_attribute['attributes'] as $attribute) {
$list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
}
$list = rtrim($list, ', ');
echo '
<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' >
<td>' . stripslashes($list) . '</td>
<td>' . $product_attribute['reference'] . '</td>
' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td><td>' . $product_attribute['upc'] . '</td>' : '') . '
<td class="right">' . $product_attribute['quantity'] . '</td>
</tr>';
}
unset($combArray);
echo '</table>';
//.........这里部分代码省略.........
示例12: PAYPAL_ProductList
//.........这里部分代码省略.........
$static = true;
$voted = 0;
}
$rating_box = RATING_ratingBar('paypal', $A['id'], $P->votes, $P->rating, $voted, 5, $static, 'sm');
$product->set_var('rating_bar', $rating_box);
} else {
$product->set_var('rating_bar', '');
}
$product->set_var(array('id' => $A['id'], 'name' => $P->name, 'short_description' => PLG_replacetags($P->short_description), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'encrypted' => '', 'item_url' => COM_buildURL(PAYPAL_URL . '/detail.php?id=' . $A['id']), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'track_onhand' => $P->track_onhand ? 'true' : '', 'qty_onhand' => $P->onhand));
if ($P->price > 0) {
//$product->set_var('price', COM_numberFormat($P->price, 2));
$product->set_var('price', $P->currency->Format($P->price));
} else {
$product->clear_var('price');
}
if ($isAdmin) {
$product->set_var('is_admin', 'true');
$product->set_var('pi_admin_url', PAYPAL_ADMIN_URL);
$product->set_var('edit_icon', "{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}");
}
$pic_filename = DB_getItem($_TABLES['paypal.images'], 'filename', "product_id = '{$A['id']}'");
if ($pic_filename) {
$product->set_var('small_pic', PAYPAL_ImageUrl($pic_filename));
} else {
$product->set_var('small_pic', '');
}
// FIXME: If a user purchased once with no expiration, this query
// will not operate correctly
/*$time = DB_getItem($_TABLES['paypal.purchases'],
'MAX(UNIX_TIMESTAMP(expiration))',
"user_id = {$_USER['uid']} AND product_id ='{$A['id']}'");
*/
$product->set_block('product', 'BtnBlock', 'Btn');
if (!$P->hasAttributes()) {
// Buttons only show in the list if there are no options to select
$buttons = $P->PurchaseLinks();
foreach ($buttons as $name => $html) {
$product->set_var('button', $html);
$product->parse('Btn', 'BtnBlock', true);
}
} else {
if ($_PP_CONF['ena_cart']) {
// If the product has attributes, then the cart must be
// enabled to allow purchasing
$button = $product->parse('', 'btn_details') . ' ';
$product->set_var('button', $button);
$product->parse('Btn', 'BtnBlock', true);
}
}
$display .= $product->parse('', 'product');
$product->clear_var('Btn');
}
// Get products from plugins.
// For now, this hack shows plugins only on the first page, since
// they're not included in the page calculation.
if ($page == 1 && empty($cat_list)) {
// Get the currency class for formatting prices
USES_paypal_class_currency();
$Cur = new ppCurrency($_PP_CONF['currency']);
$product->clear_var('rating_bar');
// no ratings for plugins (yet)
foreach ($_PLUGINS as $pi_name) {
$status = LGLIB_invokeService($pi_name, 'getproducts', array(), $plugin_data, $svc_msg);
if ($status != PLG_RET_OK || empty($plugin_data)) {
continue;
}
示例13: checkStock
/**
* @param ShopgateCart $cart
* @return array
*/
public function checkStock(ShopgateCart $cart)
{
$result = array();
foreach ($cart->getItems() as $item) {
$cartItem = new ShopgateCartItem();
$cartItem->setItemNumber($item->getItemNumber());
list($productId, $attributeId) = ShopgateHelper::getProductIdentifiers($item);
/** @var ProductCore $product */
if (version_compare(_PS_VERSION_, '1.5.2.0', '<')) {
$product = new BWProduct($productId, true, $this->getPlugin()->getLanguageId());
} else {
$product = new Product($productId, $this->getPlugin()->getLanguageId());
}
if (empty($attributeId) && !empty($productId) && $product->hasAttributes()) {
$result[] = $cartItem;
continue;
}
$product->loadStockData();
/**
* validate attributes
*/
if ($product->hasAttributes()) {
$invalidAttribute = false;
$message = '';
if (!$attributeId) {
$cartItem->setError(ShopgateLibraryException::UNKNOWN_ERROR_CODE);
$cartItem->setErrorText('attributeId required');
$message = 'attributeId required';
$invalidAttribute = true;
} else {
$validAttributeId = false;
if (version_compare(_PS_VERSION_, '1.5.0', '<')) {
$attributeIds = BWProduct::getProductAttributesIds($productId);
} else {
$attributeIds = $product->getProductAttributesIds($productId, true);
}
foreach ($attributeIds as $attribute) {
if ($attributeId == $attribute['id_product_attribute']) {
$validAttributeId = true;
continue;
}
}
if (!$validAttributeId) {
$invalidAttribute = true;
$message = 'invalid attributeId';
}
}
if ($invalidAttribute) {
$cartItem->setError(ShopgateLibraryException::UNKNOWN_ERROR_CODE);
$cartItem->setErrorText($message);
$result[] = $cartItem;
continue;
}
}
if ($product->id) {
if (version_compare(_PS_VERSION_, '1.5.0', '<')) {
$quantity = $product->getStockAvailable();
//getQuantityAvailableByProduct($productId, $attributeId, $this->getPlugin()->getContext()->shop->id);
} else {
$quantity = StockAvailable::getQuantityAvailableByProduct($productId, $attributeId, $this->getPlugin()->getContext()->shop->id);
}
$cartItem->setStockQuantity($quantity);
$cartItem->setIsBuyable($product->available_for_order && ($attributeId ? Attribute::checkAttributeQty($attributeId, ShopgateItemsCartExportJson::DEFAULT_QTY_TO_CHECK) : $product->checkQty(ShopgateItemsCartExportJson::DEFAULT_QTY_TO_CHECK)) || Product::isAvailableWhenOutOfStock($product->out_of_stock) ? 1 : 0);
} else {
$cartItem->setError(ShopgateLibraryException::CART_ITEM_PRODUCT_NOT_FOUND);
$cartItem->setErrorText(ShopgateLibraryException::getMessageFor($cartItem->getError()));
}
$result[] = $cartItem;
}
return $result;
}
示例14: processChangeProductInCart
/**
* This process add or update a product in the cart
*/
protected function processChangeProductInCart()
{
$mode = Tools::getIsset('update') && $this->id_product ? 'update' : 'add';
if ($this->qty == 0) {
$this->errors[] = Tools::displayError('Null quantity.', !Tools::getValue('ajax'));
} elseif (!$this->id_product) {
$this->errors[] = Tools::displayError('Product not found', !Tools::getValue('ajax'));
}
$product = new Product($this->id_product, true, $this->context->language->id);
if (!$product->id || !$product->active || !$product->checkAccess($this->context->cart->id_customer)) {
$this->errors[] = Tools::displayError('This product is no longer available.', !Tools::getValue('ajax'));
return;
}
$qty_to_check = $this->qty;
$cart_products = $this->context->cart->getProducts();
if (is_array($cart_products)) {
foreach ($cart_products as $cart_product) {
if ((!isset($this->id_product_attribute) || $cart_product['id_product_attribute'] == $this->id_product_attribute) && (isset($this->id_product) && $cart_product['id_product'] == $this->id_product)) {
$qty_to_check = $cart_product['cart_quantity'];
if (Tools::getValue('op', 'up') == 'down') {
$qty_to_check -= $this->qty;
} else {
$qty_to_check += $this->qty;
}
break;
}
}
}
// Check product quantity availability
if ($this->id_product_attribute) {
if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) {
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
}
} elseif ($product->hasAttributes()) {
$minimumQuantity = $product->out_of_stock == 2 ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock;
$this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity);
// @todo do something better than a redirect admin !!
if (!$this->id_product_attribute) {
Tools::redirectAdmin($this->context->link->getProductLink($product));
} elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) {
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
}
} elseif (!$product->checkQty($qty_to_check)) {
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
}
// If no errors, process product addition
if (!$this->errors && $mode == 'add') {
// Add cart if no cart found
if (!$this->context->cart->id) {
if (Context::getContext()->cookie->id_guest) {
$guest = new Guest(Context::getContext()->cookie->id_guest);
$this->context->cart->mobile_theme = $guest->mobile_theme;
}
$this->context->cart->add();
if ($this->context->cart->id) {
$this->context->cookie->id_cart = (int) $this->context->cart->id;
}
}
// Check customizable fields
if (!$product->hasAllRequiredCustomizableFields() && !$this->customization_id) {
$this->errors[] = Tools::displayError('Please fill in all of the required fields, and then save your customizations.', !Tools::getValue('ajax'));
}
if (!$this->errors) {
$cart_rules = $this->context->cart->getCartRules();
$available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart, false, true);
$update_quantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery);
if ($update_quantity < 0) {
// If product has attribute, minimal quantity is set with minimal quantity of attribute
$minimal_quantity = $this->id_product_attribute ? Attribute::getAttributeMinimalQty($this->id_product_attribute) : $product->minimal_quantity;
$this->errors[] = sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity);
} elseif (!$update_quantity) {
$this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.', !Tools::getValue('ajax'));
} elseif ((int) Tools::getValue('allow_refresh')) {
// If the cart rules has changed, we need to refresh the whole cart
$cart_rules2 = $this->context->cart->getCartRules();
if (count($cart_rules2) != count($cart_rules)) {
$this->ajax_refresh = true;
} elseif (count($cart_rules2)) {
$rule_list = array();
foreach ($cart_rules2 as $rule) {
$rule_list[] = $rule['id_cart_rule'];
}
foreach ($cart_rules as $rule) {
if (!in_array($rule['id_cart_rule'], $rule_list)) {
$this->ajax_refresh = true;
break;
}
}
} else {
$available_cart_rules2 = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart, false, true);
if (count($available_cart_rules2) != count($available_cart_rules)) {
$this->ajax_refresh = true;
} elseif (count($available_cart_rules2)) {
$rule_list = array();
foreach ($available_cart_rules2 as $rule) {
$rule_list[] = $rule['id_cart_rule'];
}
//.........这里部分代码省略.........
示例15: hookAdminStatsModules
public function hookAdminStatsModules($params)
{
global $cookie, $currentIndex;
$id_category = (int) Tools::getValue('id_category');
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
if (Tools::getValue('export')) {
if (!Tools::getValue('exportType')) {
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
}
}
$this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
if ($id_product = (int) Tools::getValue('id_product')) {
if (Tools::getValue('export')) {
if (Tools::getValue('exportType') == 1) {
$this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product));
} elseif (Tools::getValue('exportType') == 2) {
$this->csvExport(array('type' => 'pie', 'option' => '3-' . $id_product));
}
}
$product = new Product($id_product, false, (int) $cookie->id_lang);
$totalBought = $this->getTotalBought($product->id);
$totalSales = $this->getTotalSales($product->id);
$totalViewed = $this->getTotalViewed($product->id);
$this->_html .= '<h3>' . $product->name . ' - ' . $this->l('Details') . '</h3>
<p>' . $this->l('Total bought:') . ' ' . $totalBought . '</p>
<p>' . $this->l('Sales (-Tx):') . ' ' . Tools::displayprice($totalSales, $currency) . '</p>
<p>' . $this->l('Total viewed:') . ' ' . $totalViewed . '</p>
<p>' . $this->l('Conversion rate:') . ' ' . number_format($totalViewed ? $totalBought / $totalViewed : 0, 2) . '</p>
<center>' . ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product)) . '</center>
<br />
<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>';
if ($hasAttribute = $product->hasAttributes() and $totalBought) {
$this->_html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center><br />
<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br />';
}
if ($totalBought) {
$sales = $this->getSales($id_product, $cookie->id_lang);
$this->_html .= '<br class="clear" />
<h3>' . $this->l('Sales') . '</h3>
<div style="overflow-y: scroll; height: ' . min(400, (count($sales) + 1) * 32) . 'px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
<tr>
<th>' . $this->l('Date') . '</th>
<th>' . $this->l('Order') . '</th>
<th>' . $this->l('Customer') . '</th>
' . ($hasAttribute ? '<th>' . $this->l('Attribute') . '</th>' : '') . '
<th>' . $this->l('Qty') . '</th>
<th>' . $this->l('Price') . '</th>
</tr>
</thead><tbody>';
$tokenOrder = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee);
$tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee);
foreach ($sales as $sale) {
$this->_html .= '
<tr>
<td>' . Tools::displayDate($sale['date_add'], (int) $cookie->id_lang, false) . '</td>
<td align="center"><a href="?tab=AdminOrders&id_order=' . $sale['id_order'] . '&vieworder&token=' . $tokenOrder . '">' . (int) $sale['id_order'] . '</a></td>
<td align="center"><a href="?tab=AdminCustomers&id_customer=' . $sale['id_customer'] . '&viewcustomer&token=' . $tokenCustomer . '">' . (int) $sale['id_customer'] . '</a></td>
' . ($hasAttribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
<td>' . (int) $sale['product_quantity'] . '</td>
<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
</tr>';
}
$this->_html .= '</tbody></table></div>';
$crossSelling = $this->getCrossSales($id_product, $cookie->id_lang);
if (count($crossSelling)) {
$this->_html .= '<br class="clear" />
<h3>' . $this->l('Cross Selling') . '</h3>
<div style="overflow-y: scroll; height: 200px;">
<table class="table" border="0" cellspacing="0" cellspacing="0">
<thead>
<tr>
<th>' . $this->l('Product name') . '</th>
<th>' . $this->l('Quantity sold') . '</th>
<th>' . $this->l('Average price') . '</th>
</tr>
</thead><tbody>';
$tokenProducts = Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee);
foreach ($crossSelling as $selling) {
$this->_html .= '
<tr>
<td ><a href="?tab=AdminCatalog&id_product=' . (int) $selling['id_product'] . '&addproduct&token=' . $tokenProducts . '">' . $selling['pname'] . '</a></td>
<td align="center">' . (int) $selling['pqty'] . '</td>
<td align="right">' . Tools::displayprice($selling['pprice'], $currency) . '</td>
</tr>';
}
$this->_html .= '</tbody></table></div>';
}
}
} else {
$categories = Category::getCategories((int) $cookie->id_lang, true, false);
$this->_html .= '
<label>' . $this->l('Choose a category') . '</label>
<div class="margin-form">
<form action="" method="post" id="categoriesForm">
<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
<option value="0">' . $this->l('All') . '</option>';
foreach ($categories as $category) {
$this->_html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
//.........这里部分代码省略.........