diba Posted October 14, 2019 Share Posted October 14, 2019 hey guys i want to customize my viewinvoice template but i have lots of problem, if any one have experience in it, please help me lots of problem to show variables in template from smarty. as you know in template file i have not access to run php so how can i access to this fields : _ rawamount or price:protected ( code has been attached ) _ product item quantity number ( default format like this "item Quantity x service name" in $LANG.invoicesdescription ) _ how can i set code to my product and show them in my invoice ? _ how can i sum $tax , $total, $subtotal values ? _ and where is disscount value ? Array ( [0] => Array ( [id] => 15 [type] => Addon [relid] => 2 [description] => ??????? ?? (domain.com) - ??? ????? ? ?????? ????? (2019/09/21 - 2020/09/20) [rawamount] => 390000.00 [amount] => WHMCS\View\Formatter\Price Object ( [price:protected] => 390000 [currency:protected] => Array ( [id] => 2 [code] => ???? [prefix] => ???? [suffix] => [format] => 4 [rate] => 1.00000 ) [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX} [defaultCurrencyDescriptor:protected] => Array ( [format] => 1 [prefix] => [suffix] => ) ) [taxed] => 1 ) [1] => Array ( [id] => 16 [type] => [relid] => 0 [description] => domain [rawamount] => 29800.00 [amount] => WHMCS\View\Formatter\Price Object ( [price:protected] => 29800 [currency:protected] => Array ( [id] => 2 [code] => ???? [prefix] => ???? [suffix] => [format] => 4 [rate] => 1.00000 ) [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX} [defaultCurrencyDescriptor:protected] => Array ( [format] => 1 [prefix] => [suffix] => ) ) [taxed] => 1 ) ) i could not find any solution for my problems in forums or WHMCS documentation. thanks in advance for your complete guide to resolve this problem 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 14, 2019 Share Posted October 14, 2019 2 hours ago, diba said: rawamount or price:protected ( code has been attached ) if you're in the invoiceitems foreach loop, then it would simply be... {$item.rawamount} 2 hours ago, diba said: product item quantity number ( default format like this "item Quantity x service name" in $LANG.invoicesdescription ) WHMCS doesn't store product quantities with invoices as a separate field - only if Group Similar Line Items is enabled in general settings -> invoices will the line item description be replaced in viewinvoice as you describe.... if the option is unticked, then each line item will be listed individually. 2 hours ago, diba said: how can i set code to my product and show them in my invoice ? if you mean SKU type codes, there's no native support for doing this in WHMCS... simplest solution would be to add them to the product names 2 hours ago, diba said: how can i sum $tax , $total, $subtotal values ? you surely wouldn't want to sum all three in an invoice, e.g $totals = ($subtotal + $tax + $tax2 - $credit)) ?? it will help you to know that these variables use Price Formatter, which basically allows limited manipulation of them in the template... so if we go back to your previous question about rawamount, let's say that it equals 100, and your currency is USD (I know it isn't in real life!) {$item.rawammount} == 100 {$item.amount} == $100 USD {$item.amount->toPrefixed()} == $100 {$item.amount->toSuffixed()} == 100 USD {$item.amount->toNumeric()) == 100 the point being that once you have them as numerics, you can add them... {$subtotal->toNumeric() + $tax->toNumeric() + $tax2->toNumeric()} this will add the three values together and output them (without any currency prefix/suffix). it is worth stating that if you're going to do any calculations, and especially for complex calculations, then do them using a PHP action hook and pass the results back to the template. 2 hours ago, diba said: and where is discount value ? if a line item is a discount, then $item.type should equal "GroupDiscount" and it's value would be {$item.amount}... or if you prefer {$item.rawamount} 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.