pronamic / wp-pronamic-pay-charitable

Charitable driver for the WordPress payment processing library.
2 stars 1 forks source link

{first_campain_name} tag in payment description #2

Closed knit-pay closed 3 years ago

knit-pay commented 3 years ago

Hello Team Many of my clients are asking to show the campaign name in the payment description. I made this small change in CharitableHelper class, get_description function. May I raise a pull request if you find it helpful?

  public static function get_description( $gateway, $donation_id ) {
    $description = $gateway->get_value( 'transaction_description' );
    $donation = new Charitable_Donation( $donation_id );

    if ( '' === $description ) {
        $description = self::get_title( $donation_id );
    }

    // Replacements.
    $replacements = array(
        '{donation_id}' => $donation_id,
        '{first_campaign_name}' => reset($donation->get_campaigns()),
    );

    return \strtr( $description, $replacements );
}
remcotolsma commented 3 years ago

Nice addition, pull request welcome.

https://github.com/Charitable/Charitable/blob/1.6.50/includes/abstracts/abstract-class-charitable-abstract-donation.php#L315-L324

remcotolsma commented 3 years ago

Merged https://github.com/wp-pay-extensions/charitable/pull/3