Skip to content

Commit

Permalink
update: doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mralaminahamed committed Jan 10, 2025
1 parent fd5671e commit 7ee67f5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions includes/Order/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
namespace WeDevs\Dokan\Order;

use Exception;
use WC_Coupon;
use WC_Discounts;
use WC_Order;
use WC_Product;

// don't call the file directly
if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -409,19 +412,19 @@ public function split_vendor_orders( $parent_order_id ) {
*
* @since DOKAN_SINCE Refactored to make it more flexible, and added filter
*
* @param boolean $valid Whether the coupon is currently considered valid.
* @param \WC_Coupon $coupon The coupon object being validated.
* @param \WC_Discounts $discount The discount object containing cart/order items being validated.
* @param boolean $valid Whether the coupon is currently considered valid.
* @param WC_Coupon $coupon The coupon object being validated.
* @param WC_Discounts $discounts The discount object containing cart/order items being validated.
*
* @return boolean True if the coupon is valid, false otherwise
* @throws \Exception When the coupon is invalid for multiple vendors
* @throws Exception When the coupon is invalid for multiple vendors
*/
public function ensure_is_coupon_valid( $valid, $coupon, $discount ) {
public function ensure_is_coupon_valid( bool $valid, WC_Coupon $coupon, WC_Discounts $discounts ): bool {
$available_vendors = [];
$available_products = [];

foreach ( $discount->get_items() as $item ) {
if ( ! isset( $item->product ) || ! $item->product instanceof \WC_Product ) {
foreach ( $discounts->get_items() as $item ) {
if ( ! isset( $item->product ) || ! $item->product instanceof WC_Product ) {
continue;
}

Expand All @@ -442,13 +445,13 @@ public function ensure_is_coupon_valid( $valid, $coupon, $discount ) {
*
* @since DOKAN_SINCE
*
* @param boolean $valid The validity of the coupon.
* @param \WC_Coupon $coupon The coupon object.
* @param array $available_vendors List of available vendors.
* @param array $available_products List of available products.
* @param \WC_Discounts $discount The discount object, which contains the order details.
* @param boolean $valid The validity of the coupon.
* @param WC_Coupon $coupon The coupon object.
* @param array $available_vendors List of available vendors.
* @param array $available_products List of available products.
* @param WC_Discounts $discounts The discount object, which contains the order details.
*/
if ( apply_filters( 'dokan_coupon_is_valid', $valid, $coupon, $available_vendors, $available_products, $discount ) ) {
if ( apply_filters( 'dokan_coupon_is_valid', $valid, $coupon, $available_vendors, $available_products, $discounts ) ) {
return true;
}

Expand Down

0 comments on commit 7ee67f5

Please sign in to comment.