Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / functions.php
Created July 6, 2018 05:24
[WooCommerce] Add custom order is paid statuses
<?php
add_filter( 'woocommerce_order_is_paid_statuses', 'my_custom_woocommerce_order_is_paid_statuses' );
/**
* @param array $statuses
* @return array
*/
function my_custom_woocommerce_order_is_paid_statuses( $statuses ) {
// already included statuses are processing and completed
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:14
[Refer A Friend] Set store credit reward to percentage of order subtotal i.e. excluding discounts
<?php
add_filter( 'automatewoo/referrals/reward_amount', 'filter_automatewoo_referrals_reward_amount', 10, 3 );
/**
* @param float $reward_amount
* @param \AutomateWoo\Referrals\Advocate $advocate
* @param \WC_Order $order
* @return float
*/
@danielbitzer
danielbitzer / functions.php
Created May 30, 2018 04:29
[AutomateWoo] Run AutomateWoo events every 5 minutes instead of every minute
<?php
// Run AutomateWoo events every 5 minutes instead of every minute
add_action( 'automatewoo_loaded', function() {
remove_action( 'automatewoo_events_worker', [ 'AutomateWoo\Cron', 'before_worker' ], 1 );
remove_action( 'automatewoo_events_worker', [ 'AutomateWoo\Events', 'run_due_events' ] );
add_action( 'automatewoo_five_minute_worker', [ 'AutomateWoo\Events', 'run_due_events' ] );
} );
@danielbitzer
danielbitzer / functions.php
Created May 29, 2018 01:33
[Refer A Friend] Team based referrals, such as for Teams for WooCommerce Memberships
<?php
add_filter( 'automatewoo/referrals/advocate_id', 'my_filter_automatewoo_advocate_id_for_team_leader' );
/**
* @param $user_id
* @return int
*/
function my_filter_automatewoo_advocate_id_for_team_leader( $user_id ) {
@danielbitzer
danielbitzer / functions.php
Created May 10, 2018 23:20
Set queue to run every minute instead of every 5
<?php
add_action( 'automatewoo_loaded', function() {
remove_action( 'automatewoo_five_minute_worker', [ 'AutomateWoo\Queue_Manager', 'check_for_queued_events' ] );
add_action( 'automatewoo_events_worker', [ 'AutomateWoo\Queue_Manager', 'check_for_queued_events' ] );
} );
@danielbitzer
danielbitzer / function.php
Created March 17, 2018 12:46
[Refer A Friend] Set custom account tab share text
<?php
add_filter( 'automatewoo/referrals/account_tab_share_link_text', function() {
return __( 'Insert custom share link text here.', 'text-domain' );
});
@danielbitzer
danielbitzer / functions.php
Created March 17, 2018 12:36
[Refer A Friend] Custom title for the referrals account tab
<?php
add_filter( 'automatewoo/referrals/account_tab_title', function() {
return 'My Custom Tab Name';
});
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:16
AutomateWoo Refer A Friend - Change referral coupon length
<?php
// Please note, once the length is changed you may need to delete the advocate's existing coupon
// before new coupons with the new length will be generated.
add_filter( 'automatewoo/referrals/coupon_key_length', function(){
return 5;
});
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:16
AutomateWoo Refer A Friend - Change referral coupon prefix
<?php
// WARNING! If you change the prefix all existing coupons will no longer work.
// Default coupon prefix is 'REF'
add_filter( 'automatewoo/referrals/coupon_prefix', function(){
return 'MY_PREFIX';
});
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:17
AutomateWoo - Allow click tracking to external hosts
<?php
/**
* Adding a domain to the 'allowed_redirect_hosts' filter means AutomateWoo will use click tracking for URLs
* on this domain. Otherwise only URLs matching the site's domain will use click tracking for security reasons.
*
* @param array $hosts
* @return array
*/
add_filter( 'allowed_redirect_hosts', function( $hosts ) {