Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
danielbitzer / functions.php
Last active June 8, 2023 12:42
Customizing WooCommerce and AutomateWoo email CSS with a filter
<?php
add_filter( 'woocommerce_email_styles', 'my_filter_woocommerce_email_styles' );
/**
* Filter email styles for WooCommerce and AutomateWoo.
*
* @param string $css
*
* @return string
@danielbitzer
danielbitzer / functions.php
Created December 10, 2018 16:35
[AutomateWoo] Prevent email capture and session tracking from the comment form
<?php
// Prevent email capture and session tracking from the comment form
add_action( 'automatewoo_loaded', function() {
remove_action( 'comment_post', [ 'AutomateWoo\Session_Tracker', 'capture_from_comment' ] );
});
@danielbitzer
danielbitzer / functions.php
Last active September 14, 2022 11:13
[AutomateWoo] Update a queued workflow run date programatically
<?php
// Requires AW 4.3
// create date object
$date = new AutomateWoo\DateTime( '2018-07-23 06:12:04' );
// get the queued event by ID
$event = AutomateWoo\Queued_Event_Factory::get( $event_id );
$event->set_date_due( $date );
@danielbitzer
danielbitzer / functions.php
Created July 9, 2018 04:49
[AutomateWoo] Custom session tracking cookies permitted logic
<?php
/**
* Using this filter will completely override the value of 'Require cookie consent' in settings.
* Presubmit tracking is depending on session tracking so this filter will also control when presubmit tracking is permitted
* (unless presubmit tracking is completely disabled in settings).
*/
add_filter( 'automatewoo/session_tracking/cookies_permitted', 'my_filter_automatewoo_session_tracking_cookies_permitted' );
/**
@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' );
});