WC_Coupon_Data_Store_CPT::increase_usage_count()
Increase usage count for current coupon.
Метод класса: WC_Coupon_Data_Store_CPT{}
Хуки из метода
Возвращает
int
. New usage count.
Использование
$WC_Coupon_Data_Store_CPT = new WC_Coupon_Data_Store_CPT(); $WC_Coupon_Data_Store_CPT->increase_usage_count( $coupon, $used_by, $order );
- $coupon(WC_Coupon) (обязательный) (передается по ссылке — &)
- Coupon object.
- $used_by(строка)
- Either user ID or billing email.
По умолчанию: '' - $order(WC_Order)
- (Optional) If passed, clears the hold record associated with order.
По умолчанию: null
Список изменений
С версии 3.0.0 | Введена. |
Код WC_Coupon_Data_Store_CPT::increase_usage_count() WC Coupon Data Store CPT::increase usage count WC 8.7.0
public function increase_usage_count( &$coupon, $used_by = '', $order = null ) { $coupon_held_key_for_user = ''; if ( $order instanceof WC_Order ) { $coupon_held_key_for_user = $order->get_data_store()->get_coupon_held_keys_for_users( $order, $coupon->get_id() ); } $new_count = $this->update_usage_count_meta( $coupon, 'increase' ); if ( $used_by ) { $this->add_coupon_used_by( $coupon, $used_by, $coupon_held_key_for_user ); $coupon->set_used_by( (array) get_post_meta( $coupon->get_id(), '_used_by' ) ); } do_action( 'woocommerce_increase_coupon_usage_count', $coupon, $new_count, $used_by ); return $new_count; }