Automattic\WooCommerce\Internal\DataStores\Orders
OrdersTableDataStore::release_held_coupons
Release all coupons held by this order.
Метод класса: OrdersTableDataStore{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$OrdersTableDataStore = new OrdersTableDataStore(); $OrdersTableDataStore->release_held_coupons( $order, $save );
- $order(WC_Order) (обязательный)
- Current order object.
- $save(true|false)
- Whether to delete keys from DB right away. Could be useful to pass
falseif you are building a bulk request.
По умолчанию:true
Код OrdersTableDataStore::release_held_coupons() OrdersTableDataStore::release held coupons WC 10.9.4
public function release_held_coupons( $order, $save = true ) {
$coupon_held_keys = $this->get_coupon_held_keys( $order );
if ( is_array( $coupon_held_keys ) ) {
foreach ( $coupon_held_keys as $coupon_id => $meta_key ) {
$coupon = new \WC_Coupon( $coupon_id );
$coupon->delete_meta_data( $meta_key );
$coupon->save_meta_data();
}
}
$order->delete_meta_data( '_coupon_held_keys' );
$coupon_held_keys_for_users = $this->get_coupon_held_keys_for_users( $order );
if ( is_array( $coupon_held_keys_for_users ) ) {
foreach ( $coupon_held_keys_for_users as $coupon_id => $meta_key ) {
$coupon = new \WC_Coupon( $coupon_id );
$coupon->delete_meta_data( $meta_key );
$coupon->save_meta_data();
}
}
$order->delete_meta_data( '_coupon_held_keys_for_users' );
if ( $save ) {
$order->save_meta_data();
}
}