Skip to content

Instantly share code, notes, and snippets.

@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
Created March 7, 2018 19:40
AutomateWoo - Add attachment to workflow email
<?php
add_filter( 'automatewoo/workflow/mailer', 'my_add_attachment_to_workflow_emails', 10, 2 );
/**
* @param Mailer $mailer
* @param Workflow_Email $workflow_email
* @return Mailer
*/
function my_add_attachment_to_workflow_emails( $mailer, $workflow_email ) {
@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 ) {
@danielbitzer
danielbitzer / functions.php
Created February 19, 2018 11:30
AutomateWoo Refer A Friend - Disable marking referrals as potential fraud
<?php
add_filter( 'automatewoo/referral/is_potential_fraud', '__return_false' );
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:18
[AutomateWoo] Custom date variable for meta field. More info at https://automatewoo.com/docs/variables/custom-variables/
<?php
add_filter( 'automatewoo/variables', 'my_automatewoo_variables' );
/**
* @param $variables array
* @return array
*/
function my_automatewoo_variables( $variables ) {
$variables['order']['my_custom_date'] = dirname(__FILE__) . '/variable-my-custom-date.php';
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:18
AutomateWoo - Blacklist an email address or multiple emails based on domain
<?php
// this filter was added in AW 3.6.0
add_filter( 'automatewoo/mailer/blacklist', function( $blacklist ){
$blacklist[] = 'email@example.com'; // block a single email
$blacklist[] = '@hotmail.com'; // block all emails from a domain
return $blacklist;
});
@danielbitzer
danielbitzer / functions.php
Created January 23, 2018 14:48
AutomateWoo - Get a list of a user's generated coupons
<?php
// please note the _aw_customer_id meta data was added in version 3.5.1
$user_id = 123; //example id
$customer = AutomateWoo\Customer_Factory::get_by_user_id( $user_id );
$query_args = [
'post_type' => 'shop_coupon',
'posts_per_page' => -1,
@danielbitzer
danielbitzer / functions.php
Created January 3, 2018 18:12
AutomateWoo - Increase expired coupon deletion rate
<?php
// this changes the coupon clean frequency to every 30 mins instead of 4 hours
// max coupon cleaned in a single batch is 200
add_action( 'automatewoo_loaded', function() {
remove_action( 'automatewoo_four_hourly_worker', [ 'AutomateWoo\Coupons', 'schedule_clean_expired' ] );
add_action( 'automatewoo_thirty_minute_worker', [ 'AutomateWoo\Coupons', 'schedule_clean_expired' ] );
});