@@ -163,37 +163,60 @@ Total $203.50
163163
164164#### Filters
165165
166- ```
167- // Modify calculated fee amount
168- add_filter( 'cfwc_calculated_fee', function( $fee, $product, $rule ) {
169- // Custom fee logic
166+ ``` php
167+ // Modify all calculated fees before they're applied
168+ add_filter( 'cfwc_calculated_fees', function( $fees, $destination_country, $cart ) {
169+ // Modify fees array
170+ return $fees;
171+ }, 10, 3 );
172+
173+ // Modify a single fee calculation
174+ add_filter( 'cfwc_calculated_single_fee', function( $fee, $rule, $total ) {
175+ // Apply 50% discount for orders over $1000
176+ if ( WC()->cart->subtotal > 1000 ) {
177+ $fee = $fee * 0.5;
178+ }
170179 return $fee;
171180}, 10, 3 );
172181
173- // Customize fee label
174- add_filter( 'cfwc_fee_label', function( $label, $rule ) {
182+ // Customize fee label displayed at checkout
183+ add_filter( 'cfwc_fee_label', function( $label, $rule, $country, $origin ) {
175184 return $label . ' (Estimated)';
176- }, 10, 2 );
185+ }, 10, 4 );
177186
178- // Override product origin
179- add_filter( 'cfwc_product_origin', function( $origin, $product_id ) {
180- // Custom origin logic
187+ // Override product origin country
188+ add_filter( 'cfwc_product_origin', function( $origin, $product_id, $product ) {
189+ // Force all electronics to use CN origin
190+ if ( has_term( 'electronics', 'product_cat', $product_id ) ) {
191+ return 'CN';
192+ }
181193 return $origin;
182- }, 10, 2 );
194+ }, 10, 3 );
195+
196+ // Modify customs value (for CIF calculations)
197+ add_filter( 'cfwc_customs_value', function( $customs_value, $line_total, $cart_item, $method ) {
198+ // Force FOB for US/Canada even if CIF is enabled
199+ $destination = WC()->customer->get_shipping_country();
200+ if ( in_array( $destination, array( 'US', 'CA' ), true ) ) {
201+ return $line_total;
202+ }
203+ return $customs_value;
204+ }, 10, 4 );
205+
206+ // Provide insurance value for CIF calculations
207+ add_filter( 'cfwc_insurance_value', function( $insurance_value, $product_value, $method ) {
208+ // Add 2% insurance to all products
209+ return $product_value * 0.02;
210+ }, 10, 3 );
183211```
184212
185213#### Actions
186214
187- ```
188- // After fees are calculated
189- add_action( 'cfwc_after_calculate_fees', function( $fees, $cart ) {
190- // Log or process calculated fees
191- }, 10, 2 );
192-
193- // After rule is saved
194- add_action( 'cfwc_rule_saved', function( $rule_id, $rule_data ) {
195- // Sync with external system
196- }, 10, 2 );
215+ ``` php
216+ // After cache is cleared
217+ add_action( 'cfwc_cache_cleared', function() {
218+ // Perform cleanup or sync
219+ } );
197220```
198221
199222### Database schema
@@ -223,24 +246,31 @@ CREATE TABLE {prefix}cfwc_rules (
223246
224247### With Multi-Currency Plugins
225248
226- ```
227- // Fees automatically convert to displayed currency
228- add_filter('cfwc_fee_amount ', function($amount ) {
229- if (function_exists('convert_to_current_currency') ) {
230- return convert_to_current_currency($amount );
249+ ``` php
250+ // Modify calculated fees for currency conversion
251+ add_filter( 'cfwc_calculated_single_fee ', function( $fee, $rule, $total ) {
252+ if ( function_exists( 'convert_to_current_currency' ) ) {
253+ return convert_to_current_currency( $fee );
231254 }
232- return $amount ;
233- });
255+ return $fee ;
256+ }, 10, 3 );
234257```
235258
236- ### With Shipping Plugins
259+ ### With Third-Party Insurance Plugins
237260
238- ```
239- // Combine with shipping calculations
240- add_action('woocommerce_shipping_calculated', function() {
241- // Recalculate customs based on shipping destination
242- WC()->cart->calculate_fees();
243- });
261+ ``` php
262+ // Integrate shipping insurance with CIF customs calculations
263+ add_filter( 'cfwc_insurance_value', function( $insurance_value, $product_value, $method ) {
264+ if ( function_exists( 'get_cart_insurance_amount' ) ) {
265+ $total_insurance = get_cart_insurance_amount();
266+ $cart_subtotal = WC()->cart->get_cart_contents_total();
267+
268+ if ( $cart_subtotal > 0 ) {
269+ return ( $product_value / $cart_subtotal ) * $total_insurance;
270+ }
271+ }
272+ return $insurance_value;
273+ }, 10, 3 );
244274```
245275
246276## Performance
@@ -314,6 +344,29 @@ GNU General Public License for more details.
314344
315345## Changelog
316346
347+ ### Version 1.1.4 - January 2026
348+
349+ ** New Feature: CIF Customs Valuation**
350+
351+ - Added support for CIF (Cost, Insurance, Freight) customs valuation method.
352+ - New setting to choose between FOB (product value only) and CIF (product + shipping) calculation methods.
353+ - Shipping costs are proportionally distributed across products when CIF is enabled.
354+ - Added ` cfwc_customs_value ` filter to customize customs value calculations.
355+ - Added ` cfwc_insurance_value ` filter for third-party insurance plugin integration.
356+ - Added ` cfwc_fee_label ` filter to customize fee labels at checkout.
357+ - Added ` cfwc_product_origin ` filter to override product origin programmatically.
358+
359+ ** Improvements**
360+
361+ - Made "Setup Status" notice on settings page dismissible.
362+ - Improved code quality with PHPCS and PHPStan compliance.
363+
364+ ** Developer Notes**
365+
366+ - CIF is an opt-in feature; default behavior (FOB) remains unchanged.
367+ - Existing orders and rules are not affected.
368+ - Virtual/downloadable products are automatically excluded from CIF calculations.
369+
317370### Version 1.1.3 - December 2025
318371
319372- Added new setting to calculate customs fees on original price (before discounts).
0 commit comments