Support Forums

Add a variable to a paypal for instruction

This is a discussion on Add a variable to a paypal for instruction within the Templates, HTML, CSS, and Design Help forums, part of the General category; Does anyone know how to add a variable to a paypal <form> instruction? What I want to do is place ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 02-28-2011, 10:06 AM   #1
Customer
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 241
Rep Power: 14
MrGForce is on a distinguished road
Default Add a variable to a paypal for instruction

Does anyone know how to add a variable to a paypal <form> instruction?

What I want to do is place an extra field's info into the "hosted_button_id value field", as indicated by the string of xxxxx's below..... The new extra field is called "pid" with an id#29 . It shows up when debugging in the array for that listing but I can't get it to replace the hardcoded string that's normally in the form.

I've tried the following .... {$pid}, {extras.pid}, $pid, $id29 . I've even tried adding a {foreach} statement at the top of the viewlisting.tpl file giving the extra field a var=" name" and then indicating that name where the xxxx's are and that didn't work either. I don't see that var="name" when I do a {debug} either. Hope someone can help with this.

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="xxxxxxxxxxxxx">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Thanking you in advance.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline   Reply With Quote
Old 02-28-2011, 10:37 AM   #2
Developer & Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,306
Rep Power: 69
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

I'm not quite sure that I understand what you are trying to do or where the code that you are displaying is from. For any given Payment gateway, the payment form (whether displayed to the user or not) is defined in the sr.php file within that payment gateways directory. What is available to the sr.php file is defined by the Gateways.php library class file.

You can also reference information for creating/modifying payment gateways in the developers section of the online documentation.

I will forewarn you that the PayPal gateway is different then any other payment gateway due to special requirements for the use of PayPal on the "callback" which is why there is an additional file for the use of PayPal called, "paypal.php" in the root of the 68 Classifieds directory.

More than likely in your scenario, you will need to add an additional function that runs prior to the create form function in the sr.php file to get, assign and apply your additional criteria or logic that runs first within the createForm function.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2,5.0)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 02-28-2011, 10:58 AM   #3
curmudgeon
 
Join Date: Mar 2006
Posts: 5,410
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

As Mike said the sr.php and paypal.php scripts do al the work. There is no smarty in use at that level so your not going to be able to use smarty variables.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 02-28-2011, 12:18 PM   #4
Customer
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 241
Rep Power: 14
MrGForce is on a distinguished road
Default

I'll see what I can do with the info you supplied. Again thanks for all the help. Thanks for the names of those files I need to work with.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline   Reply With Quote
Old 02-28-2011, 01:44 PM   #5
Developer & Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,306
Rep Power: 69
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

I can not stress this enough in working with files of that nature.

ONLY WORK ON COPIES OF THE FILES!!!
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2,5.0)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 02-28-2011, 03:25 PM   #6
Customer
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 241
Rep Power: 14
MrGForce is on a distinguished road
Default

Thanks Lary and Mike. You guys helped me before with some really tricky stuff, so I'm going to try to say what I need in just a little different way. I know how to do a temporary fix for my problem, but it's cumbersome and I know there's got to be an easier way. So here goes......

In the "viewlisting.tpl file I placed the <FORM> code to display a Paypal Button just after the extra fields, for one particular item and it works great, for that one item beause it contains the complete code for just that item. BUT, when placing all the hardcode into the viewlisting.tpl file, it displays that same paypal info for all the items. That's the problem. I'm trying to do this so a listing member can sell his or her own items through paypal. All they'll need when submitting a listing is that small bit of code to put with their listing. That code tells Paypal all about that item. It has nothing to do with the site's paypal function. That's totally separate.

So I created a Listing Extra Field to hold just the "value" that Paypal needs to distinguish it from another item ....

hosted_button_id" value="xxxxxxxxxxxxx">

So I searched the forum for a way to "assign a variable name" to that value which could be used whenever you wanted to display or use that variable. I found a {foreach extrafields} post and tried that but it did not assign the variable name to anything. I was told to put this at the top of the viewlisting.tpl file. The foreach code was ....

