mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-17 14:52:56 +00:00
2.6.1
This commit is contained in:

committed by
Remco Tolsma

parent
42964bef17
commit
a60db3815d
@@ -534,3 +534,36 @@ function wcs_doing_cron() {
|
||||
function wcs_doing_ajax() {
|
||||
return function_exists( 'wp_doing_ajax' ) ? wp_doing_ajax() : defined( 'DOING_AJAX' ) && DOING_AJAX;
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper function for getting an order's used coupon codes.
|
||||
*
|
||||
* WC 3.7 deprecated @see WC_Abstract_Order::get_used_coupons() in favour of WC_Abstract_Order::get_coupon_codes().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param WC_Abstract_Order $order An order or subscription object to get the coupon codes for.
|
||||
* @return array The coupon codes applied to the $order.
|
||||
*/
|
||||
function wcs_get_used_coupon_codes( $order ) {
|
||||
return is_callable( array( $order, 'get_coupon_codes' ) ) ? $order->get_coupon_codes() : $order->get_used_coupons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a function callback for a certain WooCommerce versions.
|
||||
*
|
||||
* Enables attaching a callback if WooCommerce is before, after, equal or not equal to a given version.
|
||||
* This function is a wrapper for @see WCS_Dependent_Hook_Manager::add_woocommerce_dependent_action().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $tag The action or filter tag to attach the callback too.
|
||||
* @param string|array $function The callable function to attach to the hook.
|
||||
* @param string $woocommerce_version The WooCommerce version to do a compare on. For example '3.0.0'.
|
||||
* @param string $operator The version compare operator to use. @see https://www.php.net/manual/en/function.version-compare.php
|
||||
* @param integer $priority The priority to attach this callback to.
|
||||
* @param integer $number_of_args The number of arguments to pass to the callback function
|
||||
*/
|
||||
function wcs_add_woocommerce_dependent_action( $tag, $function, $woocommerce_version, $operator, $priority = 10, $number_of_args = 1 ) {
|
||||
WCS_Dependent_Hook_Manager::add_woocommerce_dependent_action( $tag, $function, $woocommerce_version, $operator, $priority, $number_of_args );
|
||||
}
|
||||
|
Reference in New Issue
Block a user