Flexible Product Add-Ons Free WooCommerce, by WP Desk
Add provided code to functions.php and update Settings.
Calculation option “Use prices modified by other plugins” must be ON.
System option “Suppress other pricing plugins in frontend” must be OFF.
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 63 64 65 66 67 68 |
<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } /** * Plugin Name: Flexible Product Fields * Plugin URI: https://wordpress.org/plugins/flexible-product-fields/ * Author: WP Desk * * Class WDP_WCFPF_Compatibility */ class WDP_WCFPF_Compatibility { const KEY = 'wc_flexible_product_fields'; const WDP_VERSION = '2.2.4'; const TARGET_VERSION = '1.2.8'; public function is_required() { return class_exists( 'Flexible_Product_Fields_Plugin' ); } public function admin_install() { } public function remove_admin_hooks() { } /** * @param WDP_Price_Display $price_display */ public function install( $price_display ) { add_filter( 'wdp_save_cart_item_keys', array( $this, 'wdp_save_cart_item_keys' ), 10, 1 ); add_filter( 'wdp_cart_item_data_before_apply', array( $this, 'wdp_cart_item_data_before_apply' ), 10, 2 ); add_filter( 'wdp_original_cart_item_data', array( $this, 'wdp_original_cart_item_data' ), 10, 1 ); } public function remove_hooks() { remove_filter( 'wdp_save_cart_item_keys', array( $this, 'wdp_save_cart_item_keys' ), 10 ); remove_filter( 'wdp_cart_item_data_before_apply', array( $this, 'wdp_cart_item_data_before_apply' ), 10 ); remove_filter( 'wdp_original_cart_item_data', array( $this, 'wdp_original_cart_item_data' ), 10 ); } public function wdp_save_cart_item_keys( $keys ) { $keys[] = 'flexible_product_fields'; return $keys; } public function wdp_cart_item_data_before_apply( $cart_item_data, $original_cart_item_data ) { if ( isset( $original_cart_item_data['flexible_product_fields'] ) ) { $cart_item_data['flexible_product_fields'] = $original_cart_item_data['flexible_product_fields']; } return $cart_item_data; } public function wdp_original_cart_item_data( $original_cart_item_data ) { unset( $original_cart_item_data['flexible_product_fields'] ); return $original_cart_item_data; } } $cmp = new WDP_WCFPF_Compatibility(); if ( $cmp->is_required() ) { $cmp->install( null ); } |