kreamweb
10/26/2016 - 12:19 PM

fix per far funzionare insieme woocommerce smart coupon, e e dynamic pricing

fix per far funzionare insieme woocommerce smart coupon, e e dynamic pricing

if( function_exists('YITH_WC_Dynamic_Pricing_Frontend') && class_exists( 'WC_Smart_Coupons' ) ){
	function ywdpd_call_for_credit_form(){

		global $product, $woocommerce, $woocommerce_smart_coupon;
		if ( $product instanceof WC_Product_Variation ) return;

		$coupons = get_post_meta( $product->id, '_coupon_title', true );

		remove_filter( 'woocommerce_get_price', array( YITH_WC_Dynamic_Pricing_Frontend(), 'get_price' ), 10, 2 );
		if ( !(!empty( $coupons ) && $woocommerce_smart_coupon->is_coupon_amount_pick_from_product_price( $coupons ) && ( !( $product->get_price() != '' || ( is_plugin_active( 'woocommerce-name-your-price/woocommerce-name-your-price.php' ) && ( get_post_meta( $product->id, '_nyp', true ) == 'yes' ) ) ) ) ) ) {
			add_filter( 'woocommerce_get_price', array( YITH_WC_Dynamic_Pricing_Frontend(), 'get_price' ), 10, 2 );
		}
	}

	add_action( 'woocommerce_single_product_summary', 'ywdpd_call_for_credit_form', 9 );
}