Jump to content

Smarty: if product is active?


J-B

Recommended Posts

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}

 

Link to comment
Share on other sites

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)
{



 

Link to comment
Share on other sites

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. 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated