Skip to content

Commit

Permalink
issue #156
Browse files Browse the repository at this point in the history
  • Loading branch information
zcadditions committed May 20, 2019
1 parent ad15481 commit 64a45b5
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions includes/modules/centerboxes/specials_index.php
@@ -1,6 +1,6 @@
<?php
/**
* new_products.php module
* specials_index.php module
*
* @package modules
* @copyright Copyright 2003-2018 Zen Cart Development Team
Expand All @@ -15,17 +15,19 @@
// initialize vars
$categories_products_id_list = array();
$list_of_products = '';
$new_products_query = '';
$special_products_query = '';

$display_limit = zen_get_new_date_range();

if ( (($manufacturers_id > 0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id) ) {
$new_products_query = "SELECT DISTINCT p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_id = pd.products_id
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
AND p.products_status = 1 " . $display_limit;
$special_products_query = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id, p.product_is_call
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id )
WHERE p.products_id = s.products_id
AND p.products_id = pd.products_id
AND p.products_status = 1 AND s.status = 1
AND pd.language_id = " . (int)$_SESSION['languages_id'];
} else {
// get all products and cPaths in this subcat tree
$productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
Expand All @@ -37,55 +39,57 @@
}
$list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

$new_products_query = "SELECT DISTINCT p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_id = pd.products_id
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
AND p.products_status = 1
AND p.products_id in (" . $list_of_products . ")";
$special_products_query = "SELECT DISTINCT p.products_id, p.products_image, pd.products_name, p.master_categories_id, p.product_is_call
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id )
WHERE p.products_id = s.products_id
AND p.products_id = pd.products_id
AND p.products_status = 1 AND s.status = 1
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
AND p.products_id in (" . $list_of_products . ")";
}
}

if ($new_products_query != '') $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS);
if ($special_products_query != '') $special_products = $db->ExecuteRandomMulti($special_products_query, MAX_DISPLAY_SPECIAL_PRODUCTS_INDEX);

$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';

$num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount();
$num_products_count = ($special_products_query == '') ? 0 : $special_products->RecordCount();

// show only when 1 or more
if ($num_products_count > 0) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS == 0 ) {
$col_width = floor(100/$num_products_count);
} else {
$col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
$col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS);
}

while (!$new_products->EOF) {
$products_price = zen_get_products_display_price($new_products->fields['products_id']);
if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);
while (!$special_products->EOF) {
$products_price = zen_get_products_display_price($special_products->fields['products_id']);
if (!isset($productsInCategory[$special_products->fields['products_id']])) $productsInCategory[$special_products->fields['products_id']] = zen_get_generated_category_path_rev($special_products->fields['master_categories_id']);

$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContents card mb-3 p-3 text-center" id="centerBoxContentsNew"',
'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price);
'text' => (($special_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($special_products->fields['products_id']), 'cPath=' . $productsInCategory[$special_products->fields['products_id']] . '&products_id=' . $special_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $special_products->fields['products_image'], $special_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($special_products->fields['products_id']), 'cPath=' . $productsInCategory[$special_products->fields['products_id']] . '&products_id=' . $special_products->fields['products_id']) . '">' . $special_products->fields['products_name'] . '</a><br />' . $products_price);

$col ++;
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) {
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS - 1)) {
$col = 0;
$row ++;
}
$new_products->MoveNextRandom();
$special_products->MoveNextRandom();
}

if ($new_products->RecordCount() > 0) {
if ($special_products->RecordCount() > 0) {
if (!empty($new_products_category_id)) {
$category_title = zen_get_categories_name((int)$new_products_category_id);
$title = '<h4 id="newCenterbox-card-header" class="centerBoxHeading card-header">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h4>';
$title = '<h4 id="specialCenterbox-card-header" class="centerBoxHeading card-header">' . sprintf(TABLE_HEADING_SPECIALS_INDEX, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h4>';
} else {
$title = '<h4 id="newCenterbox-card-header" class="centerBoxHeading card-header">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h4>';
$title = '<h4 id="specialCenterbox-card-header" class="centerBoxHeading card-header">' . sprintf(TABLE_HEADING_SPECIALS_INDEX, strftime('%B')) . '</h4>';
}
$zc_show_new_products = true;
$zc_show_special_products = true;
}
}

0 comments on commit 64a45b5

Please sign in to comment.