Merge pull request #23689 from woocommerce/add/get_used_coupon_codes
Deprecate get_used_coupons in favor of get_coupon_codes
This commit is contained in:
commit
30ce9ff6a3
|
@ -781,11 +781,12 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get coupon codes only.
|
* Get used coupon codes only.
|
||||||
*
|
*
|
||||||
|
* @since 3.7.0
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_used_coupons() {
|
public function get_coupon_codes() {
|
||||||
$coupon_codes = array();
|
$coupon_codes = array();
|
||||||
$coupons = $this->get_items( 'coupon' );
|
$coupons = $this->get_items( 'coupon' );
|
||||||
|
|
||||||
|
|
|
@ -598,6 +598,17 @@ abstract class WC_Abstract_Legacy_Order extends WC_Data {
|
||||||
return $item_meta_array;
|
return $item_meta_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get coupon codes only.
|
||||||
|
*
|
||||||
|
* @deprecated 3.7.0 - Replaced with better named method to reflect the actual data being returned.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_used_coupons() {
|
||||||
|
wc_deprecated_function( 'get_used_coupons', '3.7', 'WC_Abstract_Order::get_coupon_codes' );
|
||||||
|
return $this->get_coupon_codes();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand item meta into the $item array.
|
* Expand item meta into the $item array.
|
||||||
* @deprecated 3.0.0 Item meta no longer expanded due to new order item
|
* @deprecated 3.0.0 Item meta no longer expanded due to new order item
|
||||||
|
|
|
@ -854,8 +854,8 @@ function wc_update_coupon_usage_counts( $order_id ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count( $order->get_used_coupons() ) > 0 ) {
|
if ( count( $order->get_coupon_codes() ) > 0 ) {
|
||||||
foreach ( $order->get_used_coupons() as $code ) {
|
foreach ( $order->get_coupon_codes() as $code ) {
|
||||||
if ( ! $code ) {
|
if ( ! $code ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,9 +470,9 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test: get_used_coupons
|
* Test: get_coupon_codes
|
||||||
*/
|
*/
|
||||||
public function test_get_used_coupons() {
|
public function test_get_coupon_codes() {
|
||||||
$object = new WC_Order();
|
$object = new WC_Order();
|
||||||
$item = new WC_Order_Item_Coupon();
|
$item = new WC_Order_Item_Coupon();
|
||||||
$item->set_props(
|
$item->set_props(
|
||||||
|
@ -484,7 +484,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
||||||
);
|
);
|
||||||
$object->add_item( $item );
|
$object->add_item( $item );
|
||||||
$object->save();
|
$object->save();
|
||||||
$this->assertCount( 1, $object->get_used_coupons() );
|
$this->assertCount( 1, $object->get_coupon_codes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue