Plugin Directory

Changeset 1949133

Timestamp:
09/29/2018 05:22:52 PM (6 years ago)
Author:
Guss77
Message:

Allow donations to be added manually from the campaign view

Location:
kickgogo/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kickgogo/trunk/README.md

    r1949118 r1949133  
    55- Tested up to: 4.9.8
    66- Requires PHP: 7.0.0
    7 - Stable tag: 1.5.1
     7- Stable tag: 1.
    88- License: GPLv2
    99- License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • kickgogo/trunk/inc/options.php

    r1949118 r1949133  
    364364                $this->deleteTransaction($campaign->name, $_POST['transaction']);
    365365                break;
     366
     367
     368
    366369        }
    367370       
     
    470473        }
    471474        </script>
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
    472512        <?php
    473513    }
     
    500540    }
    501541   
    502    
     542    public function handle_add_transaction($campaignId, $data) {
     543        global $wpdb;
     544       
     545        if (!is_numeric($data['amount'])) {
     546            $this->report_error('Missing donation amount!');
     547        }
     548       
     549        if ($this->has_errors())
     550            return false;
     551       
     552        $tid = $this->getNextTransactionId();
     553        $details = json_encode([
     554            'amount' => $data['amount'],
     555            'campaign' => $campaignId,
     556            'confirmation' => "manual-$tid",
     557            'code' => $tid,
     558            'name' => @$data['name'],
     559            'email' => @$data['email'],
     560            'phone' => @$data['phone'],
     561            'orderid' => "manual-$tid",
     562            'test' => @$data['test'] ? true : false
     563            ]);
     564       
     565        $wpdb->insert($this->transaction_table, [
     566            'campaign_id' => $campaignId,
     567            'amount' => $data['amount'],
     568            'test' => @$data['test'] ? 1 : 0,
     569            'details' => $details,
     570        ]);
     571        return true;
     572    }
    503573   
    504574    public function report_error($error) {
     
    533603        global $wpdb;
    534604        $query = "select count(amount) from $this->transaction_table AS tr
    535             INNER JOIN $this->campaign_table AS cpg ON tr.campaign_id = cpg.id and cpg.name = '$name'
     605            INNER JOIN $this->campaign_table AS cpg ON tr.campaign_id = cpg.id and
    536606            WHERE tr.deleted = 0";
    537607        return $wpdb->get_var($query);
    538608    }
    539609   
     610
     611
     612
     613
     614
     615
    540616    public function getTransactions($name) {
    541617        global $wpdb;
    542618        $query = "select tr.* from $this->transaction_table AS tr
    543             INNER JOIN $this->campaign_table AS cpg ON tr.campaign_id = cpg.id and cpg.name = '$name'
     619            INNER JOIN $this->campaign_table AS cpg ON tr.campaign_id = cpg.id and
    544620            WHERE tr.deleted = 0";
    545621        return $wpdb->get_results($query);
  • kickgogo/trunk/kickgogo.php

    r1949118 r1949133  
    44 Plugin URI:  http://github.com/guss77/kickgogo-wordpress-plugin
    55 Description: Crowd-funding campaign manager
    6  Version:     1.5.1
     6 Version:     1.
    77 Author:      Oded Arbel
    88 Author URI:  https://github.com/guss77/kickgogo-wordpress-plugin
Note: See TracChangeset for help on using the changeset viewer.