-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiconic-woo-delivery-slots-compat-flat-rate-shipping.php
62 lines (53 loc) · 1.86 KB
/
iconic-woo-delivery-slots-compat-flat-rate-shipping.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Plugin Name: WooCommerce Delivery Slots by Iconic [Flat Rate Shipping Plugin For WooCommerce]
* Plugin URI: https://iconicwp.com/products/woocommerce-delivery-slots/
* Description: Compatibility between WooCommerce Delivery Slots by Iconic and Flat Rate Shipping Plugin For WooCommerce by theDotstore.
* Author: Iconic
* Author URI: https://iconicwp.com/
* Text Domain: iconic-woo-delivery-slots-compat-flat-rate-shipping
* Domain Path: /languages
* Version: 0.1.0
*
* @package Iconic_Woo_Delivery_Slots_Compat_Flat_rate_shipping
*/
/**
* Is Flat Rate Shipping Plugin For WooCommerce active?
*
* @return bool
*/
function iconic_compat_frs_is_active() {
return defined( 'AFRSM_PRO_PREMIUM_VERSION' ) || defined( 'AFRSM_PLUGIN_VERSION' );
}
/**
* Remove default options.
*
* @return array
*/
function iconic_compat_frs_remove_default_shipping_method_options( $shipping_method_options ) {
if ( ! iconic_compat_frs_is_active() ) {
return $shipping_method_options;
}
$sm_args = array(
'post_type' => 'wc_afrsm',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'suppress_filters' => false,
);
$shipping_methods = get_posts( $sm_args );
foreach ( $shipping_methods as $shipping_method ) {
$id = sprintf( 'advanced_flat_rate_shipping:%d', $shipping_method->ID );
$title = sprintf( 'Advanced Flat Rate Shipping: %s', get_the_title( $shipping_method->ID ) );
$shipping_method_options[ $id ] = $title;
}
return $shipping_method_options;
}
add_filter( 'iconic_wds_shipping_method_options', 'iconic_compat_frs_remove_default_shipping_method_options', 10 );
/**
* Activate the plugin.
*/
function iconic_compat_frs_activate() {
delete_transient( 'iconic-wds-shipping-methods' );
}
register_activation_hook( __FILE__, 'iconic_compat_frs_activate' );