{foreach from=$extrafields item=extras}
{if $extras.fID==29}
(foreach key=key item=item from=$extras.value}
{assign var="paypalcode" value=#item"}
{/foreach}
{/if}
{/foreach}

All I continue to get when running {Debug} is the extra field displayed in an array like this, NO ASSIGNED VALUE ....

Array (2)
0 => Array (3)
fID => "16"
title => "Offered By"
value => "Private Seller"
2 => Array (3)
fID => "29"
title => "pid"
value =>"LYGS75N247JZT"


Is there a way to assign the var="paypalcode", shown in the {foreach} code above, the value indicated above in red? If I can do that, I believe I can make my <FORM> work.

Thanks.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline   Reply With Quote
Old 02-28-2011, 04:16 PM   #7
Customer
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 241
Rep Power: 14
MrGForce is on a distinguished road
Default

Hey guys, I got it to work ...... (almost).

What I did was this.....

I took the {foreach code} I put in at the top of the tpl file and combined it with the {foreach code} indicated down in the file which displayed the extra field data in the listing.

This is what I had placed at the top of the viewlisting.tpl page, as indicated before .....

{foreach from=$extrafields item=extras}
{if $extras.fID==29}
{foreach key=key item=item from=$extras.value}
{assign var="paypalcode" value="$item"}
{/foreach}
{/if}
{/foreach}

This is what's indicated in the viewlisting.tpl file (original) ....

{* Extra Fields *}
{foreach from=$extrafields item=extras}
<tr>
<td align="left"><strong>{$extras.title}:</strong></td>
<td align="left">
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item}
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{/foreach}
{* End Extra Fields *}


And this is what I now have that works (almost) ....

{* Extra Fields *}
{foreach from=$extrafields item=extras}
<tr>
<td align="left"><strong>{$extras.title}:</strong></td>
<td align="left">
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{assign var="paypalcode" value="$item"}
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{/foreach}
{* End Extra Fields *}

The reason I say that it almost works is that now, the Paypal button works just fine. The "paypalcode" variable works. BUT, all the other extra fields no longer display in the listing. Would you know how to just assign the one extra field fID==29 to the variable and leave the others alone.

.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline   Reply With Quote
Old 02-28-2011, 05:39 PM   #8
Developer & Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,306
Rep Power: 69
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

I'm a little confused still. If it were me, I would simply make the extra field not be seen in the viewlistings. Then I would make a copy of the get_extra_field smarty plugin and call it something like function.get_pp_button.php.

In the file modify it to put any additional things that you would want including any hidden form, etc, then assign that to one variable and assign that to the template.

e.g.
standard query in the plugin to get the value of the extra field.
modification to code after that
example:
PHP Code:
$pp_output = <form ....>
 ... 
</
form>
<
img src="pathtopaypalbutton">

return 
$pp_output
That way, you could simply put wherever you want the PayPal button in your viewlisting, you would simply put in your smarty plugin like normal. Like: {get_pp_button fid=29 id=$view}

Doing it that way then separates it from anything/everything else. and the only template modification would be adding the smarty plugin where you want it.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2,5.0)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 03-03-2011, 06:35 AM   #9
Customer
 
MrGForce's Avatar
 
Join Date: May 2009
Posts: 241
Rep Power: 14
MrGForce is on a distinguished road
Default

Thank you Mike. I'll work on your idea.
__________________
MrGForce

Currently running 68Classifieds v4.1.5 Developer Edition ... Purple Template
MrGForce is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PayPal page style variable metrony Templates, HTML, CSS, and Design Help 2 01-21-2010 08:42 PM
If Variable contains bowers01 Technical Support 1 09-28-2009 08:47 AM
v4.0.x How to compare variable hel68c Modules / Plugins / Modifications 5 04-14-2009 04:52 PM
$Body Variable? kampbell Templates, HTML, CSS, and Design Help 2 08-26-2007 11:41 AM


All times are GMT -4. The time now is 04:39 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0