J-B Posted February 17, 2021 Share Posted February 17, 2021 Hello, I wrote a module that gets information about an API by curl. But i have no check is a product active or not. When a customer click to this cancel services (clientarea.php?action=productdetails&id=XXX), the customer get a lot of errors. That is right, why the user dont exist anymore. But how I can check in smarty if a product is active and then get the data? Something like: { if product == active } $data {else} You canceled your product. {/if} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 17, 2021 Share Posted February 17, 2021 9 minutes ago, J-B said: But how I can check in smarty if a product is active and then get the data? in Smarty and on the product details page? if you wanted to check if the current service was active, then {if $status == "Active"} should work... 0 Quote Link to comment Share on other sites More sharing options...
J-B Posted February 17, 2021 Author Share Posted February 17, 2021 4 minutes ago, brian! said: {if $status == "Active"} Not work. It is still trying to get the api data. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 17, 2021 Share Posted February 17, 2021 any reason for wanting to do this in Smarty? I mean can the module not check the database, either capsule query, class method or API, to get the status of the service ?? 0 Quote Link to comment Share on other sites More sharing options...
J-B Posted February 17, 2021 Author Share Posted February 17, 2021 Status == active seems to be if a user is active but not if a product is active. 2 minutes ago, brian! said: any reason for wanting to do this in Smarty? I mean can the module not check the database, either capsule query, class method or API, to get the status of the service ?? I thought that would be the easiest way. Any idea how to make the check in the function cloudxl_ClientArea(array $params) { 0 Quote Link to comment Share on other sites More sharing options...
CodeCo Posted February 17, 2021 Share Posted February 17, 2021 I believe the product/service status is included in $params array. 0 Quote Link to comment Share on other sites More sharing options...
J-B Posted February 18, 2021 Author Share Posted February 18, 2021 Just where? I haven't found it yet. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 18, 2021 Share Posted February 18, 2021 In the server module's _Clientarea() function, status is in $params['status']. For example: if ($params['status'] == "Cancelled") { $Cancel = Capsule::table('tblcancelrequests')->where('relid', '=', $params['serviceid'])->first(); if ($Cancel) $Reason = $Cancel->reason; else $Reason = "Reason not provided"; return array( 'tabOverviewReplacementTemplate' => "templates/fatal_error", 'vars' => array('message'=>"Service has been cancelled with the following reason:<br><br>$Reason" ) ); } Then in templates/fatal_error, have: <div class="alert alert-danger">Error: {$message}</div> (templates is relative to the server module's directory) For template it self, within the server module template at least, you would use:{if $status eq "Cancelled"} but that isn't needed if you use the above within the server module. 1 Quote Link to comment Share on other sites More sharing options...
J-B Posted February 19, 2021 Author Share Posted February 19, 2021 Thanks a lot @steven99 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.