Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can i get the total value from the following URL http://tradephonein.com/checkout-swap/?total=$18.00&broken=No&water=%20No&power=Yes,%20battery%20included&lcd=No&charger=&manual=Owner%20Manual&box=&other=

I have this kind of a string query, you'll see that there is a total=$18.00, my question is, how can I get the value because I want it to subtract in a number.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

If those values are in your query then you can use the following

if( get_query_var('total') ) {
    $total_value = floatval( str_replace( '$', '', get_query_var('total') ) );

or else

if( isset( $_GET['total'] ) ) {
    $total_value = floatval( str_replace( '$', '', $_GET['total'] ) );
share|improve this answer
No isset check? –  t31os Dec 3 '11 at 13:27
Yeah done the isset check :) –  Joshua Abenazer Dec 3 '11 at 16:42
sorry I forgot to say thank you, thanks anyway. it works :) –  markyeoj Dec 5 '11 at 8:10

I don't know anything about gravity forms. But normally you get that value with php via $_GET / $_POST object / array:

isset($total) ? $total : $total = 0; // is total set; if not set it to 0;
$total = substr($_GET['total'], "$"); // grab the value after the dollar sign
$total = strval(htmlentities($total)); // Let's sanitize the values. Don't forget to do this!

Sorry i haven't actually test that yet.

share|improve this answer
No isset check? –  t31os Dec 3 '11 at 13:26
Just demonstrating concepts. But good point. I'll add it in for you @t31os –  chrisjlee Dec 3 '11 at 15:47
You already had my +1 anyway, but i'd give you another if i could for adding that in.. :) Further note, might wanna cast that value to int... (never know what that value may contain).. –  t31os Dec 3 '11 at 16:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.