Skip to content

Instantly share code, notes, and snippets.

@gdarko
Last active March 22, 2023 09:21
Show Gist options
  • Save gdarko/496a3d378353c4d08e6ab8bd5996f523 to your computer and use it in GitHub Desktop.
Save gdarko/496a3d378353c4d08e6ab8bd5996f523 to your computer and use it in GitHub Desktop.
Move the licenses table above order details in the WooCommerce order email. Simply drop this in your plugins (or mu-plugins) directory or even add the snippet in your functions.php starting from line 13.
<?php
/**
* Plugin Name: DLM Emails Move Licenses On-Top
* Description: Move the licenses table above order details in the WooCommerce order email
* Author: Darko Gjorgjijoski
* Version: 1.0.0
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
class DLM_Emails_Move_Licenses_Table_OnTop {
/**
* Constructor
*/
public function __construct() {
add_action( 'dlm_init', [$this, 'on_init'] );
}
/**
* Reorganizes the emails, moves "Your License(s)" section above order details table.
*
* @note Requires Digital License Manager (Core) 1.4.2 and onwards.
*
* @param \IdeoLogix\DigitalLicenseManager\Boot $plugin
*
* @return void
*/
public function on_init( $plugin ) {
if( empty( $plugin ) ) {
// Not using Core 1.4.2 or onwards.
return;
}
remove_action( 'woocommerce_email_after_order_table', [ $plugin->woocommerce->emails, 'afterOrderTable' ], 10 );
add_action( 'woocommerce_email_before_order_table', [ $plugin->woocommerce->emails, 'afterOrderTable' ], 10, 4 );
}
}
new DLM_Emails_Move_Licenses_Table_OnTop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment