apache
wp-content
mu-plugins
plugins
activitypub
audioigniter
authldap
companion-auto-update
easy-digital-downloads
assets
includes
adjustments
admin
api
blocks
cart
checkout
compat
currency
customers
database
downloads
emails
extensions
gateways
libraries
logs
models
notes
orders
classes
functions
actions.php
addresses.php
adjustments.php
items.php
meta.php
orders.php
refunds.php
statuses.php
transactions.php
transitions.php
types.php
ui.php
payments
reports
traits
users
utils
EDD_SL_Plugin_Updater.php
actions.php
ajax-functions.php
class-base-object.php
class-component.php
class-easy-digital-downloads.php
class-edd-cache-helper.php
class-edd-cli.php
class-edd-cron.php
class-edd-customer-query.php
class-edd-customer.php
class-edd-db-customer-meta.php
class-edd-db-customers.php
class-edd-db.php
class-edd-discount.php
class-edd-download.php
class-edd-fees.php
class-edd-html-elements.php
class-edd-license-handler.php
class-edd-logging.php
class-edd-register-meta.php
class-edd-requirements-check.php
class-edd-roles.php
class-edd-session.php
class-edd-stats.php
class-stats.php
class-structured-data.php
class-utilities.php
compat-functions.php
component-functions.php
country-functions.php
customer-functions.php
date-functions.php
deprecated-functions.php
deprecated-hooks.php
discount-functions.php
download-functions.php
error-tracking.php
formatting.php
install.php
interface-edd-exception.php
mime-types.php
misc-functions.php
plugin-compatibility.php
post-types.php
privacy-functions.php
process-download.php
process-purchase.php
query-filters.php
refund-functions.php
scripts.php
shortcodes.php
tax-functions.php
template-actions.php
template-functions.php
theme-compatibility.php
user-functions.php
widgets.php
languages
src
templates
vendor
easy-digital-downloads.php
license.txt
readme.txt
uninstall.php
gitium
gp-premium
jetpack-protect
menu-icons
simple-local-avatars
smtp-mailer
two-factor
wp-piwik
wp-webauthn
index.php
themes
index.php
.dbsetup
.gitignore
htaccess
php.ini
57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* Order Transition Functions.
|
|
*
|
|
* @package EDD
|
|
* @subpackage Orders
|
|
* @copyright Copyright (c) 2022, Easy Digital Downloads
|
|
* @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
|
|
* @since 3.0
|
|
*/
|
|
|
|
/**
|
|
* Record order status change
|
|
*
|
|
* @since 3.0
|
|
* @param string $old_status the status of the order prior to this change.
|
|
* @param string $new_status The new order status.
|
|
* @param int $order_id the ID number of the order.
|
|
* @return void
|
|
*/
|
|
function edd_record_order_status_change( $old_status, $new_status, $order_id ) {
|
|
|
|
// Get the list of statuses so that status in the payment note can be translated.
|
|
$stati = edd_get_payment_statuses();
|
|
$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
|
|
$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
|
|
|
|
$status_change = sprintf(
|
|
/* translators: %1$s Old order status. %2$s New order status. */
|
|
__( 'Status changed from %1$s to %2$s', 'easy-digital-downloads' ),
|
|
$old_status,
|
|
$new_status
|
|
);
|
|
|
|
edd_insert_payment_note( $order_id, $status_change );
|
|
}
|
|
add_action( 'edd_transition_order_status', 'edd_record_order_status_change', 100, 3 );
|
|
|
|
/**
|
|
* Triggers `edd_update_payment_status` hook when an order status changes
|
|
* for backwards compatibility.
|
|
*
|
|
* @since 3.0
|
|
* @param string $old_status the status of the order prior to this change.
|
|
* @param string $new_status The new order status.
|
|
* @param int $order_id the ID number of the order.
|
|
* @return void
|
|
*/
|
|
add_action( 'edd_transition_order_status', function( $old_status, $new_status, $order_id ) {
|
|
// Trigger the payment status action hook for backwards compatibility.
|
|
do_action( 'edd_update_payment_status', $order_id, $new_status, $old_status );
|
|
if ( 'complete' === $old_status ) {
|
|
// Trigger the action again to account for add-ons listening for status changes from "publish".
|
|
do_action( 'edd_update_payment_status', $order_id, $new_status, 'publish' );
|
|
}
|
|
}, 10, 3 );
|