j1979 Posted May 13, 2010 Share Posted May 13, 2010 hello all.. i am using a Joomla Component called travelbook for my site and am almost there with my quest to integrate paypal.. but my total price sent to paypal is wrong.. the code i am editing uses 2 variables that i need to add together and pass to paypal. the first variable is ok $rate_total, when i use $_SESSION['paypal']=$rate_total this works perfectly. the second variable i need to send has an operator i don't understand the second variable is chosen by the user via a radio button.. if a user picks the top option at £12.. the variable sends the amount linked to one of the other radio button options. i can only find 1 variable in the code $record->rate (but i belevie the operator in the middle is changing the radio button option) but i can't find anywhere an example of this operator in PHP. so from my testing $record->rate is the only variable i can use but this is always sending the integer value from one of the other radio buttons and not the button chosen by the user does anyone know how i can make $record->rate equal a new variable with the correct option chosen by the user. sorry if this is a very basic question but i have never done any PHP and not any programming for at least 10 years Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/ Share on other sites More sharing options...
teamatomic Posted May 13, 2010 Share Posted May 13, 2010 I guess telling us what this "secret" operator is and showing some code would help. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1057807 Share on other sites More sharing options...
j1979 Posted May 13, 2010 Author Share Posted May 13, 2010 I guess telling us what this "secret" operator is and showing some code would help. HTH Teamatomic // additional services if (count($this->add_services_items)>0) { echo "<div id='box_services_rechts'>\n"; echo " <fieldset>\n"; echo " <legend>".JText::_('TB On Top')."</legend>\n"; // $typ_id = $this->add_services_items[0]->srv_type; $typ_id = $this->add_services_items[0]->type; // $typ_id = NULL; $index = 0; $service_index = 0; echo "<div class='tb_services_start' id='tb_services0'>".$this->add_services_items[0]->type."</div>\n"; foreach ($this->add_services_items as $record) { if ( $typ_id != $record->type ) { $service_index++; echo "<div class='tb_services' id='tb_services".$service_index."'>".$record->type."</div>\n"; } if ( $record->checked ) { $checked = "checked='checked'"; } else { $checked = ''; } echo " <input type='".$record->category."' id='cb".$service_index.$index."' name='".$record->category.$service_index."' value='".$record->name."' ".$checked."> ".$record->name." (".number_format($record->rate, 0, ',', '.')." ".$this->currency.")<br />\n"; echo " <input type='hidden' name='value_".$record->category.$service_index."' value='".$record->pro_rata." ".number_format($record->rate, 0, ',', '.')." ".$this->currency."'>\n"; echo " <input type='hidden' name='wert_".$record->category.$service_index."' value='".$pax/$pax*$record->rate."'>\n"; $typ_id = $record->type; $index++; $_SESSION['paypal']=$rate_total+$record->rate; } } ...... this last line ( $_SESSION['paypal']=$rate_total+$record->rate; ) is giving the result but of the wrong radio button. Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1057813 Share on other sites More sharing options...
ChemicalBliss Posted May 13, 2010 Share Posted May 13, 2010 That "secret" Operator you mentioned is infact a Class operator used to interact with Objects. $record is obviously an object (Possibly with all the values from the form), so "$record->rate" is asking for the Property of "rate" in the object that is held by $record. If you want to know more about $record object use a "var_dump($record)", it should show you all the properties assigned to this object. Note, Having no experience with joomla i cant help you how to specifically change or modify it in a convenient and efficient way. But the moethods i have written down of usng var dump will at least tell you if you can even access that property from the $record object. -cb- Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1057823 Share on other sites More sharing options...
j1979 Posted May 13, 2010 Author Share Posted May 13, 2010 ^ Thank you for the quick response what totally baffles me (and it does not take much) is that the value in this line echo " <input type='hidden' name='wert_".$record->category.$service_index."' value='".$pax/$pax*$record->rate."'>\n"; gives the correct result. i just want to create a PHP variable that has the same value as the code above. so that i can send this to the paypal page $_SESSION['paypal'] = the value of the code above. Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1057848 Share on other sites More sharing options...
teamatomic Posted May 13, 2010 Share Posted May 13, 2010 As Chemical Bliss stated... What you should do is make use of the Joomla forum or wherever you got the pulgin from as I doubt you are the only user and if there is in fact a problem there is probably already a stated fix for it. OTOH. It may that you are not giving the correct value to the paypal API. One thing I think might be problematic is where you have the session var, within the same block that the form is created in. There is no code there to process anything. Which is where I feel that the session var should be assigned a value, not within the form block. Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1057850 Share on other sites More sharing options...
j1979 Posted May 14, 2010 Author Share Posted May 14, 2010 Thank you everyone i appreciate the help provided. I have posted on the forum dedicated to the component some time ago (march 7th) but no reply. i think the author is busy and not able to reply. i hope someone here is able to help a little more i have used var dump with theses results... each radio button outputs something similar to this: object(stdClass)#125 (11) { ["id"]=> string(2) "35" ["srv_type"]=> string(2) "65" ["category"]=> string(5) "radio" ["checked"]=> string(1) "0" ["pro_rata"]=> string(0) "" ["ordering"]=> string(1) "5" ["published"]=> string(1) "1" ["rate"]=> string(2) "49" ["type"]=> string(30) "Collection or Delivery options" ["catid"]=> string(2) "75" ["name"]=> string(37) } OR object(stdClass)#126 (11) { ["id"]=> string(2) "32" ["srv_type"]=> string(2) "65" ["category"]=> string(5) "radio" ["checked"]=> string(1) "1" ["pro_rata"]=> string(0) "" ["ordering"]=> string(1) "2" ["published"]=> string(1) "1" ["rate"]=> string(2) "24" ["type"]=> string(30) "Collection or Delivery options" ["catid"]=> string(2) "75" ["name"]=> string(57) } the value i need to output from the $record object is which ever has the value "radio" ["checked"]=> string(1) "1" and i need it to return the value located here ["rate"]=> string(2) "24" does anyone have a link or some advice how to output this value? thanks in advance. Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1058460 Share on other sites More sharing options...
ChemicalBliss Posted May 20, 2010 Share Posted May 20, 2010 ^ Thank you for the quick response what totally baffles me (and it does not take much) is that the value in this line echo " <input type='hidden' name='wert_".$record->category.$service_index."' value='".$pax/$pax*$record->rate."'>\n"; gives the correct result. i just want to create a PHP variable that has the same value as the code above. so that i can send this to the paypal page $_SESSION['paypal'] = the value of the code above. So first, here is your solution variable. $total = $pax/$pax*$record->rate; I dont know where the $pax variable comes from, but if the value in that text box is what u want then this is what u want. -cb- Link to comment https://forums.phpfreaks.com/topic/201636-very-newbie-question/#findComment-1061088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.