I am using X cart and I have tried add function that hide price until customers log in.
so I added following codes to my files with notepad but I am keep getting smarty errors
Error: Smarty error: [in customer/main/products_t.tpl line 161]: syntax error: 'if' statement requires arguments (Smarty_Compiler.class.php, line 1270) in /home1/lemielfa/public_html/include/lib/smarty/Smarty.class.php on line 1092
Here's Smarty.class.php line 1092
-------------------------------------------------------------------------------------------------------------------------------------
* @param string $error_msg
* @param integer $error_type
*/
function trigger_error($error_msg, $error_type = E_USER_WARNING)
{
(line1092----->)trigger_error("Smarty error: $error_msg", $error_type);
}
/**
* executes & displays the template results
--------------------------------------------------------------------------------------------------------------------------------
This was my first time adding some code to my web, I hope I didn't screw up that much......
Thank You
David
----------------------------------------------------------------------------------------
Following Code ADDED /b]
1. Apply following SQL statements either from your cart admin/patch area or myphpadmin. This will place 2 controls in General Settings / General options in Common options. The first one will allow you to turn this mod on/off
Code:
INSERT INTO `xcart_config` (`name`, `comment`, `value`, `category`, `orderby`, `type`, `defvalue`, `variants`, `validation`) VALUES
('cflsys_hide_prices', 'Hide prices for non-logged in customers (this will also hide quantity box, "buy now" and "add to cart" buttons)', 'N', 'General', 75, 'checkbox', 'N', '', '');
INSERT INTO `xcart_config` (`name`, `comment`, `value`, `category`, `orderby`, `type`, `defvalue`, `variants`, `validation`) VALUES
('cflsys_hide_prices_message', 'Show this optional message if the option "Hide prices" is enabled', 'You need to login in order to see prices and place orders.', 'General', 76, 'text', '', '', '');
2. Add to init.php at the end of the file just before
PHP Code:
#
# WARNING !
# Please ensure that you have no whitespaces / empty lines below this message.
# Adding a whitespace or an empty line below this line will cause a PHP error.
#
this
PHP Code:
# added by CFL Systems for hide prices if customer not logged in
$smarty->assign("cflsys_hide_prices",$config['General']['cflsys_hide_prices']);
$smarty->assign("cflsys_hide_prices_message",$config['General']['cflsys_hide_prices_message']);
# added by CFL Systems for hide prices if customer not logged in
3. In skin1/customer/main/products.tpl find
Code:
{if $config.Appearance.products_per_row && ($featured eq "Y" || $config.Appearance.featured_only_multicolumn eq "N")}
{include file="customer/main/products_t.tpl"}
{else}
{include file="customer/main/products_list.tpl"}
{/if}and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if $login eq "" && $cflsys_hide_prices eq "Y"}
{if $cflsys_hide_prices_message ne ""}
<div style="color: red; margin: 5px 0; padding: 5px 5px 5px 10px; border: 1px solid #cccccc;">{$cflsys_hide_prices_message}</div>
{/if}
{/if}
{* added by CFL Systems to hide prices if customer not logged in *}
4. In skin1/customer/main/product.tpl (skin1/customer/main/product_details.tpl for 4.3.x, code may be slightly different) find this
Code:
<tr>
<td class="property-name product-price">{$lng.lbl_price}:</td>
<td class="property-value">
and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if $login eq "" && $cflsys_hide_prices eq "Y"}
$nbsp;
{else}
{* added by CFL Systems to hide prices if customer not logged in *}
then find
Code:
{if $product.forsale ne "B"}
<tr>
<td colspan="2">
{include file="customer/main/product_prices.tpl"}
</td>
</tr>
{/if}and after add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if}
{* added by CFL Systems to hide prices if customer not logged in *}
then find
Code:
<tr>
<td class="property-name product-input">
{$lng.lbl_quantity}and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if $login eq "" && $cflsys_hide_prices eq "Y"}
<tr>
<td colspan="2">
{if $cflsys_hide_prices_message ne ""}
{$cflsys_hide_prices_message}
{else}
{/if}
</td>
</tr>
{else}
{* added by CFL Systems to hide prices if customer not logged in *}then find
Code:
{/if}
</table>
and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if}
{* added by CFL Systems to hide prices if customer not logged in *}then find
Code:
{if $product.appearance.buy_now_buttons_enabled}and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if $login eq "" && $cflsys_hide_prices eq "Y"}
$nbsp;
{else}
{* added by CFL Systems to hide prices if customer not logged in *}then find
Code:
</form>and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if}
{* added by CFL Systems to hide prices if customer not logged in *}
5. In skin1/customer/main/products_list.tpl find
Code:
{if $product.product_type eq "C"}
{include file="customer/buttons/details.tpl" href=$url}
{else}and after add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if $login eq "" && $cflsys_hide_prices eq "Y"}
$nbsp;
{else}
{* added by CFL Systems to hide prices if customer not logged in *}
then find
Code:
{/if}
</div>
<div class="clearing"></div>and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if}
{* added by CFL Systems to hide prices if customer not logged in *}
6. In skin1/customer/main/products_t.tpl find
Code:
<tr>
{foreach from=$row item=product}
{if $product}
<td class="product-cell product-cell-price">
{if $product.product_type ne "C"}
{if $active_modules.Subscriptions ne "" && $product.catalogprice}
and before add
Code:
{if $login eq "" && $cflsys_hide_prices eq "Y"}
<tr>
<td colspan="2">
</td>
</tr>
{else}
{* added by CFL Systems to hide prices if customer not logged in *}then find at the end of the file
Code:
{/foreach}
</table>
{/if}and before add
Code:
{* added by CFL Systems to hide prices if customer not logged in *}
{if}
{* added by CFL Systems to hide prices if customer not logged in *}