11
JMorris
Re: Felix, theCat!!! Re: paypal button How?
  • 2004/11/21 0:17

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


Ok, I've come up with a really good start on this one. Here's the code for the PayPal button:

echo "<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />";
echo "<input type="hidden" name="cmd" value="_xclick" />";
echo 
"<input type="hidden" name="business" value=".$ads->getVar('email')," />";
echo 
"<input type="hidden" name="item_name" value=".$ads->getVar('ads_title')," />";
echo 
"<input type="hidden" name="amount" value=".$ads->getVar('price')," />";
echo 
"<input type="hidden" name="no_note" value="1" />";
echo 
"<input type="hidden" name="currency_code" value="USD" />";
echo 
"<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />";
echo "</form>";


The Ad Title, Ad Price, and the e-mail Account of the Ad Poster dynamically updates based on which ad your visitors are viewing. So your Advertisers MUST use their PayPal when posting an Ad.

Ok, here's the down side. 1) I'm having a heck of time getting it to position correctly. 2) Only the first word of the Ad Title is sent to Paypal. 3) Only USD is currently supported.

This little hack is actually going to be quite useful for me as well, so I'm going to keep working on this as often I can.

I'll keep you updated.

12
JMorris
Re: Felix, theCat!!! Re: paypal button How?
  • 2004/11/21 2:06

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


OK, I believe this will do the trick. The following assumes you know how to work with templates. If you don't know how to work with templates, go tohttp://www.macambridge.com/dummies/ and read up on it.

Create a cloned template set, set it as default, and set "Update module template..." to yes.
Click on List next to Small ads in the template manager
Click edit for catads_item.html
Copy and paste the following code into the edit box:
<!-- Pas d'annonce  -->
<{if not $ad_exists and not $preview}>
    <{$smarty.const._MD_CATADS_NO_ADS}>
<{else}>
    <table cellspacing="1" class="outer" style="width:100%;">
      <tr> 
      <th><b>
      <{if $annonce.date_pub == 0}>
          <{$smarty.const._MD_CATADS_ADSWAIT}>
      <{elseif $annonce.date_exp == 0}>
          <{$smarty.const._MD_CATADS_ADSEXP}>
      <{else}>
          <{$annonce.date_pub}>
     <{/if}>
     </b> </th>
    <th> 
      <{$annonce.codpost}>&nbsp;<b><{$annonce.town}></b>
    </th>
  </tr>
  <tr> 
    <td width="22%" class="head"> 
      <{if $annonce.date_exp > 0 and $annonce.date_pub > 0}>
          <{$smarty.const._MD_CATADS_DATE_EXP}><{$annonce.date_exp}>
     <{/if}>
      </td>
    <td width="78%" class="head"> 
      <{$annonce.type}><b>: </b><{$annonce.title}>
    </td>
  </tr>
  <tr> 
    <td class="odd"> 
      (<{$annonce.nbview}>)
       </td>
    <td class="odd"> 
      <{if $annonce.price}>
          <b><{$smarty.const._MD_CATADS_PRICE2}>&nbsp;<{$annonce.price}></b>&nbsp;<{$annonce.monnaie}>
      <{if $annonce.price_option}>
          &nbsp;(<{$annonce.price_option}>) 
      <{/if}>
      <{/if}>
    </td>
  </tr>
  <tr> 
    <td width="22%" class="odd"> 
    <{if $annonce.suspend > 0}>
        <br><{$smarty.const._MD_CATADS_PUB_SUSP}>
     <{else}>
        <b><{$smarty.const._MD_CATADS_CONTACT}></b><br><br>
          <{$annonce.maillink}>
          </br>
          <{$annonce.pmlink}>
          </br></br>
          <b><{$smarty.const._MD_CATADS_PHONE}>&nbsp; </b><br>
          <{$annonce.phone}>
          <br> <b> </b>&nbsp; <br> 
      <{/if}>
<div align="center">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="<{$annonce.email}>" />
<input type="hidden" name="item_name" value="<{$annonce.title}>" />
<input type="hidden" name="amount" value="<{$annonce.price}>" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it'
s fastfree and secure!" />
</form>
</div>
      </td>
    <td class="
odd"><div align="left"> 
         
        <
{$annonce.description}>
        <br>
        <br>
        <
{$annonce.photo}>
        <br>
        <br>
      </div></td>
      </tr>
    <{if not 
$preview}>
      <tr> 
    <td align="
left" class="foot"> 
        <a href="
print.php?op=showone&ads_id=<{$annonce.id}>"><img src="images/print.gif" border=0 alt="<{$smarty.const._MD_CATADS_PRINT}>"></a>&nbsp; 
      <!-- Icone validation annonce en attente  -->
      <{if 
$xoops_isadmin and $annonce.date_pub == 0}>
      <a href="
