Defer WooCommerce Transactional Emails

/** * This will turn on deferred transactional emails in WooCommerce. This may help if you * are experiencing slow checkouts or checkout timeouts. */ add_filter( ‘woocommerce_defer_transactional_emails’, ‘__return_true’ );Continue reading

Add shipping short description

function ts_add_description_field_to_shipping_method( $fields ) { $fields[‘short_description’] = array( ‘title’ => __( ‘Short Description’, ‘woocommerce’ ), ‘type’ => ‘textarea’, ‘description’ => __( ‘Add a short description for this shipping method.’, ‘woocommerce’ ), ‘default’ => ”, ‘desc_tip’ => true, ); return $fields;…Continue reading

Get coupons automatically

// Cron event add_action(‘init’, function () { if (!wp_next_scheduled(‘tune_hourly_coupon_import’)) { wp_schedule_event(time(), ‘hourly’, ‘tune_hourly_coupon_import’); } // Optional: manual trigger for testing if (isset($_GET[‘import_tune_coupons’]) && $_GET[‘import_tune_coupons’] === ‘1’) { tune_import_coupons_from_tune(); } }); add_action(‘tune_hourly_coupon_import’, ‘tune_import_coupons_from_tune’); function tune_import_coupons_from_tune() { if (!function_exists(‘wc_get_coupon_id_by_code’)) return; $network_token =…Continue reading

Sync manually created coupons

add_action(‘save_post_shop_coupon’, function($post_id, $post, $update) { if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) { return; } if ($post->post_type !== ‘shop_coupon’) { return; } if ($post->post_status !== ‘publish’ && $post->post_status !== ‘draft’ && $post->post_status !== ‘pending’) { return; } if (get_post_meta($post_id, ‘_tune_imported’, true)) { return;…Continue reading

Action Scheduler Log Retention

add_filter( ‘action_scheduler_default_cleaner_statuses’, function ( $statuses ) { $statuses[] = ‘failed’; return $statuses; } ); add_filter( ‘action_scheduler_retention_period’, ‘custom_action_scheduler_retention’ ); /** * Change Action Scheduler default purge to 1 day */ function custom_action_scheduler_retention() { return DAY_IN_SECONDS; // DAY_IN_SECONDS is a built-in WordPress…Continue reading