Skip to content

Instantly share code, notes, and snippets.

View picocodes's full-sized avatar
🏠
Building Noptin

picocodes

🏠
Building Noptin
View GitHub Profile
<?php
add_filter(
'getpaid_invoice_email_recipients',
function( $recipients, $email ) {
if ( 'completed_invoice' === $email->id ) {
$recipients[] = 'accounting@example.com';
}
return $recipients;
<?php
add_filter( 'getpaid_invoice_totals_rows', function( $totals, $invoice ) {
$discount = $invoice->get_discount_code();
if ( ! empty( $discount ) ) {
$totals['discount'] .= ' (' . $discount . ')';
}
return $totals;
<?php
// Add discount column.
add_filter( 'manage_wpi_invoice_posts_columns', function( $columns ) {
$columns['discount_code'] = __( 'Discount Code', 'invoicing' );
return $columns;
}, 999 );
// Display discount column.
add_action( 'manage_wpi_invoice_posts_custom_column', function( $column_name, $post_id ) {
<?php
// Give free trials until 2023-09-02.
$GLOBALS['wpinv_trial_ends'] = '2023-09-02';
if ( time() < strtotime( $GLOBALS['wpinv_trial_ends'] ) ) {
// Allow free trials.
add_filter(
'wpinv_get_item_is_free_trial',
<?php
add_action(
'getpaid_submissions_process_items',
function( &$submission ) {
/**@var GetPaid_Payment_Form_Submission $submission */
$percent = 5 / 100; // 5% processing fee.
$submission->remove_fee( 'Processing Fee' );
$submission->add_fee(
@picocodes
picocodes / zone.php
Created January 4, 2023 06:35
Customize zone template
<?php
/**
* Contains the zone template.
*
* You can override this template by copying it to your-theme/gpa/zone.php
*
* @var Adv_Zone_Template $zone The zone to display.
*/
defined( 'ABSPATH' ) || exit;
@picocodes
picocodes / subscriptions-user-roles.php
Created November 28, 2022 03:18
Update user roles when subscription statuses change
<?php
add_action(
'getpaid_subscription_status_changed',
function( $subscription ) {
$user = $subscription->get_customer();
if ( empty( $user ) ) {
return;
}
<?php
add_shortcode( 'gd_qr_code', 'gd_qr_code_shortcode' );
function gd_qr_code_shortcode( $atts ) {
$atts = shortcode_atts(
array(
'url' => '',
'size' => '150',
'alt' => '',
'class' => 'img-responsive',
<?php
/**
* Creates a custom meta box.
*
* @param string $post_type Post type.
* @param WP_Post $post Post.
*/
function prefix_add_meta_box( $post_type, $post ) {
<?php
// If next year is not yet here...
if ( (int) date( 'Y' ) < 2022 ) {
// ... then give a 50% discount on the initial item price...
add_filter( 'wpinv_get_initial_item_price', function( $price ) {
global $wpdb;
// ... unless he/she is not a first time customer.