Solution: Nice PayPal Downloads Hack, Add a Newsletter Opt-in Option

Tech


Joomla!

Joomla is one of the world’ s most popular open source CMS (content management system).

Version: 1.5-2.5
Developer: Open Source Matters, Inc.
Linkhttp://www.joomla.org


Nice PayPal Downloads

The Nice PayPal Downloads extension is a robust download manager that allows you to distribute files for free or for paid download. 

Version: 1.92
Developer: TriniTronic
Linkhttp://trinitronic.com/index.php/Downloads/nice-paypal-downloads.html


Background


The Nice PayPal Downloads extension does not currently support a newsletter opt-in option.  However, with a small hack, you could modify the plugin to add a newsletter opt-in drop down box. The only catch is that the Nice PayPal Downloads will not keep a record of the buyer's choice. You will need to consult your PayPal account history or your PayPal notification emails to retrieve the buyer's newsletter opt-in selection.


Solution


IMPORTANT: Before you proceed make a full back up of your web site files and database.


The "System - Nice PayPal Download Button" plugin creates all of the buttons for the Nice PayPal Downloads extension. This plugin is the portion of the extension that you will need to modify in order to add a newsletter opt-in drop-down selection feature. Keep in mind, this modification will effect all Nice PayPal Download buttons on your website. It is a global alteration.


To modify the System - Nice PayPal Download Button plugin, do the following.

1. Back up your website.

2. FTP into your site.

3. Go to plugins/system/nicepaypaldownloadsbtn/

4. Download the file named nicepaypaldownloadsbtn.php

5. Make a local copy of the file name it nicepaypaldownloadsbtn-backup.php

6. Open the file in a text editor. I like Notepad++ for Windows.

7. Find the block of code that looks like the following, around line 165.


{codecitation class="brush:sql;first-line:165;" width="550px" }

$insert = '<form action="'.$this->paypal_url.'/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_xclick">  

<input type="hidden" name="business" value="'.$this->paypal_email.'">  

<input type="hidden" name="item_name" value="'.$this->_data->item_name.'">  

<input type="hidden" name="item_number" value="'.$this->_data->id.'">

<input type="hidden" name="quantity" value="1">

<input type="hidden" name="amount" value="'.$this->_data->amount.'">

<input type="hidden" name="tax" value="'.$this->_data->tax.'">

<input type="hidden" name="shipping" value="0">

<input type="hidden" name="currency_code" value="'.$this->currency_code.'"> 

<input type="hidden" name="lc" value="'.$this->country_code.'">

<input type="hidden" name="mrb" value="YRDKF6S68Y7DS"/>

<input type="hidden" name="return" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;nd=r&amp;itm='.$this->_data->id.'">    

<input type="hidden" name="cancel_return" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;nd=c&amp;itm='.$this->_data->id.'">    

<input type="hidden" name="notify_url" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;controller=Ipn&amp;task=ipn">  

<input type="image" border="0" name="submit" src="'.$btnimg.'" alt="PayPal - The safer, easier way to pay online">

</form>';

{/codecitation}


8. You're now going to need to add the drop down menu code to the block of code.


{codecitation class="brush:sql;first-line:165;highlight:[172,173,174,175,176,177,178,179,180,181,182,183]" width="550px" }

$insert = '<form action="'.$this->paypal_url.'/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_xclick">  

<input type="hidden" name="business" value="'.$this->paypal_email.'">  

<input type="hidden" name="item_name" value="'.$this->_data->item_name.'">  

<input type="hidden" name="item_number" value="'.$this->_data->id.'">

<input type="hidden" name="quantity" value="1">

<input type="hidden" name="amount" value="'.$this->_data->amount.'">

<p>

   <label>Subscribe to our Newsletter

   </label>

   <br>

   <input type="hidden" name="on0" value="newsletter">         

   <select name="os0">

     <option value="yes">Yes

     </option>

     <option value="no">No

     </option>

   </select>

</p>

<input type="hidden" name="tax" value="'.$this->_data->tax.'">

<input type="hidden" name="shipping" value="0">

<input type="hidden" name="currency_code" value="'.$this->currency_code.'"> 

<input type="hidden" name="lc" value="'.$this->country_code.'">

<input type="hidden" name="mrb" value="YRDKF6S68Y7DS"/>

<input type="hidden" name="return" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;nd=r&amp;itm='.$this->_data->id.'">    

<input type="hidden" name="cancel_return" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;nd=c&amp;itm='.$this->_data->id.'">    

<input type="hidden" name="notify_url" value="'.JURI::base().'index.php?option=com_nicepaypaldownloads&amp;controller=Ipn&amp;task=ipn">

<input type="image" border="0" name="submit" src="'.$btnimg.'" alt="PayPal - The safer, easier way to pay online">

</form>';

{/codecitation}


9. Save your changes to the file.

10. Upload the modified file back to its original location.


That should do it. All of your Nice PayPal Downloads buttons on your site will have the drop down buttons.


~ Enjoy success!