Completed
Pull Request — master (#1383)
by
unknown
02:00
created

WC_Helper_Shipping::delete_simple_flat_rate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Shipping helpers.
4
 *
5
 * @package WooCommerce/Tests
6
 */
7
8
/**
9
 * Class WC_Helper_Shipping.
10
 *
11
 * This helper class should ONLY be used for unit tests!.
12
 */
13
class WC_Helper_Shipping {
14
15
	/**
16
	 * Create a simple flat rate at the cost of 10.
17
	 *
18
	 * @since 2.3
19
	 */
20
	public static function create_simple_flat_rate() {
21
		$flat_rate_settings = [
22
			'enabled'      => 'yes',
23
			'title'        => 'Flat rate',
24
			'availability' => 'all',
25
			'countries'    => '',
26
			'tax_status'   => 'taxable',
27
			'cost'         => '10',
28
		];
29
30
		update_option( 'woocommerce_flat_rate_settings', $flat_rate_settings );
31
		update_option( 'woocommerce_flat_rate', [] );
32
		WC_Cache_Helper::get_transient_version( 'shipping', true );
33
		WC()->shipping()->load_shipping_methods();
34
	}
35
36
	/**
37
	 * Delete the simple flat rate.
38
	 *
39
	 * @since 2.3
40
	 */
41
	public static function delete_simple_flat_rate() {
42
		delete_option( 'woocommerce_flat_rate_settings' );
43
		delete_option( 'woocommerce_flat_rate' );
44
		WC_Cache_Helper::get_transient_version( 'shipping', true );
45
		WC()->shipping()->unregister_shipping_methods();
46
	}
47
}
48