I am reworking the coupon system on our site and got following problem now:
I am checking the session for a cc_id (couponcode_id), if it isset i give the variable to a PHP file in which some functions are beeing made. Just one example:
{if $smarty.session.cc_id}
<div class="coupon-outter">
<div class="coupon">
<div class="coupon-code-start">
<p>Ihr Coupon ist aktiv.<br>
Klicken Sie hier für Details</p>
</div>
<div class="coupon-code-detail">
<div class="coupon-block-headline">
<p class="coupon-headline">{$smarty.session.cc_id|@get_coupon_code}</p>
</div>
</div>
</div>
</div>
{/if}
So in my understanding, the whole thing only happens IF the session variable {$smarty.session.cc_id}
isset. Now if i redeem a coupon and the session variable is available, it all works just fine. But when the session variable is not set i am getting following error code:
USER ERROR(256): "Smarty error: [in C:/xampp/htdocs/xxx/xxx/xxx/index.html line 72]: [plugin] modifier 'get_coupon_code' is not implemented (core.load_plugins.php, line 118)"
So i know that Smarty can't pass the session cc_id if it is not set. But if it is not set it shouldn't even do the whole code block, but it is trying to and then i get the error because it can't pass the cc_id.
Here my PHP:
function get_coupon_code($ccid){
$sql = "SELECT coupon_code FROM coupons WHERE coupon_id='".$ccid."'";
$retval = mysql_query($sql);
$row = mysql_fetch_assoc($retval);
return $row['coupon_code'];
}
Any suggestions for solving this?