Jump to content

custom variable


TGK

Recommended Posts

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.
 

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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 by TGK
Correct info
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by TGK
Correct info
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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!

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