Changeset 3759367
- Timestamp:
- 10/22/2026 06:01:08 AM (5 weeks ago)
- Location:
- woocommerce-product-addon
- Files:
-
- 36 edited
- 1 copied
-
tags/34.0.12 (copied) (copied from woocommerce-product-addon/trunk )
-
tags/34.0.12/CHANGELOG.md (modified) (1 diff)
-
tags/34.0.12/classes/frontend-scripts.class.php (modified) (2 diffs)
-
tags/34.0.12/classes/plugin.class.php (modified) (2 diffs)
-
tags/34.0.12/readme.txt (modified) (2 diffs)
-
tags/34.0.12/src/Arrays/Settings.php (modified) (1 diff)
-
tags/34.0.12/src/Pricing/Engine.php (modified) (8 diffs)
-
tags/34.0.12/src/Pricing/ModernCartFeeApplicator.php (modified) (2 diffs)
-
tags/34.0.12/src/Support/Helpers.php (modified) (11 diffs)
-
tags/34.0.12/src/WooCommerce/Cart/CartHandler.php (modified) (6 diffs)
-
tags/34.0.12/src/WooCommerce/Order/OrderHandler.php (modified) (3 diffs)
-
tags/34.0.12/src/WooCommerce/Product/ProductHandler.php (modified) (1 diff)
-
tags/34.0.12/vendor/codeinwp/themeisle-sdk/load.php (modified) (1 diff)
-
tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Loader.php (modified) (1 diff)
-
tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php (modified) (2 diffs)
-
tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Modules/Crash_reporter.php (modified) (3 diffs)
-
tags/34.0.12/vendor/composer/installed.json (modified) (3 diffs)
-
tags/34.0.12/vendor/composer/installed.php (modified) (3 diffs)
-
tags/34.0.12/woocommerce-product-addon.php (modified) (2 diffs)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/classes/frontend-scripts.class.php (modified) (2 diffs)
-
trunk/classes/plugin.class.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Arrays/Settings.php (modified) (1 diff)
-
trunk/src/Pricing/Engine.php (modified) (8 diffs)
-
trunk/src/Pricing/ModernCartFeeApplicator.php (modified) (2 diffs)
-
trunk/src/Support/Helpers.php (modified) (11 diffs)
-
trunk/src/WooCommerce/Cart/CartHandler.php (modified) (6 diffs)
-
trunk/src/WooCommerce/Order/OrderHandler.php (modified) (3 diffs)
-
trunk/src/WooCommerce/Product/ProductHandler.php (modified) (1 diff)
-
trunk/vendor/codeinwp/themeisle-sdk/load.php (modified) (1 diff)
-
trunk/vendor/codeinwp/themeisle-sdk/src/Loader.php (modified) (1 diff)
-
trunk/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php (modified) (2 diffs)
-
trunk/vendor/codeinwp/themeisle-sdk/src/Modules/Crash_reporter.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.json (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (3 diffs)
-
trunk/woocommerce-product-addon.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-product-addon/tags/34.0.12/CHANGELOG.md
r3733313 r3759367 1 ##### [Version 34.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.11...v34.0.12) (2026-10-22) 2 3 - Fixed the PPOM price summary showing the product price in the wrong currency 4 - Fixed cart option prices showing unconverted in secondary WCML currencies. 5 - Fixed identical linked-quantity products merging into one cart line 6 - Updated dependencies 7 1 8 ##### [Version 34.0.11](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.10...v34.0.11) (2026-10-07) 2 9 -
woocommerce-product-addon/tags/34.0.12/classes/frontend-scripts.class.php
r3733313 r3759367 300 300 301 301 $product = wc_get_product( $product_id ); 302 if ( ! $product instanceof WC_Product ) { 303 return ''; 304 } 302 305 303 306 $ppom = new PPOM_Meta( $product_id ); … … 577 580 $input_js_vars['field_meta'] = $inputs_meta_updated; 578 581 $input_js_vars['wc_no_decimal'] = $decimal_palces; 579 $input_js_vars['wc_product_price'] = ppom_get_product_price( $product, '', 'product');582 $input_js_vars['wc_product_price'] = \PPOM\Support\Helpers::get_product_display_price( $product ); 580 583 $input_js_vars['wc_product_regular_price'] = ppom_get_product_regular_price( $product ); 581 584 $input_js_vars['product_title'] = $product->get_title(); -
woocommerce-product-addon/tags/34.0.12/classes/plugin.class.php
r3733313 r3759367 920 920 921 921 /** 922 * Register the core ppom_option_price conversion hook only when PPOM Pro 923 * has not already registered ppom_hooks_convert_price on the same filter. 922 * Register the core ppom_option_price conversion hook and the WCML cart row 923 * pass only when PPOM Pro has not already registered ppom_hooks_convert_price 924 * on the same filter. Running Pro registers both conversions itself. 924 925 * 925 926 * Called from __construct() on woocommerce_init — after every plugin has … … 933 934 if ( ! has_filter( 'ppom_option_price', 'ppom_hooks_convert_price' ) ) { 934 935 add_filter( 'ppom_option_price', array( $this, 'ppom_convert_price' ), 99, 1 ); 935 } 936 add_filter( 'ppom_fields_prices', array( $this, 'convert_cart_rows_wcml' ), 10, 1 ); 937 } 938 } 939 940 /** 941 * Convert cart charge rows to the WCML client currency. 942 * 943 * WCML converts the product price when its meta is read, not the cart line, 944 * so option rows must be converted to match the base. One-time fees are 945 * converted when the fee is added, and percent rows are already a share of 946 * the converted base. 947 * 948 * @param array<int, array<string, mixed>> $field_prices Charge rows from Engine::get_field_prices(). 949 * @return array<int, array<string, mixed>> 950 */ 951 public function convert_cart_rows_wcml( $field_prices ) { 952 foreach ( $field_prices as $index => $row ) { 953 if ( ! isset( $row['price'] ) || 'cart_fee' === ( $row['apply'] ?? '' ) || ! empty( $row['is_percent'] ) ) { 954 continue; 955 } 956 $field_prices[ $index ]['price'] = \PPOM\Support\Helpers::convert_to_wcml_line_currency( $row['price'] ); 957 } 958 959 return $field_prices; 936 960 } 937 961 -
woocommerce-product-addon/tags/34.0.12/readme.txt
r3733313 r3759367 4 4 Requires at least: 6.2 5 5 Tested up to: 7.1 6 Stable tag: 34.0.1 16 Stable tag: 34.0.12 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 260 260 == Changelog == 261 261 262 ##### [Version 34.0.11](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.10...v34.0.11) (2026-10-07) 263 264 - Fixed SVG uploads failing in File upload fields 265 - Fixed the first product-page price to use the visible conditional price matrix. 266 - Fixed conditional fields to respond only to selections in their own product form. 267 - Fixed modern pricing to honor zero-price matrix selections 268 - Fixed the file picker for upload fields with hyphenated names. 269 - Fixed PPOM applying currency exchange rates twice to priced options and cart totals. 270 - Fixed PPOM Pro converting WPML cart option charges twice. 271 - Fixed currency switchers converting PPOM option prices more than once. 272 - Fixed file uploads allowing visitors to delete files outside uploads folder. 262 ##### [Version 34.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.11...v34.0.12) (2026-10-22) 263 264 - Fixed the PPOM price summary showing the product price in the wrong currency 265 - Fixed cart option prices showing unconverted in secondary WCML currencies. 266 - Fixed identical linked-quantity products merging into one cart line 273 267 - Updated dependencies 274 268 -
woocommerce-product-addon/tags/34.0.12/src/Arrays/Settings.php
r3733313 r3759367 644 644 $js_vars['wc_decimal_sep'] = get_option( 'woocommerce_price_decimal_sep' ); 645 645 $js_vars['wc_no_decimal'] = $decimal_palces; 646 $variation_id = ''; 647 $context = 'product'; 648 $js_vars['wc_product_price'] = Helpers::get_product_price( $product, $variation_id, $context ); 646 $js_vars['wc_product_price'] = Helpers::get_product_display_price( $product ); 649 647 $js_vars['wc_product_regular_price'] = Helpers::get_product_regular_price( $product ); 650 648 $ppom_label_discount_price = Helpers::get_option( 'ppom_label_discount_price', __( 'Discount Price', 'woocommerce-product-addon' ) ); -
woocommerce-product-addon/tags/34.0.12/src/Pricing/Engine.php
r3733313 r3759367 20 20 */ 21 21 final class Engine { 22 23 /** 24 * Field types whose options can be priced as a percentage of the product price. 25 * 26 * @var list<'select'|'radio'|'checkbox'|'multiple_select'|'cropper'|'palettes'|'imageselect'|'image'|'audio'> 27 */ 28 private const PERCENT_PRICED_FIELD_TYPES = array( 'select', 'radio', 'checkbox', 'multiple_select', 'cropper', 'palettes', 'imageselect', 'image', 'audio' ); 22 29 23 30 /** … … 296 303 * @param array<string, mixed>|null $item Cart item context. 297 304 * 298 * @return array< string, mixed>305 * @return array<int, array<string, mixed>> 299 306 * 300 307 * @see Helpers::get_field_meta_by_dataname() … … 968 975 $without_tax = isset( $option['without_tax'] ) ? $option['without_tax'] : ''; 969 976 970 // Charge rows stay in store currency: the switcher converts the cart line on read971 // and Pro's WPML pass converts these rows itself. Only the label is display (#755).977 // Charge rows stay in store currency: switchers convert the cart line on read, and 978 // the WCML pass on ppom_fields_prices converts the rows. Only the label is converted here. 972 979 $label_price = "{$field_title} - " . wc_price( apply_filters( 'ppom_option_price', $field_price ) ); 973 980 // For bulkquantity … … 995 1002 'quantity' => $qty, 996 1003 'base_price' => $base_price, 1004 'is_percent' => self::is_percent_option_price( $option, $field_type ), 997 1005 ), 998 1006 $field_meta, … … 1003 1011 } 1004 1012 1013 /** 1014 * Whether a charge row's price is a percentage of the product price, using 1015 * the checkbox discount over the option price as get_field_prices() does. 1016 * Percentage detection is restricted to the listed saved-option field types. 1017 * 1018 * @param array<string, mixed>|string $option Option the row was priced from. 1019 * @param string $field_type Saved field type. 1020 * @return bool 1021 */ 1022 private static function is_percent_option_price( $option, string $field_type ): bool { 1023 if ( ! in_array( $field_type, self::PERCENT_PRICED_FIELD_TYPES, true ) || ! is_array( $option ) ) { 1024 return false; 1025 } 1026 $raw_price = isset( $option['raw_discount'] ) && $option['raw_discount'] > 0 ? $option['raw_discount'] : ( $option['raw_price'] ?? '' ); 1027 1028 return false !== strpos( (string) $raw_price, '%' ); 1029 } 1030 1005 1031 // Get total addon price of given Price Array 1006 1032 public static function price_get_addon_total( $price_array ) { … … 1047 1073 } 1048 1074 } 1075 } 1076 1077 return $total_cart_fee; 1078 } 1079 1080 /** 1081 * Total of the one-time fees in the currency the cart line is shown in. Flat fee 1082 * rows are store currency; percentage fees are already a share of the shown price. 1083 * 1084 * @param array<int, array<string, mixed>> $price_array Charge rows from get_field_prices(). 1085 * @return float 1086 */ 1087 public static function price_get_client_cart_fee_total( array $price_array ): float { 1088 $total_cart_fee = 0.0; 1089 1090 foreach ( $price_array as $price ) { 1091 if ( 'cart_fee' !== $price['apply'] ) { 1092 continue; 1093 } 1094 $fee_price = self::normalize_price_value( $price['price'] ); 1095 $total_cart_fee += empty( $price['is_percent'] ) ? (float) apply_filters( 'ppom_option_price', $fee_price ) : $fee_price; 1049 1096 } 1050 1097 … … 1519 1566 $price_tobe_discount = Helpers::get_product_price( $native_product ) * $quantity; 1520 1567 if ( $matrix_found['discount'] == 'both' ) { 1521 $total_addon_price = self::price_get_addon_total( $ppom_field_prices ); 1522 $total_cart_fee_price = self::price_get_cart_fee_total( $ppom_field_prices ); 1523 // Fee rows are store currency; the line price is what WooCommerce shows, so convert the fees once (#755). 1524 $price_tobe_discount = ( $cart_item_price * $quantity ) + apply_filters( 'ppom_option_price', $total_cart_fee_price ); 1568 $price_tobe_discount = ( $cart_item_price * $quantity ) + self::price_get_client_cart_fee_total( $ppom_field_prices ); 1525 1569 } 1526 1570 … … 1556 1600 $label = $fee['label']; 1557 1601 $option_label = isset( $fee['option_label'] ) ? $fee['option_label'] : ''; 1558 $fee_price = Helpers::convert_fee_price( $fee['price'] ); 1602 // A percentage fee is already a share of the converted product price. 1603 $fee_price = empty( $fee['is_percent'] ) ? Helpers::convert_fee_price( $fee['price'] ) : $fee['price']; 1559 1604 $taxable = $fee['taxable']; // deprecated soon 1560 1605 -
woocommerce-product-addon/tags/34.0.12/src/Pricing/ModernCartFeeApplicator.php
r3733313 r3759367 42 42 $price_tobe_discount = ppom_get_product_price( $native_product ) * $quantity; 43 43 if ( $matrix_found['discount'] == 'both' ) { 44 $total_addon_price = ppom_price_get_addon_total( $ppom_field_prices ); 45 $total_cart_fee_price = ppom_price_get_cart_fee_total( $ppom_field_prices ); 46 // Fee rows are store currency; the line price is what WooCommerce shows, so convert the fees once (#755). 47 $price_tobe_discount = ( $cart_item_price * $quantity ) + apply_filters( 'ppom_option_price', $total_cart_fee_price ); 44 $price_tobe_discount = ( $cart_item_price * $quantity ) + Engine::price_get_client_cart_fee_total( $ppom_field_prices ); 48 45 } 49 46 … … 67 64 $label = $fee['label']; 68 65 $option_label = isset( $fee['option_label'] ) ? $fee['option_label'] : ''; 69 $fee_price = \PPOM\Support\Helpers::convert_fee_price( $fee['price'] ); 66 // A percentage fee is already a share of the converted product price. 67 $fee_price = empty( $fee['is_percent'] ) ? \PPOM\Support\Helpers::convert_fee_price( $fee['price'] ) : $fee['price']; 70 68 $taxable = $fee['taxable']; 71 69 -
woocommerce-product-addon/tags/34.0.12/src/Support/Helpers.php
r3733313 r3759367 182 182 183 183 return apply_filters( 'ppom_product_price', $product_price, $product ); 184 } 185 186 /** 187 * Product price for the browser price summary, in the shopper's currency. 188 * 189 * CURCY's PPOM integration reverts ppom_product_price to store currency for 190 * server-side pricing, so it is converted back here for display only. 191 * 192 * @param \WC_Product $product Product. 193 * @return mixed Whatever ppom_product_price returns, converted under CURCY. 194 */ 195 public static function get_product_display_price( \WC_Product $product ) { 196 $product_price = self::get_product_price( $product, '', 'product' ); 197 198 if ( self::curcy_integration_active() && function_exists( 'wmc_get_price' ) ) { 199 return wmc_get_price( $product_price ); 200 } 201 202 return $product_price; 184 203 } 185 204 … … 1420 1439 1421 1440 /** 1441 * Whether WCML converts product prices in this request. On admin-ajax actions 1442 * outside its allowlist it leaves them in store currency. 1443 * 1444 * @return bool 1445 */ 1446 public static function wcml_converts_product_prices(): bool { 1447 global $woocommerce_wpml; 1448 1449 $multi_currency = $woocommerce_wpml->multi_currency ?? null; 1450 1451 return is_object( $multi_currency ) 1452 && method_exists( $multi_currency, 'are_filters_need_loading' ) 1453 && $multi_currency->are_filters_need_loading(); 1454 } 1455 1456 /** 1457 * Converts a store-currency amount to the currency WCML prices the cart line in. 1458 * Other switchers convert the line when it is read, so the amount stays as is. 1459 * 1460 * @param mixed $price Amount in store currency. 1461 * @return mixed 1462 */ 1463 public static function convert_to_wcml_line_currency( $price ) { 1464 if ( ! is_numeric( $price ) || ! self::wcml_converts_product_prices() ) { 1465 return $price; 1466 } 1467 1468 return apply_filters( 'wcml_raw_price_amount', (float) $price ); 1469 } 1470 1471 /** 1472 * Store-currency amount of a price WCML converted for this request. 1473 * 1474 * @param mixed $price Amount in the WCML client currency. 1475 * @return mixed 1476 */ 1477 public static function wcml_store_currency_price( $price ) { 1478 global $woocommerce_wpml; 1479 1480 $prices = $woocommerce_wpml->multi_currency->prices ?? null; 1481 1482 if ( ! is_numeric( $price ) || ! is_object( $prices ) || ! method_exists( $prices, 'unconvert_price_amount' ) || ! self::wcml_converts_product_prices() ) { 1483 return $price; 1484 } 1485 1486 return $prices->unconvert_price_amount( (float) $price ); 1487 } 1488 1489 /** 1422 1490 * Whether CURCY's own PPOM integration is loaded. It hooks ppom_option_price and 1423 1491 * ppom_cart_fixed_fee itself, so PPOM's CURCY conversion must step aside (#755). … … 2025 2093 2026 2094 /** 2095 * Option price for the legacy cart line: a flat price in the currency the line is 2096 * priced in, or a percentage of the product price, which already is in it. 2097 * 2098 * @param array<mixed>|string $field_meta Field settings, as get_field_meta_by_dataname() returns them. 2099 * @param mixed $option_label Selected option label. 2100 * @param \WC_Product|false|null $product Product of the cart line, as wc_get_product() returns it. 2101 * @return mixed 2102 */ 2103 private static function get_field_option_line_price( $field_meta, $option_label, $product ) { 2104 $stored_price = (string) self::get_field_option_stored_price( $field_meta, $option_label ); 2105 2106 if ( false === strpos( $stored_price, '%' ) ) { 2107 return self::convert_to_wcml_line_currency( self::get_field_option_raw_price( $field_meta, $option_label ) ); 2108 } 2109 2110 $amount = $product instanceof \WC_Product ? Engine::get_amount_after_percentage( $product->get_price(), $stored_price ) : 0; 2111 2112 return apply_filters( 'ppom_field_option_price', wc_format_decimal( $amount ), $field_meta, $option_label ); 2113 } 2114 2115 /** 2027 2116 * Option price exactly as saved in the field settings. 2028 2117 * … … 2049 2138 } 2050 2139 2051 // Getting field option price by ID 2052 public static function get_field_option_price_by_id( $option, $product, $ppom_meta_ids ) { 2140 /** 2141 * Getting field option price by ID. 2142 * 2143 * @param array<string, mixed> $option Cart payload row with data_name and option_id. 2144 * @param \WC_Product $product Product of the cart line; percentage prices need it. 2145 * @param string|int|array<int> $ppom_meta_ids PPOM field group ids. 2146 * @param bool $in_line_currency Return a flat price in the currency the cart line is priced in. 2147 * @return mixed 2148 */ 2149 public static function get_field_option_price_by_id( $option, $product, $ppom_meta_ids, bool $in_line_currency = false ) { 2053 2150 2054 2151 $data_name = isset( $option['data_name'] ) ? $option['data_name'] : ''; … … 2078 2175 } 2079 2176 2080 $ option_price = 0;2177 $saved_price = ''; 2081 2178 2082 2179 switch ( $field_type ) { … … 2088 2185 $image_id = $field_meta['data_name'] . '-' . $option['id']; 2089 2186 if ( $image_id == $option_id && isset( $option['price'] ) && $option['price'] != '' ) { 2090 2091 if ( strpos( $option['price'], '%' ) !== false ) { 2092 $option_price = Engine::get_amount_after_percentage( $product->get_price(), $option['price'] ); 2093 } else { 2094 // For currency switcher 2095 // $option_price = apply_filters('ppom_option_price', $option['price']); 2096 $option_price = $option['price']; 2097 } 2187 $saved_price = (string) $option['price']; 2098 2188 } 2099 2189 } … … 2106 2196 2107 2197 if ( $option['id'] == $option_id && isset( $option['price'] ) && $option['price'] != '' ) { 2108 2109 if ( strpos( $option['price'], '%' ) !== false ) { 2110 $option_price = Engine::get_amount_after_percentage( $product->get_price(), $option['price'] ); 2111 } else { 2112 // For currency switcher 2113 // $option_price = apply_filters('ppom_option_price', $option['price']); 2114 $option_price = $option['price']; 2115 } 2198 $saved_price = (string) $option['price']; 2116 2199 } 2117 2200 } … … 2120 2203 } 2121 2204 2205 $option_price = self::saved_option_amount( $saved_price, $product, $in_line_currency ); 2122 2206 2123 2207 return apply_filters( 'ppom_field_option_price_by_id', wc_format_decimal( $option_price ), $field_meta, $option_id, $product ); 2208 } 2209 2210 /** 2211 * Amount of a saved option price: a percentage of the product price, or the flat price. 2212 * 2213 * @param string $saved_price Saved option price, empty when no option matched. 2214 * @param \WC_Product $product Product of the cart line. 2215 * @param bool $in_line_currency Convert a flat price to the currency the cart line is priced in. 2216 * @return mixed 2217 */ 2218 private static function saved_option_amount( string $saved_price, $product, bool $in_line_currency ) { 2219 if ( '' === $saved_price ) { 2220 return 0; 2221 } 2222 2223 if ( false !== strpos( $saved_price, '%' ) ) { 2224 return Engine::get_amount_after_percentage( $product->get_price(), $saved_price ); 2225 } 2226 2227 return $in_line_currency ? self::convert_to_wcml_line_currency( $saved_price ) : $saved_price; 2124 2228 } 2125 2229 … … 2448 2552 * Builds a legacy ppom_option_price structure from posted field values. 2449 2553 * 2450 * @param array<string, mixed> $fields_posted Posted ppom[fields] payload. 2451 * @param int $product_id Product ID to look up field metadata against. 2554 * @param array<string, mixed> $fields_posted Posted ppom[fields] payload. 2555 * @param int $product_id Product ID to look up field metadata against. 2556 * @param \WC_Product|false|null $line_product Product the cart line is priced from, such as the 2557 * selected variation; percentages are taken of its price. 2452 2558 * 2453 2559 * @return array<array<string, mixed>> Option-price entries (empty when no priced options match). 2454 2560 */ 2455 public static function compute_option_price_from_fields( $fields_posted, $product_id ) {2561 public static function compute_option_price_from_fields( $fields_posted, $product_id, $line_product = null ) { 2456 2562 2457 2563 $option_prices = array(); 2458 2564 $ppom_id = isset( $fields_posted['id'] ) ? $fields_posted['id'] : null; 2565 $product = $line_product instanceof \WC_Product ? $line_product : wc_get_product( $product_id ); 2459 2566 2460 2567 foreach ( $fields_posted as $data_name => $value ) { … … 2469 2576 if ( is_array( $value ) ) { 2470 2577 foreach ( $value as $cb_value ) { 2471 $price = self::get_field_option_ raw_price( $field_meta, $cb_value);2578 $price = self::get_field_option_line_price( $field_meta, $cb_value, $product ); 2472 2579 if ( 0 != $price ) { 2473 2580 $option_prices[] = array( … … 2479 2586 } 2480 2587 } else { 2481 $price = self::get_field_option_ raw_price( $field_meta, $value);2588 $price = self::get_field_option_line_price( $field_meta, $value, $product ); 2482 2589 if ( 0 != $price ) { 2483 2590 $option_prices[] = array( -
woocommerce-product-addon/tags/34.0.12/src/WooCommerce/Cart/CartHandler.php
r3733313 r3759367 21 21 */ 22 22 final class CartHandler { 23 24 /** 25 * Cart item key that keeps each add of a quantity-controlling product on its own line. 26 * 27 * WooCommerce merges identical adds by summing their quantities, while those 28 * fields fix the line quantity themselves. 29 */ 30 private const LINE_KEY = 'ppom_line_key'; 23 31 24 32 /** … … 374 382 $cart[ Handler::VERIFIED_FILES_KEY ] = Handler::payload_file_names( $cart['ppom'] ); 375 383 376 return $cart; 384 return self::separate_quantity_controlled_line( $cart, (int) $product_id ); 385 } 386 387 /** 388 * Gives the cart item of a quantity-controlling product its own line. 389 * 390 * Sold-individually products keep the shared cart id, which is how 391 * WooCommerce rejects a second add. 392 * 393 * @param array<string, mixed> $cart_item_data Cart item data. 394 * @param int $product_id Parent product ID. 395 * 396 * @return array<string, mixed> 397 */ 398 public static function separate_quantity_controlled_line( array $cart_item_data, int $product_id ): array { 399 if ( Helpers::is_cart_quantity_updatable( $product_id ) ) { 400 return $cart_item_data; 401 } 402 403 $product = wc_get_product( $product_id ); 404 if ( $product && $product->is_sold_individually() ) { 405 return $cart_item_data; 406 } 407 408 $cart_item_data[ self::LINE_KEY ] = wp_generate_uuid4(); 409 410 return $cart_item_data; 377 411 } 378 412 … … 444 478 445 479 if ( empty( $values['ppom']['ppom_option_price'] ) && ! empty( $values['ppom']['fields'] ) ) { 446 $computed = Helpers::compute_option_price_from_fields( $values['ppom']['fields'], $product_id );480 $computed = Helpers::compute_option_price_from_fields( $values['ppom']['fields'], $product_id, $wc_product ); 447 481 if ( ! empty( $computed ) ) { 448 482 $values['ppom']['ppom_option_price'] = wp_json_encode( $computed ); … … 513 547 $resolved_line_price = isset( $option['price'] ) ? $option['price'] : 0; 514 548 if ( isset( $option['data_name'] ) && isset( $option['option_id'] ) ) { 515 $resolved_line_price = Helpers::get_field_option_price_by_id( $option, $wc_product, $ppom_meta_ids );549 $resolved_line_price = Helpers::get_field_option_price_by_id( $option, $wc_product, $ppom_meta_ids, true ); 516 550 } 517 551 } … … 1088 1122 * Turns a saved amount into the figure the cart shows. 1089 1123 * 1090 * Percentages resolve against the product base price. The amount stays net, because 1124 * Percentages resolve against the store-currency product base price, so callers 1125 * convert flat and percentage amounts the same way. The amount stays net, because 1091 1126 * the tax display transformation belongs to the display path alone. 1092 1127 * … … 1104 1139 1105 1140 if ( false !== strpos( $amount, '%' ) ) { 1106 $base = Callbacks::convert_price_back( Helpers::get_product_price( $product, null, 'cart') );1141 $base = Helpers::wcml_store_currency_price( Callbacks::convert_price_back( Helpers::get_product_price( $product, null, 'cart' ) ) ); 1107 1142 $amount = Engine::get_amount_after_percentage( $base, $amount ); 1108 1143 } -
woocommerce-product-addon/tags/34.0.12/src/WooCommerce/Order/OrderHandler.php
r3733313 r3759367 13 13 use PPOM\Files\Handler; 14 14 use PPOM\Support\Helpers; 15 use PPOM\WooCommerce\Cart\CartHandler; 15 16 16 17 /** … … 341 342 * @param \WC_Order_Item_Product $item Order Item Product 342 343 * @param \WC_Order $order 343 * @return void344 * @return array<string, mixed> 344 345 */ 345 346 public static function wc_order_again_compatibility( $cart_item_data, $item, $order ) { … … 349 350 self::restore_order_files_to_upload_dir( $ppom_data['fields'], $item, $order ); 350 351 $cart_item_data['ppom'] = $ppom_data; 352 $cart_item_data = CartHandler::separate_quantity_controlled_line( $cart_item_data, (int) $item->get_product_id() ); 351 353 } 352 354 -
woocommerce-product-addon/tags/34.0.12/src/WooCommerce/Product/ProductHandler.php
r3733313 r3759367 237 237 } 238 238 239 $computed = Helpers::compute_option_price_from_fields( $fields, $product_id );239 $computed = Helpers::compute_option_price_from_fields( $fields, $product_id, wc_get_product( $variation_id ? $variation_id : $product_id ) ); 240 240 if ( ! empty( $computed ) ) { 241 241 $_POST['ppom']['ppom_option_price'] = wp_json_encode( $computed ); -
woocommerce-product-addon/tags/34.0.12/vendor/codeinwp/themeisle-sdk/load.php
r3733313 r3759367 15 15 } 16 16 // Current SDK version and path. 17 $themeisle_sdk_version = '3.3.6 6';17 $themeisle_sdk_version = '3.3.67'; 18 18 $themeisle_sdk_path = dirname( __FILE__ ); 19 19 -
woocommerce-product-addon/tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Loader.php
r3720596 r3759367 391 391 'connect_cursor' => 'Add to Cursor', 392 392 'hint_off' => 'Your agents can connect once Easy MCP is active.', 393 'hint_on' => 'Each button opens your agent with this site pre-filled. ChatGPT asks you topaste the URL above.',393 'hint_on' => 'Each button opens your agent with this site pre-filled. In ChatGPT, click Add, then Add custom MCP server, and paste the URL above.', 394 394 'more_agents' => 'Using another agent?', 395 395 'more_agents_link' => 'See how to connect it.', -
woocommerce-product-addon/tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php
r3720596 r3759367 740 740 * One-click deep links. They mirror Easy MCP's own 741 741 * Admin_Page::build_connect_url() so they can be offered before it runs. 742 * ChatGPT cannot be pre-filled: the user pastes the URL. Cursor's link wants 742 * ChatGPT has no link to its form: its link opens the Plugins page, where 743 * the user adds the server and pastes the URL. Cursor's link wants 743 744 * its `config` as Base64 JSON; the script appends it (window.btoa), because 744 745 * PHP's Base64 function is refused by the WordPress.org plugin check in … … 756 757 return array( 757 758 'claude' => 'https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=' . rawurlencode( $name ) . '&connectorUrl=' . rawurlencode( $endpoint ), 758 'chatgpt' => 'https://chatgpt.com/plugins #settings/Connectors?create-connector=true&redirectAfter=%2Fplugins',759 'chatgpt' => 'https://chatgpt.com/plugins', 759 760 'cursor' => 'cursor://anysphere.cursor-deeplink/mcp/install?name=' . rawurlencode( $name ), 760 761 ); -
woocommerce-product-addon/tags/34.0.12/vendor/codeinwp/themeisle-sdk/src/Modules/Crash_reporter.php
r3630454 r3759367 188 188 189 189 /** 190 * Global handler for uncaught exceptions. Captures the crash and chains to 191 * the previously registered handler, if any. 190 * Global handler for uncaught exceptions. Captures the crash, then hands 191 * the exception on: to the previously registered handler when there is 192 * one, otherwise back to PHP. 193 * 194 * A handler that returns makes PHP end the request as if nothing failed: 195 * no fatal error is raised or logged and error_get_last() stays empty, so 196 * WordPress never shows its "critical error" page, never enters recovery 197 * mode and does not roll back a broken automatic update. Rethrowing keeps 198 * the request failing exactly as it would without this handler. 192 199 * 193 200 * @param \Throwable $throwable Uncaught exception. 201 * 202 * @throws \Throwable The same exception, when no earlier handler exists. 194 203 */ 195 204 public static function handle_exception( $throwable ) { … … 205 214 if ( null !== self::$previous_exception_handler && is_callable( self::$previous_exception_handler ) ) { 206 215 call_user_func( self::$previous_exception_handler, $throwable ); 207 } 216 217 return; 218 } 219 220 throw $throwable; 208 221 } 209 222 … … 211 224 * Shutdown handler. Records supported fatal errors originating from a 212 225 * registered product directory. Never outputs and never exits. 213 */ 214 public static function handle_shutdown() { 226 * 227 * @param array{type: int, message: string, file: string, line: int}|null $error Error to examine. Defaults to 228 * error_get_last(); tests pass a synthetic one. 229 */ 230 public static function handle_shutdown( $error = null ) { 215 231 self::$reserved_memory = null; 216 232 217 $error = error_get_last(); 233 if ( null === $error ) { 234 $error = error_get_last(); 235 } 218 236 if ( empty( $error ) || ! isset( $error['type'] ) || ! in_array( (int) $error['type'], self::$fatal_types, true ) ) { 219 237 return; -
woocommerce-product-addon/tags/34.0.12/vendor/composer/installed.json
r3733313 r3759367 3 3 { 4 4 "name": "codeinwp/themeisle-sdk", 5 "version": "3.3.6 6",6 "version_normalized": "3.3.6 6.0",5 "version": "3.3.67", 6 "version_normalized": "3.3.67.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/Codeinwp/themeisle-sdk.git", 10 "reference": " 27e095d8357e0594cd5769222af1258538832e75"10 "reference": "e1dda44811660a65c3da6994349c054a46686d69" 11 11 }, 12 12 "dist": { 13 13 "type": "zip", 14 "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/ 27e095d8357e0594cd5769222af1258538832e75",15 "reference": " 27e095d8357e0594cd5769222af1258538832e75",14 "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/e1dda44811660a65c3da6994349c054a46686d69", 15 "reference": "e1dda44811660a65c3da6994349c054a46686d69", 16 16 "shasum": "" 17 17 }, … … 20 20 "yoast/phpunit-polyfills": "^4.0" 21 21 }, 22 "time": "2026-10- 07T08:46:25+00:00",22 "time": "2026-10-13T12:16:34+00:00", 23 23 "type": "library", 24 24 "installation-source": "dist", … … 41 41 "support": { 42 42 "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", 43 "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.6 6"43 "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.67" 44 44 }, 45 45 "install-path": "../codeinwp/themeisle-sdk" -
woocommerce-product-addon/tags/34.0.12/vendor/composer/installed.php
r3733313 r3759367 2 2 'root' => array( 3 3 'name' => 'codeinwp/woocommerce-product-addon', 4 'pretty_version' => 'v34.0.1 1',5 'version' => '34.0.1 1.0',6 'reference' => '5 a5807826d5a5c57941963932f12cbd28558e302',4 'pretty_version' => 'v34.0.12', 5 'version' => '34.0.12.0', 6 'reference' => '5e981bd06d3e86b4a43699e473dc049d989f3d6c', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'codeinwp/themeisle-sdk' => array( 14 'pretty_version' => '3.3.6 6',15 'version' => '3.3.6 6.0',16 'reference' => ' 27e095d8357e0594cd5769222af1258538832e75',14 'pretty_version' => '3.3.67', 15 'version' => '3.3.67.0', 16 'reference' => 'e1dda44811660a65c3da6994349c054a46686d69', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../codeinwp/themeisle-sdk', … … 21 21 ), 22 22 'codeinwp/woocommerce-product-addon' => array( 23 'pretty_version' => 'v34.0.1 1',24 'version' => '34.0.1 1.0',25 'reference' => '5 a5807826d5a5c57941963932f12cbd28558e302',23 'pretty_version' => 'v34.0.12', 24 'version' => '34.0.12.0', 25 'reference' => '5e981bd06d3e86b4a43699e473dc049d989f3d6c', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../', -
woocommerce-product-addon/tags/34.0.12/woocommerce-product-addon.php
r3733313 r3759367 4 4 * Plugin URI: https://themeisle.com/plugins/ppom-pro/ 5 5 * Description: PPOM (Personalized Product Option Manager) plugin allow WooCommerce Store Admin to create unlimited input fields and files to attach with Product Pages. 6 * Version: 34.0.1 16 * Version: 34.0.12 7 7 * Author: Themeisle 8 8 * Text Domain: woocommerce-product-addon … … 33 33 define( 'PPOM_BASENAME', basename( PPOM_WP_PLUGIN_DIR ) ); 34 34 define( 'PPOM_PRODUCT_SLUG', PPOM_BASENAME ); 35 define( 'PPOM_VERSION', '34.0.1 1' );35 define( 'PPOM_VERSION', '34.0.12' ); 36 36 define( 'PPOM_DB_VERSION', '32.1.0' ); 37 37 define( 'PPOM_PRODUCT_META_KEY', '_product_meta_id' ); -
woocommerce-product-addon/trunk/CHANGELOG.md
r3733313 r3759367 1 ##### [Version 34.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.11...v34.0.12) (2026-10-22) 2 3 - Fixed the PPOM price summary showing the product price in the wrong currency 4 - Fixed cart option prices showing unconverted in secondary WCML currencies. 5 - Fixed identical linked-quantity products merging into one cart line 6 - Updated dependencies 7 1 8 ##### [Version 34.0.11](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.10...v34.0.11) (2026-10-07) 2 9 -
woocommerce-product-addon/trunk/classes/frontend-scripts.class.php
r3733313 r3759367 300 300 301 301 $product = wc_get_product( $product_id ); 302 if ( ! $product instanceof WC_Product ) { 303 return ''; 304 } 302 305 303 306 $ppom = new PPOM_Meta( $product_id ); … … 577 580 $input_js_vars['field_meta'] = $inputs_meta_updated; 578 581 $input_js_vars['wc_no_decimal'] = $decimal_palces; 579 $input_js_vars['wc_product_price'] = ppom_get_product_price( $product, '', 'product');582 $input_js_vars['wc_product_price'] = \PPOM\Support\Helpers::get_product_display_price( $product ); 580 583 $input_js_vars['wc_product_regular_price'] = ppom_get_product_regular_price( $product ); 581 584 $input_js_vars['product_title'] = $product->get_title(); -
woocommerce-product-addon/trunk/classes/plugin.class.php
r3733313 r3759367 920 920 921 921 /** 922 * Register the core ppom_option_price conversion hook only when PPOM Pro 923 * has not already registered ppom_hooks_convert_price on the same filter. 922 * Register the core ppom_option_price conversion hook and the WCML cart row 923 * pass only when PPOM Pro has not already registered ppom_hooks_convert_price 924 * on the same filter. Running Pro registers both conversions itself. 924 925 * 925 926 * Called from __construct() on woocommerce_init — after every plugin has … … 933 934 if ( ! has_filter( 'ppom_option_price', 'ppom_hooks_convert_price' ) ) { 934 935 add_filter( 'ppom_option_price', array( $this, 'ppom_convert_price' ), 99, 1 ); 935 } 936 add_filter( 'ppom_fields_prices', array( $this, 'convert_cart_rows_wcml' ), 10, 1 ); 937 } 938 } 939 940 /** 941 * Convert cart charge rows to the WCML client currency. 942 * 943 * WCML converts the product price when its meta is read, not the cart line, 944 * so option rows must be converted to match the base. One-time fees are 945 * converted when the fee is added, and percent rows are already a share of 946 * the converted base. 947 * 948 * @param array<int, array<string, mixed>> $field_prices Charge rows from Engine::get_field_prices(). 949 * @return array<int, array<string, mixed>> 950 */ 951 public function convert_cart_rows_wcml( $field_prices ) { 952 foreach ( $field_prices as $index => $row ) { 953 if ( ! isset( $row['price'] ) || 'cart_fee' === ( $row['apply'] ?? '' ) || ! empty( $row['is_percent'] ) ) { 954 continue; 955 } 956 $field_prices[ $index ]['price'] = \PPOM\Support\Helpers::convert_to_wcml_line_currency( $row['price'] ); 957 } 958 959 return $field_prices; 936 960 } 937 961 -
woocommerce-product-addon/trunk/readme.txt
r3733313 r3759367 4 4 Requires at least: 6.2 5 5 Tested up to: 7.1 6 Stable tag: 34.0.1 16 Stable tag: 34.0.12 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 260 260 == Changelog == 261 261 262 ##### [Version 34.0.11](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.10...v34.0.11) (2026-10-07) 263 264 - Fixed SVG uploads failing in File upload fields 265 - Fixed the first product-page price to use the visible conditional price matrix. 266 - Fixed conditional fields to respond only to selections in their own product form. 267 - Fixed modern pricing to honor zero-price matrix selections 268 - Fixed the file picker for upload fields with hyphenated names. 269 - Fixed PPOM applying currency exchange rates twice to priced options and cart totals. 270 - Fixed PPOM Pro converting WPML cart option charges twice. 271 - Fixed currency switchers converting PPOM option prices more than once. 272 - Fixed file uploads allowing visitors to delete files outside uploads folder. 262 ##### [Version 34.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v34.0.11...v34.0.12) (2026-10-22) 263 264 - Fixed the PPOM price summary showing the product price in the wrong currency 265 - Fixed cart option prices showing unconverted in secondary WCML currencies. 266 - Fixed identical linked-quantity products merging into one cart line 273 267 - Updated dependencies 274 268 -
woocommerce-product-addon/trunk/src/Arrays/Settings.php
r3733313 r3759367 644 644 $js_vars['wc_decimal_sep'] = get_option( 'woocommerce_price_decimal_sep' ); 645 645 $js_vars['wc_no_decimal'] = $decimal_palces; 646 $variation_id = ''; 647 $context = 'product'; 648 $js_vars['wc_product_price'] = Helpers::get_product_price( $product, $variation_id, $context ); 646 $js_vars['wc_product_price'] = Helpers::get_product_display_price( $product ); 649 647 $js_vars['wc_product_regular_price'] = Helpers::get_product_regular_price( $product ); 650 648 $ppom_label_discount_price = Helpers::get_option( 'ppom_label_discount_price', __( 'Discount Price', 'woocommerce-product-addon' ) ); -
woocommerce-product-addon/trunk/src/Pricing/Engine.php
r3733313 r3759367 20 20 */ 21 21 final class Engine { 22 23 /** 24 * Field types whose options can be priced as a percentage of the product price. 25 * 26 * @var list<'select'|'radio'|'checkbox'|'multiple_select'|'cropper'|'palettes'|'imageselect'|'image'|'audio'> 27 */ 28 private const PERCENT_PRICED_FIELD_TYPES = array( 'select', 'radio', 'checkbox', 'multiple_select', 'cropper', 'palettes', 'imageselect', 'image', 'audio' ); 22 29 23 30 /** … … 296 303 * @param array<string, mixed>|null $item Cart item context. 297 304 * 298 * @return array< string, mixed>305 * @return array<int, array<string, mixed>> 299 306 * 300 307 * @see Helpers::get_field_meta_by_dataname() … … 968 975 $without_tax = isset( $option['without_tax'] ) ? $option['without_tax'] : ''; 969 976 970 // Charge rows stay in store currency: the switcher converts the cart line on read971 // and Pro's WPML pass converts these rows itself. Only the label is display (#755).977 // Charge rows stay in store currency: switchers convert the cart line on read, and 978 // the WCML pass on ppom_fields_prices converts the rows. Only the label is converted here. 972 979 $label_price = "{$field_title} - " . wc_price( apply_filters( 'ppom_option_price', $field_price ) ); 973 980 // For bulkquantity … … 995 1002 'quantity' => $qty, 996 1003 'base_price' => $base_price, 1004 'is_percent' => self::is_percent_option_price( $option, $field_type ), 997 1005 ), 998 1006 $field_meta, … … 1003 1011 } 1004 1012 1013 /** 1014 * Whether a charge row's price is a percentage of the product price, using 1015 * the checkbox discount over the option price as get_field_prices() does. 1016 * Percentage detection is restricted to the listed saved-option field types. 1017 * 1018 * @param array<string, mixed>|string $option Option the row was priced from. 1019 * @param string $field_type Saved field type. 1020 * @return bool 1021 */ 1022 private static function is_percent_option_price( $option, string $field_type ): bool { 1023 if ( ! in_array( $field_type, self::PERCENT_PRICED_FIELD_TYPES, true ) || ! is_array( $option ) ) { 1024 return false; 1025 } 1026 $raw_price = isset( $option['raw_discount'] ) && $option['raw_discount'] > 0 ? $option['raw_discount'] : ( $option['raw_price'] ?? '' ); 1027 1028 return false !== strpos( (string) $raw_price, '%' ); 1029 } 1030 1005 1031 // Get total addon price of given Price Array 1006 1032 public static function price_get_addon_total( $price_array ) { … … 1047 1073 } 1048 1074 } 1075 } 1076 1077 return $total_cart_fee; 1078 } 1079 1080 /** 1081 * Total of the one-time fees in the currency the cart line is shown in. Flat fee 1082 * rows are store currency; percentage fees are already a share of the shown price. 1083 * 1084 * @param array<int, array<string, mixed>> $price_array Charge rows from get_field_prices(). 1085 * @return float 1086 */ 1087 public static function price_get_client_cart_fee_total( array $price_array ): float { 1088 $total_cart_fee = 0.0; 1089 1090 foreach ( $price_array as $price ) { 1091 if ( 'cart_fee' !== $price['apply'] ) { 1092 continue; 1093 } 1094 $fee_price = self::normalize_price_value( $price['price'] ); 1095 $total_cart_fee += empty( $price['is_percent'] ) ? (float) apply_filters( 'ppom_option_price', $fee_price ) : $fee_price; 1049 1096 } 1050 1097 … … 1519 1566 $price_tobe_discount = Helpers::get_product_price( $native_product ) * $quantity; 1520 1567 if ( $matrix_found['discount'] == 'both' ) { 1521 $total_addon_price = self::price_get_addon_total( $ppom_field_prices ); 1522 $total_cart_fee_price = self::price_get_cart_fee_total( $ppom_field_prices ); 1523 // Fee rows are store currency; the line price is what WooCommerce shows, so convert the fees once (#755). 1524 $price_tobe_discount = ( $cart_item_price * $quantity ) + apply_filters( 'ppom_option_price', $total_cart_fee_price ); 1568 $price_tobe_discount = ( $cart_item_price * $quantity ) + self::price_get_client_cart_fee_total( $ppom_field_prices ); 1525 1569 } 1526 1570 … … 1556 1600 $label = $fee['label']; 1557 1601 $option_label = isset( $fee['option_label'] ) ? $fee['option_label'] : ''; 1558 $fee_price = Helpers::convert_fee_price( $fee['price'] ); 1602 // A percentage fee is already a share of the converted product price. 1603 $fee_price = empty( $fee['is_percent'] ) ? Helpers::convert_fee_price( $fee['price'] ) : $fee['price']; 1559 1604 $taxable = $fee['taxable']; // deprecated soon 1560 1605 -
woocommerce-product-addon/trunk/src/Pricing/ModernCartFeeApplicator.php
r3733313 r3759367 42 42 $price_tobe_discount = ppom_get_product_price( $native_product ) * $quantity; 43 43 if ( $matrix_found['discount'] == 'both' ) { 44 $total_addon_price = ppom_price_get_addon_total( $ppom_field_prices ); 45 $total_cart_fee_price = ppom_price_get_cart_fee_total( $ppom_field_prices ); 46 // Fee rows are store currency; the line price is what WooCommerce shows, so convert the fees once (#755). 47 $price_tobe_discount = ( $cart_item_price * $quantity ) + apply_filters( 'ppom_option_price', $total_cart_fee_price ); 44 $price_tobe_discount = ( $cart_item_price * $quantity ) + Engine::price_get_client_cart_fee_total( $ppom_field_prices ); 48 45 } 49 46 … … 67 64 $label = $fee['label']; 68 65 $option_label = isset( $fee['option_label'] ) ? $fee['option_label'] : ''; 69 $fee_price = \PPOM\Support\Helpers::convert_fee_price( $fee['price'] ); 66 // A percentage fee is already a share of the converted product price. 67 $fee_price = empty( $fee['is_percent'] ) ? \PPOM\Support\Helpers::convert_fee_price( $fee['price'] ) : $fee['price']; 70 68 $taxable = $fee['taxable']; 71 69 -
woocommerce-product-addon/trunk/src/Support/Helpers.php
r3733313 r3759367 182 182 183 183 return apply_filters( 'ppom_product_price', $product_price, $product ); 184 } 185 186 /** 187 * Product price for the browser price summary, in the shopper's currency. 188 * 189 * CURCY's PPOM integration reverts ppom_product_price to store currency for 190 * server-side pricing, so it is converted back here for display only. 191 * 192 * @param \WC_Product $product Product. 193 * @return mixed Whatever ppom_product_price returns, converted under CURCY. 194 */ 195 public static function get_product_display_price( \WC_Product $product ) { 196 $product_price = self::get_product_price( $product, '', 'product' ); 197 198 if ( self::curcy_integration_active() && function_exists( 'wmc_get_price' ) ) { 199 return wmc_get_price( $product_price ); 200 } 201 202 return $product_price; 184 203 } 185 204 … … 1420 1439 1421 1440 /** 1441 * Whether WCML converts product prices in this request. On admin-ajax actions 1442 * outside its allowlist it leaves them in store currency. 1443 * 1444 * @return bool 1445 */ 1446 public static function wcml_converts_product_prices(): bool { 1447 global $woocommerce_wpml; 1448 1449 $multi_currency = $woocommerce_wpml->multi_currency ?? null; 1450 1451 return is_object( $multi_currency ) 1452 && method_exists( $multi_currency, 'are_filters_need_loading' ) 1453 && $multi_currency->are_filters_need_loading(); 1454 } 1455 1456 /** 1457 * Converts a store-currency amount to the currency WCML prices the cart line in. 1458 * Other switchers convert the line when it is read, so the amount stays as is. 1459 * 1460 * @param mixed $price Amount in store currency. 1461 * @return mixed 1462 */ 1463 public static function convert_to_wcml_line_currency( $price ) { 1464 if ( ! is_numeric( $price ) || ! self::wcml_converts_product_prices() ) { 1465 return $price; 1466 } 1467 1468 return apply_filters( 'wcml_raw_price_amount', (float) $price ); 1469 } 1470 1471 /** 1472 * Store-currency amount of a price WCML converted for this request. 1473 * 1474 * @param mixed $price Amount in the WCML client currency. 1475 * @return mixed 1476 */ 1477 public static function wcml_store_currency_price( $price ) { 1478 global $woocommerce_wpml; 1479 1480 $prices = $woocommerce_wpml->multi_currency->prices ?? null; 1481 1482 if ( ! is_numeric( $price ) || ! is_object( $prices ) || ! method_exists( $prices, 'unconvert_price_amount' ) || ! self::wcml_converts_product_prices() ) { 1483 return $price; 1484 } 1485 1486 return $prices->unconvert_price_amount( (float) $price ); 1487 } 1488 1489 /** 1422 1490 * Whether CURCY's own PPOM integration is loaded. It hooks ppom_option_price and 1423 1491 * ppom_cart_fixed_fee itself, so PPOM's CURCY conversion must step aside (#755). … … 2025 2093 2026 2094 /** 2095 * Option price for the legacy cart line: a flat price in the currency the line is 2096 * priced in, or a percentage of the product price, which already is in it. 2097 * 2098 * @param array<mixed>|string $field_meta Field settings, as get_field_meta_by_dataname() returns them. 2099 * @param mixed $option_label Selected option label. 2100 * @param \WC_Product|false|null $product Product of the cart line, as wc_get_product() returns it. 2101 * @return mixed 2102 */ 2103 private static function get_field_option_line_price( $field_meta, $option_label, $product ) { 2104 $stored_price = (string) self::get_field_option_stored_price( $field_meta, $option_label ); 2105 2106 if ( false === strpos( $stored_price, '%' ) ) { 2107 return self::convert_to_wcml_line_currency( self::get_field_option_raw_price( $field_meta, $option_label ) ); 2108 } 2109 2110 $amount = $product instanceof \WC_Product ? Engine::get_amount_after_percentage( $product->get_price(), $stored_price ) : 0; 2111 2112 return apply_filters( 'ppom_field_option_price', wc_format_decimal( $amount ), $field_meta, $option_label ); 2113 } 2114 2115 /** 2027 2116 * Option price exactly as saved in the field settings. 2028 2117 * … … 2049 2138 } 2050 2139 2051 // Getting field option price by ID 2052 public static function get_field_option_price_by_id( $option, $product, $ppom_meta_ids ) { 2140 /** 2141 * Getting field option price by ID. 2142 * 2143 * @param array<string, mixed> $option Cart payload row with data_name and option_id. 2144 * @param \WC_Product $product Product of the cart line; percentage prices need it. 2145 * @param string|int|array<int> $ppom_meta_ids PPOM field group ids. 2146 * @param bool $in_line_currency Return a flat price in the currency the cart line is priced in. 2147 * @return mixed 2148 */ 2149 public static function get_field_option_price_by_id( $option, $product, $ppom_meta_ids, bool $in_line_currency = false ) { 2053 2150 2054 2151 $data_name = isset( $option['data_name'] ) ? $option['data_name'] : ''; … … 2078 2175 } 2079 2176 2080 $ option_price = 0;2177 $saved_price = ''; 2081 2178 2082 2179 switch ( $field_type ) { … … 2088 2185 $image_id = $field_meta['data_name'] . '-' . $option['id']; 2089 2186 if ( $image_id == $option_id && isset( $option['price'] ) && $option['price'] != '' ) { 2090 2091 if ( strpos( $option['price'], '%' ) !== false ) { 2092 $option_price = Engine::get_amount_after_percentage( $product->get_price(), $option['price'] ); 2093 } else { 2094 // For currency switcher 2095 // $option_price = apply_filters('ppom_option_price', $option['price']); 2096 $option_price = $option['price']; 2097 } 2187 $saved_price = (string) $option['price']; 2098 2188 } 2099 2189 } … … 2106 2196 2107 2197 if ( $option['id'] == $option_id && isset( $option['price'] ) && $option['price'] != '' ) { 2108 2109 if ( strpos( $option['price'], '%' ) !== false ) { 2110 $option_price = Engine::get_amount_after_percentage( $product->get_price(), $option['price'] ); 2111 } else { 2112 // For currency switcher 2113 // $option_price = apply_filters('ppom_option_price', $option['price']); 2114 $option_price = $option['price']; 2115 } 2198 $saved_price = (string) $option['price']; 2116 2199 } 2117 2200 } … … 2120 2203 } 2121 2204 2205 $option_price = self::saved_option_amount( $saved_price, $product, $in_line_currency ); 2122 2206 2123 2207 return apply_filters( 'ppom_field_option_price_by_id', wc_format_decimal( $option_price ), $field_meta, $option_id, $product ); 2208 } 2209 2210 /** 2211 * Amount of a saved option price: a percentage of the product price, or the flat price. 2212 * 2213 * @param string $saved_price Saved option price, empty when no option matched. 2214 * @param \WC_Product $product Product of the cart line. 2215 * @param bool $in_line_currency Convert a flat price to the currency the cart line is priced in. 2216 * @return mixed 2217 */ 2218 private static function saved_option_amount( string $saved_price, $product, bool $in_line_currency ) { 2219 if ( '' === $saved_price ) { 2220 return 0; 2221 } 2222 2223 if ( false !== strpos( $saved_price, '%' ) ) { 2224 return Engine::get_amount_after_percentage( $product->get_price(), $saved_price ); 2225 } 2226 2227 return $in_line_currency ? self::convert_to_wcml_line_currency( $saved_price ) : $saved_price; 2124 2228 } 2125 2229 … … 2448 2552 * Builds a legacy ppom_option_price structure from posted field values. 2449 2553 * 2450 * @param array<string, mixed> $fields_posted Posted ppom[fields] payload. 2451 * @param int $product_id Product ID to look up field metadata against. 2554 * @param array<string, mixed> $fields_posted Posted ppom[fields] payload. 2555 * @param int $product_id Product ID to look up field metadata against. 2556 * @param \WC_Product|false|null $line_product Product the cart line is priced from, such as the 2557 * selected variation; percentages are taken of its price. 2452 2558 * 2453 2559 * @return array<array<string, mixed>> Option-price entries (empty when no priced options match). 2454 2560 */ 2455 public static function compute_option_price_from_fields( $fields_posted, $product_id ) {2561 public static function compute_option_price_from_fields( $fields_posted, $product_id, $line_product = null ) { 2456 2562 2457 2563 $option_prices = array(); 2458 2564 $ppom_id = isset( $fields_posted['id'] ) ? $fields_posted['id'] : null; 2565 $product = $line_product instanceof \WC_Product ? $line_product : wc_get_product( $product_id ); 2459 2566 2460 2567 foreach ( $fields_posted as $data_name => $value ) { … … 2469 2576 if ( is_array( $value ) ) { 2470 2577 foreach ( $value as $cb_value ) { 2471 $price = self::get_field_option_ raw_price( $field_meta, $cb_value);2578 $price = self::get_field_option_line_price( $field_meta, $cb_value, $product ); 2472 2579 if ( 0 != $price ) { 2473 2580 $option_prices[] = array( … … 2479 2586 } 2480 2587 } else { 2481 $price = self::get_field_option_ raw_price( $field_meta, $value);2588 $price = self::get_field_option_line_price( $field_meta, $value, $product ); 2482 2589 if ( 0 != $price ) { 2483 2590 $option_prices[] = array( -
woocommerce-product-addon/trunk/src/WooCommerce/Cart/CartHandler.php
r3733313 r3759367 21 21 */ 22 22 final class CartHandler { 23 24 /** 25 * Cart item key that keeps each add of a quantity-controlling product on its own line. 26 * 27 * WooCommerce merges identical adds by summing their quantities, while those 28 * fields fix the line quantity themselves. 29 */ 30 private const LINE_KEY = 'ppom_line_key'; 23 31 24 32 /** … … 374 382 $cart[ Handler::VERIFIED_FILES_KEY ] = Handler::payload_file_names( $cart['ppom'] ); 375 383 376 return $cart; 384 return self::separate_quantity_controlled_line( $cart, (int) $product_id ); 385 } 386 387 /** 388 * Gives the cart item of a quantity-controlling product its own line. 389 * 390 * Sold-individually products keep the shared cart id, which is how 391 * WooCommerce rejects a second add. 392 * 393 * @param array<string, mixed> $cart_item_data Cart item data. 394 * @param int $product_id Parent product ID. 395 * 396 * @return array<string, mixed> 397 */ 398 public static function separate_quantity_controlled_line( array $cart_item_data, int $product_id ): array { 399 if ( Helpers::is_cart_quantity_updatable( $product_id ) ) { 400 return $cart_item_data; 401 } 402 403 $product = wc_get_product( $product_id ); 404 if ( $product && $product->is_sold_individually() ) { 405 return $cart_item_data; 406 } 407 408 $cart_item_data[ self::LINE_KEY ] = wp_generate_uuid4(); 409 410 return $cart_item_data; 377 411 } 378 412 … … 444 478 445 479 if ( empty( $values['ppom']['ppom_option_price'] ) && ! empty( $values['ppom']['fields'] ) ) { 446 $computed = Helpers::compute_option_price_from_fields( $values['ppom']['fields'], $product_id );480 $computed = Helpers::compute_option_price_from_fields( $values['ppom']['fields'], $product_id, $wc_product ); 447 481 if ( ! empty( $computed ) ) { 448 482 $values['ppom']['ppom_option_price'] = wp_json_encode( $computed ); … … 513 547 $resolved_line_price = isset( $option['price'] ) ? $option['price'] : 0; 514 548 if ( isset( $option['data_name'] ) && isset( $option['option_id'] ) ) { 515 $resolved_line_price = Helpers::get_field_option_price_by_id( $option, $wc_product, $ppom_meta_ids );549 $resolved_line_price = Helpers::get_field_option_price_by_id( $option, $wc_product, $ppom_meta_ids, true ); 516 550 } 517 551 } … … 1088 1122 * Turns a saved amount into the figure the cart shows. 1089 1123 * 1090 * Percentages resolve against the product base price. The amount stays net, because 1124 * Percentages resolve against the store-currency product base price, so callers 1125 * convert flat and percentage amounts the same way. The amount stays net, because 1091 1126 * the tax display transformation belongs to the display path alone. 1092 1127 * … … 1104 1139 1105 1140 if ( false !== strpos( $amount, '%' ) ) { 1106 $base = Callbacks::convert_price_back( Helpers::get_product_price( $product, null, 'cart') );1141 $base = Helpers::wcml_store_currency_price( Callbacks::convert_price_back( Helpers::get_product_price( $product, null, 'cart' ) ) ); 1107 1142 $amount = Engine::get_amount_after_percentage( $base, $amount ); 1108 1143 } -
woocommerce-product-addon/trunk/src/WooCommerce/Order/OrderHandler.php
r3733313 r3759367 13 13 use PPOM\Files\Handler; 14 14 use PPOM\Support\Helpers; 15 use PPOM\WooCommerce\Cart\CartHandler; 15 16 16 17 /** … … 341 342 * @param \WC_Order_Item_Product $item Order Item Product 342 343 * @param \WC_Order $order 343 * @return void344 * @return array<string, mixed> 344 345 */ 345 346 public static function wc_order_again_compatibility( $cart_item_data, $item, $order ) { … … 349 350 self::restore_order_files_to_upload_dir( $ppom_data['fields'], $item, $order ); 350 351 $cart_item_data['ppom'] = $ppom_data; 352 $cart_item_data = CartHandler::separate_quantity_controlled_line( $cart_item_data, (int) $item->get_product_id() ); 351 353 } 352 354 -
woocommerce-product-addon/trunk/src/WooCommerce/Product/ProductHandler.php
r3733313 r3759367 237 237 } 238 238 239 $computed = Helpers::compute_option_price_from_fields( $fields, $product_id );239 $computed = Helpers::compute_option_price_from_fields( $fields, $product_id, wc_get_product( $variation_id ? $variation_id : $product_id ) ); 240 240 if ( ! empty( $computed ) ) { 241 241 $_POST['ppom']['ppom_option_price'] = wp_json_encode( $computed ); -
woocommerce-product-addon/trunk/vendor/codeinwp/themeisle-sdk/load.php
r3733313 r3759367 15 15 } 16 16 // Current SDK version and path. 17 $themeisle_sdk_version = '3.3.6 6';17 $themeisle_sdk_version = '3.3.67'; 18 18 $themeisle_sdk_path = dirname( __FILE__ ); 19 19 -
woocommerce-product-addon/trunk/vendor/codeinwp/themeisle-sdk/src/Loader.php
r3720596 r3759367 391 391 'connect_cursor' => 'Add to Cursor', 392 392 'hint_off' => 'Your agents can connect once Easy MCP is active.', 393 'hint_on' => 'Each button opens your agent with this site pre-filled. ChatGPT asks you topaste the URL above.',393 'hint_on' => 'Each button opens your agent with this site pre-filled. In ChatGPT, click Add, then Add custom MCP server, and paste the URL above.', 394 394 'more_agents' => 'Using another agent?', 395 395 'more_agents_link' => 'See how to connect it.', -
woocommerce-product-addon/trunk/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php
r3720596 r3759367 740 740 * One-click deep links. They mirror Easy MCP's own 741 741 * Admin_Page::build_connect_url() so they can be offered before it runs. 742 * ChatGPT cannot be pre-filled: the user pastes the URL. Cursor's link wants 742 * ChatGPT has no link to its form: its link opens the Plugins page, where 743 * the user adds the server and pastes the URL. Cursor's link wants 743 744 * its `config` as Base64 JSON; the script appends it (window.btoa), because 744 745 * PHP's Base64 function is refused by the WordPress.org plugin check in … … 756 757 return array( 757 758 'claude' => 'https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=' . rawurlencode( $name ) . '&connectorUrl=' . rawurlencode( $endpoint ), 758 'chatgpt' => 'https://chatgpt.com/plugins #settings/Connectors?create-connector=true&redirectAfter=%2Fplugins',759 'chatgpt' => 'https://chatgpt.com/plugins', 759 760 'cursor' => 'cursor://anysphere.cursor-deeplink/mcp/install?name=' . rawurlencode( $name ), 760 761 ); -
woocommerce-product-addon/trunk/vendor/codeinwp/themeisle-sdk/src/Modules/Crash_reporter.php
r3630454 r3759367 188 188 189 189 /** 190 * Global handler for uncaught exceptions. Captures the crash and chains to 191 * the previously registered handler, if any. 190 * Global handler for uncaught exceptions. Captures the crash, then hands 191 * the exception on: to the previously registered handler when there is 192 * one, otherwise back to PHP. 193 * 194 * A handler that returns makes PHP end the request as if nothing failed: 195 * no fatal error is raised or logged and error_get_last() stays empty, so 196 * WordPress never shows its "critical error" page, never enters recovery 197 * mode and does not roll back a broken automatic update. Rethrowing keeps 198 * the request failing exactly as it would without this handler. 192 199 * 193 200 * @param \Throwable $throwable Uncaught exception. 201 * 202 * @throws \Throwable The same exception, when no earlier handler exists. 194 203 */ 195 204 public static function handle_exception( $throwable ) { … … 205 214 if ( null !== self::$previous_exception_handler && is_callable( self::$previous_exception_handler ) ) { 206 215 call_user_func( self::$previous_exception_handler, $throwable ); 207 } 216 217 return; 218 } 219 220 throw $throwable; 208 221 } 209 222 … … 211 224 * Shutdown handler. Records supported fatal errors originating from a 212 225 * registered product directory. Never outputs and never exits. 213 */ 214 public static function handle_shutdown() { 226 * 227 * @param array{type: int, message: string, file: string, line: int}|null $error Error to examine. Defaults to 228 * error_get_last(); tests pass a synthetic one. 229 */ 230 public static function handle_shutdown( $error = null ) { 215 231 self::$reserved_memory = null; 216 232 217 $error = error_get_last(); 233 if ( null === $error ) { 234 $error = error_get_last(); 235 } 218 236 if ( empty( $error ) || ! isset( $error['type'] ) || ! in_array( (int) $error['type'], self::$fatal_types, true ) ) { 219 237 return; -
woocommerce-product-addon/trunk/vendor/composer/installed.json
r3733313 r3759367 3 3 { 4 4 "name": "codeinwp/themeisle-sdk", 5 "version": "3.3.6 6",6 "version_normalized": "3.3.6 6.0",5 "version": "3.3.67", 6 "version_normalized": "3.3.67.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/Codeinwp/themeisle-sdk.git", 10 "reference": " 27e095d8357e0594cd5769222af1258538832e75"10 "reference": "e1dda44811660a65c3da6994349c054a46686d69" 11 11 }, 12 12 "dist": { 13 13 "type": "zip", 14 "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/ 27e095d8357e0594cd5769222af1258538832e75",15 "reference": " 27e095d8357e0594cd5769222af1258538832e75",14 "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/e1dda44811660a65c3da6994349c054a46686d69", 15 "reference": "e1dda44811660a65c3da6994349c054a46686d69", 16 16 "shasum": "" 17 17 }, … … 20 20 "yoast/phpunit-polyfills": "^4.0" 21 21 }, 22 "time": "2026-10- 07T08:46:25+00:00",22 "time": "2026-10-13T12:16:34+00:00", 23 23 "type": "library", 24 24 "installation-source": "dist", … … 41 41 "support": { 42 42 "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", 43 "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.6 6"43 "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.67" 44 44 }, 45 45 "install-path": "../codeinwp/themeisle-sdk" -
woocommerce-product-addon/trunk/vendor/composer/installed.php
r3733313 r3759367 2 2 'root' => array( 3 3 'name' => 'codeinwp/woocommerce-product-addon', 4 'pretty_version' => 'v34.0.1 1',5 'version' => '34.0.1 1.0',6 'reference' => '5 a5807826d5a5c57941963932f12cbd28558e302',4 'pretty_version' => 'v34.0.12', 5 'version' => '34.0.12.0', 6 'reference' => '5e981bd06d3e86b4a43699e473dc049d989f3d6c', 7 7 'type' => 'project', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'codeinwp/themeisle-sdk' => array( 14 'pretty_version' => '3.3.6 6',15 'version' => '3.3.6 6.0',16 'reference' => ' 27e095d8357e0594cd5769222af1258538832e75',14 'pretty_version' => '3.3.67', 15 'version' => '3.3.67.0', 16 'reference' => 'e1dda44811660a65c3da6994349c054a46686d69', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../codeinwp/themeisle-sdk', … … 21 21 ), 22 22 'codeinwp/woocommerce-product-addon' => array( 23 'pretty_version' => 'v34.0.1 1',24 'version' => '34.0.1 1.0',25 'reference' => '5 a5807826d5a5c57941963932f12cbd28558e302',23 'pretty_version' => 'v34.0.12', 24 'version' => '34.0.12.0', 25 'reference' => '5e981bd06d3e86b4a43699e473dc049d989f3d6c', 26 26 'type' => 'project', 27 27 'install_path' => __DIR__ . '/../../', -
woocommerce-product-addon/trunk/woocommerce-product-addon.php
r3733313 r3759367 4 4 * Plugin URI: https://themeisle.com/plugins/ppom-pro/ 5 5 * Description: PPOM (Personalized Product Option Manager) plugin allow WooCommerce Store Admin to create unlimited input fields and files to attach with Product Pages. 6 * Version: 34.0.1 16 * Version: 34.0.12 7 7 * Author: Themeisle 8 8 * Text Domain: woocommerce-product-addon … … 33 33 define( 'PPOM_BASENAME', basename( PPOM_WP_PLUGIN_DIR ) ); 34 34 define( 'PPOM_PRODUCT_SLUG', PPOM_BASENAME ); 35 define( 'PPOM_VERSION', '34.0.1 1' );35 define( 'PPOM_VERSION', '34.0.12' ); 36 36 define( 'PPOM_DB_VERSION', '32.1.0' ); 37 37 define( 'PPOM_PRODUCT_META_KEY', '_product_meta_id' );
Note:
See TracChangeset
for help on using the changeset viewer.