Jump to content

AmitTQ

Member
  • Posts

    9
  • Joined

  • Last visited

About AmitTQ

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

AmitTQ's Achievements

Junior Member

Junior Member (1/3)

0

Reputation

  1. I want to add a table elsewhere on the home page and show the product/service details in that table
  2. Hi im looking for a way to create a table on the clientareahome.tpl to show a brief of user products and services such as service name, expire date, etc. I am using below code in my table: <div class="tab-pane fade in active" id="products-tab" role="tabpanel" aria-labelledby="products-tab-btn"> <div class="table-responsive"> {if in_array('products',$contactpermissions)} <table class="table table-hover"> <thead> <tr> <th>{$LANG.orderproduct}</th> </tr> </thead> <tbody> {foreach $services item=service} <tr> <td>{$service.name}</td> </tr> {foreachelse} <tr> <td colspan="7">You have not any active service</td> </tr> {/foreach} </tbody> </table> {/if} </div> <div class="tab-btn"> <br> </div> </div> but it is not giving me the details I found that I would need to create a hook but I dont know how because im noob in programming.
  3. I created a hook-file.php and pasted your code and faced with "Oops!" message with below details: Error: Call to undefined method WHMCS\Service::find() in .../includes/hooks/service_customfields_clientareapagesubmitticket.php:14 #0 .../includes/hookfunctions.php(0): WHMCS\Utility\SafeInclude::{closure}(Array)#1 .../includes/clientareafunctions.php(0): run_hook('ClientAreaPageS...', Array)#2 .../submitticket.php(0): outputClientArea('supportticketsu...', false, Array)#3 {main}
  4. I used same code and only changed the hook to: add_hook('ClientAreaPageSubmitTicket', 1, function($vars) { so if I used your shared hook, what should i use in .tpl file to echo the custom field value to the page ?
  5. Hi friends, I am looking for a way to bring a custom product field to new ticket service selector items. I did it for products list page using below code as hook.php: <?php use WHMCS\Database\Capsule as DB; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } add_hook('ClientAreaPageProductsServices', 1, function($vars) { $fieldId = 'Product Serial Number'; //Custom field Name if (isset($vars['services'])) { $csVals = []; foreach ($vars['services'] as $service) { $fieldVal = ''; $data = DB::table('tblcustomfieldsvalues AS t1') ->leftJoin('tblcustomfields AS t2', 't1.fieldid', '=', 't2.id') ->select('t1.value') ->where('t2.fieldname', $fieldId)->where('t2.type', 'product')->where('t1.relid', $service['id']) ->first(); if (!is_null($data)) { $fieldVal = $data->value; } $csVals[$service['id']] = $fieldVal; } return ['customFields' => $csVals]; } }); then used it in templates/six/clientareaproducts.tpl as: {$customFields[$service.id]} But I am not able to do the same with the supportticketsubmit-steptwo.tpl to have same output on new ticket product list. Any idea ? BR
  6. I finally found the way!! The original code is doing below query: SELECT * FROM tblcustomfieldsvalues AS t1 LEFT JOIN tblcustomfields AS t2 ON t1.fieldid = t2.id WHERE t2.id = 2 #Field id AND t2.type = 'product' AND t1.relid = 9 #service id So on the query part we dont need to do anything but in retrieving part, we can have a change I have changed: ->where('t2.id', $fieldId)->where('t2.type', 'product')->where('t1.relid', $service['id']) to: ->where('t2.fieldname', $fieldId)->where('t2.type', 'product')->where('t1.relid', $service['id']) and from: $fieldId = 4; //Custom field id to: $fieldId = 'Field Name'; //Custom field name Now, in the product list of clientarea, we have the custom field value on all products, no matter of field ID, we only need to have a custom field with same name on all products. so the new code for hook file will be: <?php use WHMCS\Database\Capsule as DB; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } add_hook('ClientAreaPageProductsServices', 1, function($vars) { $fieldId = 'Field Name'; //Custom field name if (isset($vars['services'])) { $csVals = []; foreach ($vars['services'] as $service) { $fieldVal = ''; $data = DB::table('tblcustomfieldsvalues AS t1') ->leftJoin('tblcustomfields AS t2', 't1.fieldid', '=', 't2.id') ->select('t1.value') ->where('t2.fieldname', $fieldId)->where('t2.type', 'product')->where('t1.relid', $service['id']) ->first(); if (!is_null($data)) { $fieldVal = $data->value; } $csVals[$service['id']] = $fieldVal; } return ['customFields' => $csVals]; } }); the rest is same as "izghitu" initial codes:
  7. Actually, the original Hook and .tpl edit is fine in mechanism, what I need is to use field name instead of field ID so I can use a general field name for all products (like product serial number) and have it in all customer products not just for a specific filed of specific product. Thank for the reply!
  8. I was able to use the initial code shared by "izghitu" but new code shared by "ewsoares" did not work to me. I used same way to use the quoted code like the initial code. It will be very great if someone advise me to use it in right way.
  9. Welcome to WHMCS.Community AmitTQ! We're glad you're here please take some time to familiarise yourself with the Community Rules & Guidelines and take a moment to introduce yourself to other WHMCS.Community members in the Introduce Yourself Board.

×
×
  • 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