Issues (4138)

includes/functions/woocommerce.php (24 issues)

1
<?php
2
/**
3
 * LSX Health Plan WooCommerce functions.
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
namespace lsx_health_plan\functions\woocommerce;
9
10
/**
11
 * Returns true or false if the plan has products.
12
 *
13
 * @return boolean
14
 */
15
function plan_has_products() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
16
	$lsx_hp       = lsx_health_plan();
17
	$has_products = false;
18
	if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
19
		$has_products = true;
20
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
21
	return $has_products;
22
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
23
24
/**
25
 * Returns product ids attached in an array.
26
 *
27
 * @return array
28
 */
29
function get_plan_products() {
30
	$lsx_hp       = lsx_health_plan();
31
	$has_products = array();
32
	if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
33
		$has_products = $lsx_hp->integrations->woocommerce->plans->product_ids;
34
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
35
	return $has_products;
36
}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
37
38
/**
39
 * Returns the product IDS of your memberships
40
 *
41
 * @return array
42
 */
43
function get_membership_products() {
44
	$product_ids = array();
45
	if ( function_exists( 'wc_memberships_get_user_memberships' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
46
		$user_memberships = wc_memberships_get_user_memberships();
47
48
		if ( ! empty( $user_memberships ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
49
			foreach ( $user_memberships as $membership ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
50
				$current_products = $membership->plan->get_product_ids();
51
				if ( ! empty( $current_products ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
52
					$product_ids = array_merge( $product_ids, $current_products );
53
				}
54
			}
55
		}
56
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
57
	if ( ! empty( $product_ids ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
58
		$product_ids = array_unique( $product_ids );
59
	}
0 ignored issues
show
No blank line found after control structure
Loading history...
60
	return $product_ids;
61
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
62