Plugin Directory

Changeset 670301


Ignore:
Timestamp:
02/19/2013 02:11:36 PM (13 years ago)
Author:
mohsinrasool
Message:
  • Added filters
  • Added feature to open payment page in a new window
  • Added feature to allow for user entered payments.
Location:
paypal-pay-buy-donation-and-cart-buttons-shortcode
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • paypal-pay-buy-donation-and-cart-buttons-shortcode/trunk/admin-settings.php

    r666765 r670301  
    201201        <em>Possible Values</em>: "&nbsp;" or "&lt;br /&gt;"</p>
    202202
     203        <p><strong>amount_prompt:</strong> <br>
     204        (boolean) (optional) Setting to "1" will enable user to enter amount they would like to pay.<br>
     205        <em>Possible Values</em>: 1 or 0</p>
     206
    203207        <p><strong>echo_link:</strong> <br>
    204208        (boolean) (optional) Set to "1" for linked output<br>
     209        <em>Possible Values</em>: 1 or 0</p>
     210
     211        <p><strong>open_new_window:</strong> <br>
     212        (boolean) (optional) Set to "1" to open payment page in a new window<br>
    205213        <em>Possible Values</em>: 1 or 0</p>
    206214
  • paypal-pay-buy-donation-and-cart-buttons-shortcode/trunk/paypal-pay-buy-cart-buttons.php

    r666770 r670301  
    44Plugin URI: http://mohsinrasool.wordpress.com/2013/01/11/wordpress-shortcode-for-paypal-pay-buy-donation-and-cart-buttons/
    55Description: Add a "paypal_button" shortcode to display pay now, buy now, donation and add to cart PayPal buttons with facility to customize they paypal checkout page.
    6 Version: 1.4
     6Version: 1.5
    77Author: Mohsin Rasool
    88Author URI: http://mohsinrasool.wordpress.com
    99License: GPL2
    10     Copyright 2013  Mohsin Rasool  (email : mohsin.rasool@gmail.com)
    1110
    1211    This program is free software; you can redistribute it and/or modify
     
    2625
    2726function wpdev_paypal_button($atts, $content = null) { 
    28     extract(shortcode_atts(array( 
     27    $final_atts = shortcode_atts(array( 
    2928    'type'=>  get_option('wpdev_paypal_button_type'),
    3029    'email' => get_option('wpdev_paypal_button_email'),
     
    3231    'id' => '',
    3332    'amount' => '',
     33    'amount_prompt' => 0,
    3434    'quantity' => '1',
    3535    'echo_link' => false,
     
    4343    'btn_text' => '',
    4444    'btn_url' => get_option('wpdev_paypal_button_custom_url'),
     45    'open_new_window' => 0,
    4546    'add_note'=>get_option('wpdev_paypal_button_add_note'),
    4647    'thankyou_page_url'=> get_option('wpdev_paypal_button_thankyou_url'),
     
    5051    'checkout_bg_color' => get_option('wpdev_paypal_button_checkout_bg_color'),
    5152    'button_subtype' => '',
    52     ), $atts)); 
     53    ), $atts); 
     54    extract($final_atts);
    5355   
    5456    global $post;
     
    156158    }
    157159    else {
     160        $rand = rand(111,999);       
    158161        if(!empty($btn_url))
    159162            $btn_src = $btn_url;
     
    169172        }
    170173
    171         $output = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" class="paypal_button_form">';
     174        $output = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" class="paypal_button_form" '.($open_new_window ? "target='_blank'": "").'>';
    172175        foreach($paypal_values as $name =>$val){
    173176            switch($name){
    174177                case 'amount':
    175                     $output .= '<input type="hidden" class="paypal_amount" name="'.$name.'" value="'.$val.'">';
     178
     179                    if($amount_prompt)
     180                        $output .= '<input type="text" class="paypal_amount" name="'.$name.'" value="'.$val.'">'.html_entity_decode($field_sep);
     181                    else
     182                        $output .= '<input type="hidden" class="paypal_amount" name="'.$name.'" value="'.$val.'">';
    176183                    $output .= '<input type="hidden" class="temp_amount" name="temp_'.$name.'" value="'.$val.'">';
    177184                    break;
     
    186193            $quantity = explode('-',$quantity);
    187194            if(is_numeric($quantity[0]) && is_numeric($quantity[1]) && $quantity[0]<$quantity[1]) {
    188                 $output .= '<select name="'.$quantity_field.'" class="paypal_quantity">';
     195                $output .= '<select name="'.$quantity_field.'" onchange="return '.  apply_filters('paypal_button_cal_amount','adjustPayPalQuantity'.$rand.'(this);').'" class="paypal_quantity">';
    189196                for($i=$quantity[0]; $i<=$quantity[1]; $i++)
    190197                    $output .= '<option value="'.$i.'"> '.$i.$quantity_txt_postfix.' </option>';
     
    197204            $quantity = explode(',',$quantity);
    198205            if(count($quantity)>0) {
    199                 $output .= '<select name="'.$quantity_field.'" class="paypal_quantity">';
     206                $output .= '<select name="'.$quantity_field.'" onchange="return '.  apply_filters('paypal_button_cal_amount','adjustPayPalQuantity'.$rand.'(this);').'" class="paypal_quantity">';
    200207                for($i=0; $i<count($quantity); $i++){
    201208                    if(is_numeric($quantity[$i]))
     
    213220
    214221        if(!empty($quantity) && ($type=='donation' || $type=='donate') ){
    215             $rand = rand(111,999);       
    216222            $output .= '
    217223            <input type="image" class="paypal_button_form_submit" src="'.$btn_src.'" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"
    218                 onclick="return adjustPayPalQuantity'.$rand.'(this);">
    219             <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
     224                onclick="return '.  apply_filters('paypal_button_cal_amount','adjustPayPalQuantity'.$rand.'(this);').'">
     225            <img alt="" style="border:0;display:none" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    220226            </form>
    221227            ';
     
    224230            <script type="text/javascript">
    225231                function adjustPayPalQuantity'.$rand.'(elem){
    226                     if(jQuery(elem).siblings(".paypal_quantity")) {
    227                         var qty = jQuery(elem).siblings(".paypal_quantity").val();
     232                    var qty = jQuery(elem).parent().find(".paypal_quantity").val();
     233                    if(typeof qty != "undefined" && !isNaN(parseInt(qty))) {
    228234                        var amount = jQuery(elem).siblings(".temp_amount").val();
    229235                        jQuery(elem).siblings(".paypal_amount").val(qty * amount);
     
    243249    }
    244250   
    245     return $output;
     251    return apply_filters('paypal_button_output',$output, $final_atts);
    246252
    247253
  • paypal-pay-buy-donation-and-cart-buttons-shortcode/trunk/readme.txt

    r666277 r670301  
    55Requires at least: 3.0.1
    66Tested up to: 3.5.1
    7 Stable tag: 1.4
     7Stable tag: 1.5
    88Author: Mohsin Rasool
    99License: GPLv2
     
    2525- **Allow buyer to add a note to order**
    2626- **Select language of your button.** Supports 17 widely used languages
     27- **Both Admin generated amount (based on quantity) and user filled amount payments**
    2728
    2829Possible usage of the plugin are as follows
     
    7475    Possible Values: "&nbsp;" or "<br />"
    7576
     77    **amount_prompt**:
     78    (boolean) (optional) Setting to "1" will enable user to enter amount they would like to pay.
     79    Possible Values: 1 or 0
     80
    7681    **echo_link**:
    7782    (boolean) (optional) Set to "1" for linked output
     83    Possible Values: 1 or 0
     84
     85    **open_new_window**:
     86    (boolean) (optional) Set to "1" to open payment page in a new window
    7887    Possible Values: 1 or 0
    7988
     
    157166== Changelog ==
    158167
     168= 1.5 =
     169* Added filters
     170* Added feature to open payment page in a new window
     171* Added feature to allow for user entered payments.
     172
    159173= 1.4 =
    160174* Added support for 17 languages for PayPal buttons.
     
    179193== Upgrade Notice ==
    180194
     195= 1.5 =
     196* Added filters
     197* Added feature to open payment page in a new window
     198* Added feature to allow for user entered payments.
     199
    181200= 1.4 =
    182201* Added support for multilingual buttons.
Note: See TracChangeset for help on using the changeset viewer.