WC_Discounts::validate_coupon_excluded_product_ids( WC_Coupon $coupon )
Exclude products.
Description Description
Parameters Parameters
- $coupon
-
(Required) Coupon data.
Return Return
(bool)
Source Source
File: includes/class-wc-discounts.php
protected function validate_coupon_excluded_product_ids( $coupon ) { // Exclude Products. if ( count( $coupon->get_excluded_product_ids() ) > 0 ) { $products = array(); foreach ( $this->get_items_to_validate() as $item ) { if ( $item->product && in_array( $item->product->get_id(), $coupon->get_excluded_product_ids(), true ) || in_array( $item->product->get_parent_id(), $coupon->get_excluded_product_ids(), true ) ) { $products[] = $item->product->get_name(); } } if ( ! empty( $products ) ) { /* translators: %s: products list */ throw new Exception( sprintf( __( 'Sorry, this coupon is not applicable to the products: %s.', 'woocommerce' ), implode( ', ', $products ) ), 113 ); } } return true; }
Changelog Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |