Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
555 B
1
Indexable
Never
add_filter( 'pws_has_free_shipping', 'nabik_pws_has_free_shipping', 10, 3 );

function nabik_pws_has_free_shipping( bool $has_free_shipping, array $package, PWS_Shipping_Method $method ): bool {

    foreach ( PWS_Cart::get_shipping_items() as $cart_item ) {

        /** @var WC_Product $product */
        $product = $cart_item['data'];

        if ( $product->is_on_sale() ) {
            return false;
        }

    }

    if ( count( $package['applied_coupons'] ) ) {
        return false;
    }

    return $has_free_shipping;
}
Leave a Comment