admin/index.php?op=approve&ads_id=<{$annonce.id}>"><img src="images/valid.gif" border=0 alt="<{$smarty.const._MD_CATADS_VALIDADS}>"></a>&nbsp; 
        <{/if}>
        <!-- Icones édition/effacement annonce -->
        <{if 
$xoops_isadmin}>
        <a href="
admin/index.php?op=edit&ads_id=<{$annonce.id}>"><img src="images/modif.gif" border=0 alt="<{$smarty.const._MD_CATADS_EDITADS}>"></a>&nbsp; 
        <a href="
admin/index.php?op=delete&ads_id=<{$annonce.id}>"><img src="images/delete.gif" border=0 alt="<{$smarty.const._MD_CATADS_DELETEADS}>"></a>&nbsp; 
        <a href="
adsuserlist.php?uid=<{$annonce.uid}>"><img src="images/who.gif" border=0 alt="<{$smarty.const._MD_CATADS_ALLADS}><{$annonce.submitter}>"></a>&nbsp; 
        <img src="
images/ip.gif" border=0 alt="<{$annonce.poster_ip}>"></a>&nbsp; 
        <{/if}>
        &nbsp; &nbsp;</td>
    <td align="
right" class="foot"><div align="left"> 
      <{if 
$annonce.isauthor}>
          <{if 
$annonce.date_exp == 0 and $annonce.countpub > 0 and $annonce.date_pub > 0}>
              <a href="
adsitem.php?op=pubagain&ads_id=<{$annonce.id}>"><{$smarty.const._MD_CATADS_PUB_AGAIN}></a>
         <{elseif 
$annonce.date_pub > 0 and $annonce.date_exp > 0}>
              <{if 
$annonce.suspend > 0}>
                  <a href="
adsitem.php?op=stopandgo&ads_id=<{$annonce.id}>"><{$smarty.const._MD_CATADS_PUB_GO}></a>
             <{else}>
                  <a href="
adsitem.php?op=stopandgo&ads_id=<{$annonce.id}>"><{$smarty.const._MD_CATADS_PUB_STOP}></a>
             <{/if}>
         <{/if}>
     <{/if}>
    </div></td>
      </tr>
    <{/if}>
<{/if}>
</table>
<br>

<!-- Liens accueil/catégorie  -->
<{if not 
$preview}>
    <div align="
center"><b>[ <{$link_main}> | <{$link_cat}> ]</b></div>

    <div style="
text-aligncenterpadding3px;
    
margin:3px;">
    <
{$commentsnav}>
    <
{$lang_notice}>
    </div>

    <div style="
margin:3pxpadding3px;">
    <!-- start comments loop -->
    <{if 
$comment_mode == "flat"}>
        <{include file="
db:system_comments_flat.html"}>
    <{elseif 
$comment_mode == "thread"}>
        <{include file="
db:system_comments_thread.html"}>
    <{elseif 
$comment_mode == "nest"}>
        <{include file="
db:system_comments_nest.html"}>
    <{/if}>
<{/if}>

Click submit
Test
Set "Update module template..." to No

Sorry to give such a rushed tutorial. The button works quite nicely, albeit with the few limitations I mentioned in my last post.

I hope this meets your needs.

Best Regards,

JMorris

13
joeiscoffee
Re: Felix, theCat!!! Re: paypal button How?

JMoris,

This looks great! I just got in and will probably install this tomorrow.

Thanks again,

I'll keep you updated as to my progress.

14
joeiscoffee
Re: Felix, theCat!!! Re: paypal button How?

JMorris,

I am not getting the user's email to pass to paypal. The variable is empty. It looks like this in the html source.
<input type="hidden" name="business" value="" />


Did I do something wrong with the template cloning?

I did not see this option mentioned in your instructions when doing the template.
Quote:
Set "Update module template..." to No



Great progress you have made on this module.

15
JMorris
Re: Felix, theCat!!! Re: paypal button How?
  • 2004/11/21 7:05

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


Sorry about that. I forgot to mention that you have to define email. Open adsitem.php with a text/php editor and look for the following line:
$annonce['codpost'] = $ads->getVar('codpost');

Directly bellow that line add the following line:
$annonce['email'] = $ads->getVar('email');

Save and re-upload.
That will define the poster's email address in the PayPal form.

RE: Templates...
System Admin > Preferences > General Settings > Set "Update module template .html files from themes/your theme/templates directory?" to "Yes" before changing templates. After you change your templates, clear the contents of the templates_c folder on the web server. Then, just set "Update module template .html files from themes/your theme/templates directory?" to "No".

Sorry, my instructions are not that great.

Hope this helps.

16
joeiscoffee
Re: Felix, theCat!!! Re: paypal button How?

Works like a champ!

Thanks JMorris. And you too theCat.

Login

Who's Online

158 user(s) are online (68 user(s) are browsing Support Forums)


Members: 0


Guests: 158


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits