Hello,
So I'm not a 100% sure how to ask this question, but here goes.
I got some code that I'm using for an X-Cart page. The portion of the php file that is $search_data['products']['categoryid'] = '2'; I need it to also look for 3 at the same time. 2 and 3 are categories that I need to display in a list in the TPL file. All items in the products database that I want to display are either in 2 or 3.
What do I need to do to this code and the tpl so that it displays all items in both categories?
PHP File:
<?php
All in-stock products on home page
*/
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }
$user_account['membershipid'] = max(0, intval($user_account['membershipid']));
if (isset($search_data['products']))
$old_search_data = $search_data['products'];
if (!empty($mode))
$old_mode = $mode;
$old_outofstock = $config['General']['show_outofstock_products'];
$do_not_use_navigation = true;
$search_data['products'] = array();
$search_data['products']['forsale'] = 'Y';
$search_data['products']['categoryid'] = '2'|'3';
$search_data['products']['category_main'] = 'Y';
$search_data['products']['search_in_subcategories'] = 'Y';
$config['General']['show_outofstock_products'] = 'N';
$REQUEST_METHOD = 'GET';
$mode = 'search';
include $xcart_dir . '/include/search.php';
if (isset($old_search_data))
$search_data['products'] = $old_search_data;
if (isset($old_mode))
$mode = $old_mode;
$config['General']['show_outofstock_products'] = $old_outofstock;
unset($old_search_data, $old_mode, $old_outofstock);
$do_not_use_navigation = false;
if ($total_items > 0) {
$_day = 'day';
$_month = 'month';
$_year = 'year';
foreach ($products as $k=>$v) {
$products[$k]['avail_date'] = '';
$day = $month = $year = '';
if (!empty($v['extra_fields'])) {
foreach ($v['extra_fields'] as $kef=>$vef) {
if(strtolower($vef['service_name']) == $_day && $vef['field_value'] != '')
$day = $vef['field_value'];
elseif(strtolower($vef['service_name']) == $_month && $vef['field_value'] != '')
$month = $vef['field_value'];
elseif(strtolower($vef['service_name']) == $_year && $vef['field_value'] != '')
$year = $vef['field_value'];
}
if ($day != '' && $month != '' && $year != '')
$products[$k]['avail_date'] = mktime(0, 0, 0, $month, $day, $year);
}
}
$smarty->assign('all_instock_products', $products);
}
?>
{*
All in-stock products on home page
*}
{if $all_instock_products}
{list2matrix assign="products_matrix" assign_width="cell_width" list=$all_instock_products row_length=1}
{assign var="is_matrix_view" value=true}
{if $products_matrix}
<table cellspacing="3" class="products products-table width-100" summary="{$lng.lbl_products_list|escape}">
{foreach from=$products_matrix item=row name=products_matrix}
<tr{interline name=products_matrix}>
{foreach from=$row item=product name=products}
{if $product}
<td{interline name=products additional_class="product-cell product-cell-buynow"}>
{if $active_modules.Product_Configurator and $is_pconf and $current_product}
{include file="modules/Product_Configurator/pconf_add_form.tpl"}
{elseif $active_modules.Product_Configurator and $product.product_type eq "C"}
{assign var="url" value="product.php?productid=`$product.productid`&cat=`$cat`&page=`$navigation_page`"}
{if $featured eq 'Y'}
{assign var="url" value=$url|cat:"&featured=Y"}
{/if}
{include file="customer/buttons/details.tpl" href=$url}
{/if}
</td>
<td{interline name=products additional_class="product-cell product-cell-price"}>
{if $product.product_type ne "C"}
{if $active_modules.Subscriptions ne "" and $product.catalogprice}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{elseif $product.appearance.is_auction}
<span class="price">{$lng.lbl_enter_your_price}</span><br />
{$lng.lbl_enter_your_price_note}
{else}
{if $product.appearance.has_price}
<div class="price-row">
<span class="price">{$lng.lbl_our_price}:</span> <span class="price-value">{include file="currency.tpl" value=$product.taxed_price}</span>
<span class="market-price">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$product.taxed_price}</span>
</div>
{if $product.appearance.has_market_price and $product.appearance.market_price_discount gt 0}
<div class="market-price">
{$lng.lbl_market_price}: <span class="market-price-value">{include file="currency.tpl" value=$product.taxed_price}</span>
{if $product.appearance.market_price_discount gt 0}
{if $config.General.alter_currency_symbol ne ""}, {/if}
<span class="price-save">{$lng.lbl_save_price} {$product.appearance.market_price_discount}%</span>
{/if}
</div>
{/if}
{if $product.taxes}
<div class="taxes">{include file="customer/main/taxed_price.tpl" taxes=$product.taxes is_subtax=true}</div>
{/if}
{/if}
{if $active_modules.Special_Offers and $product.use_special_price}
{include file="modules/Special_Offers/customer/product_special_price.tpl"}
{/if}
{/if}
{elseif $product.product_type ne "C"}
{/if}
</td>
<td{interline name=products additional_class="product-cell"}>
<script type="text/javascript">
//<![CDATA[
products_data[{$product.productid}] = {ldelim}{rdelim};
//]]>
</script>
<a href="{$product.alt_url|default:$product.page_url|amp}" class="product-title">{$product.product|amp}</a>
</td>
<td{interline name=products additional_class="product-cell"}>{$product.avail_date|date_format:$config.Appearance.datetime_format}</td>
{/if}
{/foreach}
</tr>
{/foreach}
</table>
{/if}
{/if}