TGK Posted September 2, 2018 Share Posted September 2, 2018 Hi im creating a custom variable in viewcart tpl im using a code that Brian! made variable works well but i need a little help this variable im trying to get the "amountin" field in tblaccounts table but i need this variable sum all amountin for each client ( userid) i leave the code hook <?php # Cart Email Verification Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function client_amountin_status_hook($vars) { $client = Menu::context("client"); if ($client && $vars['templatefile'] == 'viewcart') { $clientamount = Capsule::table('tblaccounts')->where('id',$client->id)->value('amountin'); return array("clientamount" => $clientamount); } } add_hook('ClientAreaPageCart', 1, 'client_amountin_status_hook'); ?> note: that hook code Brian made when he helped me to make some variable on other threat i just modified that hook code for make a new variable thanks in advance. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 2, 2018 Share Posted September 2, 2018 6 hours ago, TGK said: im trying to get the "amountin" field in tblaccounts table but i need this variable sum all amountin for each client ( userid) you know what to do - you just didn't have the confidence to try it. 😀 if you changed 'id' to userid' and 'value' to 'sum', then that should give you the amount you want... though it wouldn't be currency formatted. however, if the client is logged in, then you should be able to get the same figure, but currency formatted, using {$clientsstats.grossRevenue} 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted September 2, 2018 Author Share Posted September 2, 2018 (edited) 6 minutes ago, brian! said: you know what to do - you just didn't have the confidence to try it. 😀 if you changed 'id' to userid' and 'value' to 'sum', then that should give you the amount you want... though it wouldn't be currency formatted. however, if the client is logged in, then you should be able to get the same figure, but currency formatted, using {$clientsstats.grossRevenue} Thanks brian i trying to make a if statement where if the client total incoming amount is higher to 100 checkout button become disable i just need that this code and i will be done Really i need to change id to userid? Actually im gettinf the amoun but the 1 invoicr u think if can explaime i aprenciate for tech me Edited September 2, 2018 by TGK Correct info 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 2, 2018 Share Posted September 2, 2018 5 minutes ago, TGK said: Thanks brian i trying to make a if statement where if the client total incoming amount is higher to 100 checkout button become disable i just need that this code and i will be done generally, it would be... {if $clientsstats.grossRevenue->toNumeric() gt 100}* do something *{/if} I suppose if in standard_cart viewcart.tpl, you could change... <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == 0} disabled{/if}" id="checkout"> to... <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == 0 or $clientsstats.grossRevenue->toNumeric() gt 100} disabled{/if}" id="checkout"> and that would disable the checkout button if the cart was empty, or a logged in client with over 100 in previous income... a similar line {if $cartitems==0} exists in checkout too and this could be modified in the same way. 1 Quote Link to comment Share on other sites More sharing options...
TGK Posted September 2, 2018 Author Share Posted September 2, 2018 (edited) 7 minutes ago, brian! said: generally, it would be... {if $clientsstats.grossRevenue->toNumeric() gt 100}* do something *{/if} I suppose if in standard_cart viewcart.tpl, you could change... <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == 0} disabled{/if}" id="checkout"> to... <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == 0 or $clientsstats.grossRevenue->toNumeric() gt 100} disabled{/if}" id="checkout"> and that would disable the checkout button if the cart was empty, or a logged in client with over 100 in previous income... a similar line {if $cartitems==0} exists in checkout too and this could be modified in the same way. Im triying like this, im trying to create a new variable because i dont know about that clientstats I can use it without make any aditional step? <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == "0" || $verficado == "false" && $clientsstats.grossRevenue->toNumeric() gt 100} disabled{/if}" id="checkout"> Edited September 2, 2018 by TGK Correct info 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 2, 2018 Share Posted September 2, 2018 19 minutes ago, TGK said: Im triying like this, im trying to create a new variable because i dont know about that clientstats I can use it without make any aditional step? no additional steps - if they're logged in, then the variable will exist... if they're not logged in, then it won't... but if they're not logged in, your hook wouldn't work either. 1 Quote Link to comment Share on other sites More sharing options...
TGK Posted September 2, 2018 Author Share Posted September 2, 2018 11 minutes ago, brian! said: no additional steps - if they're logged in, then the variable will exist... if they're not logged in, then it won't... but if they're not logged in, your hook wouldn't work either. Yeah i notice that no logged in the i Just modified de login in the final checkout page Thanks for all Brian! 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.