Jump to content

Someone give me php line


NormanRynd

Recommended Posts

Hello, i hope someone help me out with this just need to customize my fields.

i have the dropdown option on my product for the Operating system to let client choose what OS

The problem here windows os has a static pass "123123" so i want to custom the email if the client chooses windows he will get a message telling him this pass cause it's not dynamic

i have the field build using configurable options so i want something like that ( it's not code just an example )

 

IF custom_field_operatingsystem = windows-server-2019 [ 

your password: 123123

else [

Your password : $whmcs.module.password

]

 

can someone give me this line ?

Thanks

Link to comment
Share on other sites

Hello, I have made a hook for you

 

add_hook('EmailPreSend', 1, function($vars) {
    
    $merge_fields = [];
    foreach ($vars['mergefields']['service_custom_fields_by_name'] as $field) {
    if ($field['name'] == 'Operating system') { // consider 'Operating system' here
        $OperatingSystem = $field['value'];
        break;
    }
    }
    
    if ($OperatingSystem == "windows-server-2019") // consider "windows-server-2019" here
    
    {
        $merge_fields['service_password'] = "123123";
    }

    return $merge_fields;
});

consider the names of Operating system and windows-server-2019 to be as you have them on your website exactly

and tell me if it worked with you 

Edited by AladdinJ
Link to comment
Share on other sites

I really appreciate your effort and spending time to help me out! thanks.

but sadly it didn't work there no effect happens i made a file at /includes/hooks "Emails.php" and added a hook you provide and tried changing names small to capital,etc.

but no luck so I will provide you with more screenshots of the settings you may notice something 

This the configurable field ( Operating system ) 

image.png.47e15f7b5ee433c2e73dfefe47de57af.png

 

This field from product settings

image.png.822025b599b9a377edf1ad571dc9a519.png

image.png.92c68132f0c9f97881b0dae6ffd89516.png

This email setting

 

all I want if the user to choose " Window-server2019" or 2016 or 2012 it provides him the static password if not then the module will generate the password.

 

Thanks for your effort. will wait for your answer 

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