<?php

if ( ! defined( 'ABSPATH' ) ) exit;

class W2W_Plugin_Compatibility {
	
	public function __construct() {
		
		// 适配WooCommerce Dynamic Pricing
		add_action( 'wp_loaded', array( $this, 'remove_wdp_on_cart_loaded_from_session' ), 1 );
	}
	
	public function remove_wdp_on_cart_loaded_from_session() {
		if( class_exists('WC_Dynamic_Pricing') && W2W()->is_in_miniprogram() ) {
			remove_action( 'woocommerce_cart_loaded_from_session', array( WC_Dynamic_Pricing::instance(), 'on_cart_loaded_from_session' ), 98, 1 );
		}
	}
}

$GLOBALS['w2w_plugin_compatibility'] = new W2W_Plugin_Compatibility();