Jump to content

Which action hook to use + tweaking order form and custom fields


alturic

Recommended Posts

Ok, so we basically have a new client checkout process/order form exactly how we need it, and I'll explain further below. We have a custom client field for "forumname" and "forumpassword". Those 2 fields are using IF statements in viewcart.tpl and only show if someone select the product addon "Forum Access", so that part is fine.

 

My question is this though and perhaps I'm just not truly understanding what people can use all the various hooks for (such as InvoicePaid) but theoretically we'd want to run the forum account creation AFTER that particular invoice is paid, but it'll run on every invoice being paid erroring out because there's already a forum account with that name... so forum creation type integration is the AddClient hook really the only real way people handle those?

 

Secondly, I put this:

 

<tr style="display: block;"><td style="width: auto;">Forum Username</td><td><input required="" style="max-width: 110px;" maxlength="20" type="text" name="customfield[13]" id="customfield13" value=""></td></tr>

 

 

into viewcart.tpl for someone doing "Order New Services" but yet when they click Checkout it doesn't post the value they entered, any clues as to why? Can you not input custom fields on existing client checkouts, which I'm assuming I'm wrong about. :P

Link to comment
Share on other sites

if it run when each invoice is marked as paid you can use if statement to search in forum database if the client already exist there, if not proceed with creating the account.

 

you can catch the information added in custom fields using action hooks too

Link to comment
Share on other sites

if it run when each invoice is marked as paid you can use if statement to search in forum database if the client already exist there, if not proceed with creating the account.

 

you can catch the information added in custom fields using action hooks too

 

So, knowing that code above shows on existing clients "Order New Services" checkout, the value they enter for customfield[13] should get sent to (and saved obviously) to customfield[13] in the clients profile fields, when the

 

<form method="post" action="/cart.php?a=checkout&submit=true" id="mainfrm">

 

gets submitted, right? If so, it's not for existing clients checking out for some reason. :-/

 

I know traditionally people probably do foreach $customclientfield and stuff but this was the only way I was able to get it to work how we needed since we're using if statements for literally every customclientfield, I didn't know how to do it inside the foreach syntax. Yea, I'm a bad boy and use {php} code all the time and then save the var into Smarty so I can do:

 

{if $forumaddoncount['PremiumForum'] == 1}
<tr style="display: block;"><td style="width: auto;">Forum Username</td><td><input required="" style="max-width: 110px;" maxlength="20" type="text" name="customfield[13]" id="customfield13" value=""></td></tr>
<tr style="display: block;"><td style="width: auto;">Forum Password</td><td><input required="" style="max-width: 110px;" maxlength="20" type="text" name="customfield[14]" id="customfield14" value=""></td></tr>
{/if}

 

 

Last quick question, is there anyway to find a list of vars that are available (without {debug}ing every hook) at each action hook? So if I wanted to find out what variables were available at "InvoicePaid" I could pull $clientdetails.customfield13 or whatever it might be?

Edited by alturic
Link to comment
Share on other sites

Oh and also, since WHMCS is meant as a hosting billing system what would be the easiest approach to start stripping away the various instances of the words "Domains' and such in the client-side of things? Is ALL of that stuff in the tpl files or is there language files I need to edit as well?

Link to comment
Share on other sites

Last quick question, is there anyway to find a list of vars that are available (without {debug}ing every hook) at each action hook? So if I wanted to find out what variables were available at "InvoicePaid" I could pull $clientdetails.customfield13 or whatever it might be?

in hook actions you can use the $vars it contain array of variables WHMCS pass it to you based on type of hook action.

<?php
function hook_actionname($vars){
   $varName = $vars['varname'];
}
?>

 

also you can use global variables like the $CONFIG like that:

<?php
function hook_actionname($vars){
global $CONFIG;
   $systemurl = $CONFIG['SystemURL'];
}
?>

 

in TPL files you can use {debug} to see what the actual variables already assigned to be used inside .tpl files

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