Changeset 3821742
- Timestamp:
- 11/25/2026 12:00:35 AM (111 minutes ago)
- Location:
- easy-product-bundles-for-woocommerce
- Files:
-
- 16 edited
- 1 copied
-
tags/6.22.5 (copied) (copied from easy-product-bundles-for-woocommerce/trunk )
-
tags/6.22.5/assets/js/checkout-integration/index.js (modified) (1 diff)
-
tags/6.22.5/easy-product-bundles.php (modified) (2 diffs)
-
tags/6.22.5/languages/asnp-easy-product-bundles.pot (modified) (5 diffs)
-
tags/6.22.5/readme.txt (modified) (2 diffs)
-
tags/6.22.5/src/Blocks/Integrations/CheckoutIntegration.php (modified) (1 diff)
-
tags/6.22.5/src/ProductBundleHooks.php (modified) (13 diffs)
-
tags/6.22.5/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/6.22.5/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/assets/js/checkout-integration/index.js (modified) (1 diff)
-
trunk/easy-product-bundles.php (modified) (2 diffs)
-
trunk/languages/asnp-easy-product-bundles.pot (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Blocks/Integrations/CheckoutIntegration.php (modified) (1 diff)
-
trunk/src/ProductBundleHooks.php (modified) (13 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-product-bundles-for-woocommerce/tags/6.22.5/assets/js/checkout-integration/index.js
r3767259 r3821742 1 (()=>{"use strict";var e, n,i,o,d={};o=d,"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0});var u=(null===(e=window)||void 0===e||null===(n=e.wc)||void 0===n||null===(i=n.blocksCheckout)||void 0===i?void 0:i.registerCheckoutFilters)||null,t=function(e){return e&&"undefined"!==typeof e.is_bundle_item};u&&u("easy-product-bundle",{cartItemClass:function(e,n,i){var o,d=null===n||void 0===n||null===(o=n.easy_product_bundle)||void 0===o?void 0:o.data;if(!d)return e;if(t(d))e+=" wepb-bundle-item","yes"===(null===d||void 0===d?void 0:d.hide_price)?e+=" wepb-hide-price":"regular"===(null===d||void 0===d?void 0:d.hide_price)&&(e+=" wepb-hide-regular-price");else if(function(e){return e&&"undefined"!==typeof e.is_bundle}(d))return"".concat(e," wepb-bundle");return e},showRemoveItemLink:function(e,n,i){var o,d=null===n||void 0===n||null===(o=n.easy_product_bundle)||void 0===o?void 0:o.data;return d?!t(d)&&e:e}}),(window.asnpWepb=window.asnpWepb||{})["checkout-integration"]=d})();1 (()=>{"use strict";var e,o,n,i,d,t,u,l={};u=l,"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0});var r=(null===(e=window)||void 0===e||null===(o=e.wc)||void 0===o||null===(n=o.blocksCheckout)||void 0===n?void 0:n.registerCheckoutFilters)||null,c=(null===(i=window)||void 0===i||null===(d=i.wp)||void 0===d||null===(t=d.hooks)||void 0===t?void 0:t.addFilter)||null,a=function(e){return e&&"undefined"!==typeof e.is_bundle_item},v=function(e,o){var n,i,d,t=(null===o||void 0===o||null===(n=o.extensions)||void 0===n||null===(i=n.easy_product_bundle)||void 0===i?void 0:i.data)||(null===o||void 0===o||null===(d=o.easy_product_bundle)||void 0===d?void 0:d.data);return t?!a(t)&&e:e};r&&r("easy-product-bundle",{cartItemClass:function(e,o,n){var i,d=null===o||void 0===o||null===(i=o.easy_product_bundle)||void 0===i?void 0:i.data;if(!d)return e;if(a(d))e+=" wepb-bundle-item","yes"===(null===d||void 0===d?void 0:d.hide_price)?e+=" wepb-hide-price":"regular"===(null===d||void 0===d?void 0:d.hide_price)&&(e+=" wepb-hide-regular-price");else if(function(e){return e&&"undefined"!==typeof e.is_bundle}(d))return"".concat(e," wepb-bundle");return e},showRemoveItemLink:function(e,o,n){var i,d=null===o||void 0===o||null===(i=o.easy_product_bundle)||void 0===i?void 0:i.data;return d?!a(d)&&e:e}}),c&&(c("woocommerce_show_cart_item_quantity_changed_notice","easy-product-bundle/show-cart-item-quantity-changed-notice",v),c("woocommerce_show_cart_item_removed_notice","easy-product-bundle/show-cart-item-removed-notice",v)),(window.asnpWepb=window.asnpWepb||{})["checkout-integration"]=l})(); -
easy-product-bundles-for-woocommerce/tags/6.22.5/easy-product-bundles.php
r3795471 r3821742 7 7 * Description: Create product bundles in WooCommerce easily 8 8 * Tags: woocommerce, product bundles, bundled products 9 * Version: 6.22. 49 * Version: 6.22.5 10 10 * Author: Product Bundles Team 11 11 * Author URI: https://www.asanaplugins.com/ … … 25 25 // Plugin version. 26 26 if ( ! defined( 'ASNP_WEPB_VERSION' ) ) { 27 define( 'ASNP_WEPB_VERSION', '6.22. 4' );27 define( 'ASNP_WEPB_VERSION', '6.22.5' ); 28 28 } 29 29 -
easy-product-bundles-for-woocommerce/tags/6.22.5/languages/asnp-easy-product-bundles.pot
r3795471 r3821742 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Easy Product Bundles for WooCommerce 6.22. 4\n"5 "Project-Id-Version: Easy Product Bundles for WooCommerce 6.22.5\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easy-product-bundles-for-woocommerce\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026-11- 10T19:51:40+00:00\n"12 "POT-Creation-Date: 2026-11-24T23:26:47+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 383 383 msgstr "" 384 384 385 #: src/ProductBundleHooks.php: 96385 #: src/ProductBundleHooks.php:113 386 386 msgid "Product bundle" 387 387 msgstr "" 388 388 389 #: src/ProductBundleHooks.php: 193390 #: src/ProductBundleHooks.php: 196391 #: src/ProductBundleHooks.php: 198392 #: src/ProductBundleHooks.php:2 01389 #: src/ProductBundleHooks.php:210 390 #: src/ProductBundleHooks.php:213 391 #: src/ProductBundleHooks.php:215 392 #: src/ProductBundleHooks.php:218 393 393 msgid "From" 394 394 msgstr "" 395 395 396 #: src/ProductBundleHooks.php:2 35397 #: src/ProductBundleHooks.php:2 48396 #: src/ProductBundleHooks.php:252 397 #: src/ProductBundleHooks.php:265 398 398 msgid "Please select a product for each of the required bundle items." 399 399 msgstr "" 400 400 401 #: src/ProductBundleHooks.php:2 39401 #: src/ProductBundleHooks.php:256 402 402 msgid "Invalid product bundle." 403 403 msgstr "" 404 404 405 #: src/ProductBundleHooks.php:2 44405 #: src/ProductBundleHooks.php:261 406 406 msgid "Bundle product is unavailable." 407 407 msgstr "" 408 408 409 #: src/ProductBundleHooks.php:2 67409 #: src/ProductBundleHooks.php:284 410 410 #, php-format 411 411 msgid "Selected product for the bundle item %d is invalid." 412 412 msgstr "" 413 413 414 #: src/ProductBundleHooks.php:2 71414 #: src/ProductBundleHooks.php:288 415 415 #, php-format 416 416 msgid "Please select a variation for the bundle item "%s"." 417 417 msgstr "" 418 418 419 #: src/ProductBundleHooks.php:2 75419 #: src/ProductBundleHooks.php:292 420 420 msgid "This product is protected and cannot be purchased." 421 421 msgstr "" 422 422 423 #: src/ProductBundleHooks.php:2 79423 #: src/ProductBundleHooks.php:296 424 424 #, php-format 425 425 msgid "Product "%s" is not purchasable." 426 426 msgstr "" 427 427 428 #: src/ProductBundleHooks.php: 284429 #: src/ProductBundleHooks.php:3 66430 #: src/ProductBundleHooks.php:3 70431 #: src/ProductBundleHooks.php:3 73428 #: src/ProductBundleHooks.php:301 429 #: src/ProductBundleHooks.php:383 430 #: src/ProductBundleHooks.php:387 431 #: src/ProductBundleHooks.php:390 432 432 #, php-format 433 433 msgid "Please select a valid quantity for the bundle item "%s"." … … 435 435 436 436 #. translators: 1: product name 2: quantity in stock 437 #: src/ProductBundleHooks.php:296 437 #: src/ProductBundleHooks.php:313 438 #: src/ProductBundleHooks.php:414 439 #: src/ProductBundleHooks.php:539 440 #, php-format 441 msgid "You cannot add that amount of "%1$s" to the cart because there is not enough stock (%2$s remaining)." 442 msgstr "" 443 444 #: src/ProductBundleHooks.php:338 445 #: src/ProductBundleHooks.php:377 446 #: src/ProductBundleHooks.php:439 447 msgid "View cart" 448 msgstr "" 449 450 #. translators: 1: quantity in stock 2: current quantity 451 #: src/ProductBundleHooks.php:340 452 #: src/ProductBundleHooks.php:441 453 #, php-format 454 msgid "You cannot add that amount of "%1$s" to the cart — we have %2$s in stock and you already have %3$s in your cart." 455 msgstr "" 456 457 #. translators: %s: product name 458 #: src/ProductBundleHooks.php:367 459 #, php-format 460 msgid "You cannot add another \"%s\" to your cart." 461 msgstr "" 462 463 #. translators: %s: product name 438 464 #: src/ProductBundleHooks.php:397 439 #: src/ProductBundleHooks.php:522440 #, php-format441 msgid "You cannot add that amount of "%1$s" to the cart because there is not enough stock (%2$s remaining)."442 msgstr ""443 444 #: src/ProductBundleHooks.php:321445 #: src/ProductBundleHooks.php:360446 #: src/ProductBundleHooks.php:422447 msgid "View cart"448 msgstr ""449 450 #. translators: 1: quantity in stock 2: current quantity451 #: src/ProductBundleHooks.php:323452 #: src/ProductBundleHooks.php:424453 #, php-format454 msgid "You cannot add that amount of "%1$s" to the cart — we have %2$s in stock and you already have %3$s in your cart."455 msgstr ""456 457 #. translators: %s: product name458 #: src/ProductBundleHooks.php:350459 #, php-format460 msgid "You cannot add another \"%s\" to your cart."461 msgstr ""462 463 #. translators: %s: product name464 #: src/ProductBundleHooks.php:380465 465 #, php-format 466 466 msgid "You cannot add "%s" to the bundle item because the product is out of stock." 467 467 msgstr "" 468 468 469 #: src/ProductBundleHooks.php:4 42469 #: src/ProductBundleHooks.php:459 470 470 #, php-format 471 471 msgid "You cannot add "%s" to the bundle item because it is an invalid product." … … 473 473 474 474 #. Translators: %s Product title. 475 #: src/ProductBundleHooks.php: 498475 #: src/ProductBundleHooks.php:515 476 476 #, php-format 477 477 msgid "You can only have 1 %s in your cart." 478 478 msgstr "" 479 479 480 #: src/ProductBundleHooks.php:5 06480 #: src/ProductBundleHooks.php:523 481 481 #, php-format 482 482 msgid "Cart update failed. The quantity of "%1$s" must be at least %2$d." 483 483 msgstr "" 484 484 485 #: src/ProductBundleHooks.php:5 10485 #: src/ProductBundleHooks.php:527 486 486 #, php-format 487 487 msgid "Cart update failed. The quantity of "%1$s" cannot be higher than %2$d." 488 488 msgstr "" 489 489 490 #: src/ProductBundleHooks.php:5 14490 #: src/ProductBundleHooks.php:531 491 491 #, php-format 492 492 msgid "Cart update failed. The quantity of "%1$s" must be equal to %2$d." 493 493 msgstr "" 494 494 495 #: src/ProductBundleHooks.php:1 248495 #: src/ProductBundleHooks.php:1305 496 496 #, php-format 497 497 msgid "(Bundled in %s)" 498 498 msgstr "" 499 499 500 #: src/ProductBundleHooks.php:13 24501 #: src/ProductBundleHooks.php:13 36500 #: src/ProductBundleHooks.php:1381 501 #: src/ProductBundleHooks.php:1393 502 502 msgid "Invalid bundle product." 503 503 msgstr "" 504 504 505 #: src/ProductBundleHooks.php:13 29506 #: src/ProductBundleHooks.php:13 34505 #: src/ProductBundleHooks.php:1386 506 #: src/ProductBundleHooks.php:1391 507 507 msgid "Bundle product has not default items to add it to the order." 508 508 msgstr "" 509 509 510 #: src/ProductBundleHooks.php:14 05510 #: src/ProductBundleHooks.php:1462 511 511 msgid "Can not add bundle product to the order." 512 512 msgstr "" 513 513 514 #: src/ProductBundleHooks.php:14 15514 #: src/ProductBundleHooks.php:1472 515 515 msgid "Can not add bundle item to the order." 516 msgstr "" 517 518 #. translators: %s: bundle product name 519 #: src/ProductBundleHooks.php:1704 520 #, php-format 521 msgid "The bundle "%s" has been removed from your cart because one or more bundled items were removed or are unavailable." 516 522 msgstr "" 517 523 -
easy-product-bundles-for-woocommerce/tags/6.22.5/readme.txt
r3795471 r3821742 6 6 Tested up to: 7.1 7 7 Requires PHP: 5.6 8 Stable tag: 6.22. 48 Stable tag: 6.22.5 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 217 217 == Changelog == 218 218 219 = 6.22.5 = 220 * Fix: Cascade bundled child item removal to parent bundle and sibling items and validate bundle integrity in cart (Credit: kta1kri). 221 * Fix: Hide bundle items message in the WooCommerce Cart block. 222 * Removed: Removed the `asnp_wepb_apply_total_discount_on_bundle_in_cart` filter hook. 223 Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏 224 219 225 = 6.22.4 = 220 226 * Fix: Ensured proper float casting for regular and parent product prices. 221 227 * Fix: Replaced deprecated findDOMNode usage across components. 222 228 * Improved: Ensured compatibility with WooCommerce 11.2.2 223 Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏224 229 225 230 = 6.22.3 = -
easy-product-bundles-for-woocommerce/tags/6.22.5/src/Blocks/Integrations/CheckoutIntegration.php
r3722065 r3821742 35 35 'asnp-wepb-checkout-integration', 36 36 $this->get_url( 'checkout-integration/index', 'js' ), 37 [ 'wc-blocks-checkout' ],37 [ 'wc-blocks-checkout', 'wp-hooks' ], 38 38 ASNP_WEPB_VERSION, 39 39 $script_args -
easy-product-bundles-for-woocommerce/tags/6.22.5/src/ProductBundleHooks.php
r3795471 r3821742 11 11 const CART_ITEM_ITEMS = 'asnp_wepb_items'; 12 12 const CART_ITEM_ITEMS_KEY = 'asnp_wepb_items_key'; 13 14 /** 15 * Flag to prevent recursion during bundle item removal. 16 * 17 * @since 6.22.5 18 * @var bool 19 */ 20 private $is_removing = false; 21 22 /** 23 * Flag to prevent recursion during bundle item restoration. 24 * 25 * @since 6.22.5 26 * @var bool 27 */ 28 private $is_restoring = false; 13 29 14 30 public function init() { … … 84 100 add_filter( 'woocommerce_order_again_cart_item_data', array( $this, 'order_again_cart_item_data' ), 10, 2 ); 85 101 add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'cart_loaded_from_session' ) ); 102 add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_items' ) ); 86 103 } 87 104 … … 705 722 'asnp_wepb_item_quantity', 706 723 'asnp_wepb_hide_price', 707 'asnp_wepb_apply_total_discount',708 724 ]; 709 725 … … 715 731 716 732 return $cart_item; 717 }718 719 /**720 * Check if the total discount should be applied on the bundle in cart.721 *722 * Uses internal memoization in $cart_item to ensure O(1) performance and avoid723 * redundant filter executions during total calculations and cart rendering.724 *725 * @since 6.23.0726 *727 * @param array $cart_item Cart item data.728 *729 * @return bool730 */731 public function apply_total_discount_on_bundle_in_cart( $cart_item ) {732 if ( isset( $cart_item['asnp_wepb_apply_total_discount'] ) ) {733 return (bool) $cart_item['asnp_wepb_apply_total_discount'];734 }735 736 /**737 * Filters whether to apply the total discount on the bundle in cart.738 *739 * @since 6.23.0740 *741 * @param bool $apply Whether to apply the total discount. Default true.742 * @param array $cart_item Cart item data.743 */744 return (bool) apply_filters( 'asnp_wepb_apply_total_discount_on_bundle_in_cart', true, $cart_item );745 733 } 746 734 … … 813 801 } 814 802 815 $apply_total_discount = $this->apply_total_discount_on_bundle_in_cart( $cart_item ); 816 $cart_item['asnp_wepb_apply_total_discount'] = $apply_total_discount; 817 WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_apply_total_discount'] = $apply_total_discount; 818 819 $total_discount = $cart_item['data']->get_total_discount(); 803 $total_discount = $cart_item['data']->get_total_discount(); 820 804 $total_discount_type = $cart_item['data']->get_total_discount_type(); 821 805 822 806 if ( empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) { 823 807 $bundle_product = wc_get_product( $cart_item['product_id'] ); 824 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 825 826 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount ) { 827 $cart_item['data']->set_price( $parent_price - (float) $total_discount ); 828 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount ) { 829 $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) ); 808 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 809 810 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 811 $cart_item['data']->set_price( max( 0, $parent_price - (float) $total_discount ) ); 812 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 813 $cart_item['data']->set_price( max( 0, $parent_price - ( $parent_price * (float) $total_discount / 100 ) ) ); 814 } else { 815 $cart_item['data']->set_price( max( 0, $parent_price ) ); 830 816 } 831 817 continue; 832 818 } 833 819 820 $has_all_children = true; 821 if ( is_array( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) { 822 foreach ( $cart_item[ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 823 if ( ! isset( $cart_contents[ $item_key ] ) ) { 824 $has_all_children = false; 825 break; 826 } 827 } 828 } else { 829 $has_all_children = false; 830 } 831 832 if ( ! $has_all_children ) { 833 $cart_item['data']->set_price( 0 ); 834 continue; 835 } 836 834 837 if ( 'true' !== $cart_item['data']->get_include_parent_price() ) { 835 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {838 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 836 839 $cart_item['data']->set_price( (float) $total_discount * -1 ); 837 840 } else { … … 840 843 } else { 841 844 $bundle_product = wc_get_product( $cart_item['product_id'] ); 842 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0;843 844 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {845 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 846 847 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 845 848 $cart_item['data']->set_price( $parent_price - (float) $total_discount ); 846 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {849 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 847 850 $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) ); 848 851 } … … 853 856 if ( isset( $bundle_price['price'] ) ) { 854 857 WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_price'] = $bundle_price['price']; 858 } else { 859 $cart_item['data']->set_price( 0 ); 855 860 } 856 861 } … … 1038 1043 wc_get_price_excluding_tax( $cart_item['data'], [ 'price' => $exchange_price ? maybe_exchange_price( (float) $cart_item['data']->get_regular_price( 'edit' ) ) : (float) $cart_item['data']->get_regular_price( 'edit' ) ] ); 1039 1044 } 1040 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $this->apply_total_discount_on_bundle_in_cart( $cart_item )) {1045 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 1041 1046 $discount = $exchange_price ? maybe_exchange_price( (float) $total_discount ) : (float) $total_discount; 1042 1047 $price -= Cart\display_prices_including_tax() ? … … 1125 1130 } 1126 1131 } 1127 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $this->apply_total_discount_on_bundle_in_cart( $cart_item )) {1132 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 1128 1133 $price -= Cart\display_prices_including_tax() ? 1129 1134 wc_get_price_including_tax( $cart_item['data'], [ 'price' => maybe_exchange_price( (float) $total_discount ) ] ) : … … 1158 1163 } 1159 1164 1165 /** 1166 * Cascade bundle item removal. 1167 * 1168 * @since 1.0.0 1169 * @version 6.22.5 1170 * 1171 * @param string $cart_item_key Cart item key. 1172 * @param \WC_Cart $cart Cart object. 1173 * @return void 1174 */ 1160 1175 public function cart_item_removed( $cart_item_key, $cart ) { 1161 if ( empty( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] )) {1176 if ( $this->is_removing ) { 1162 1177 return; 1163 1178 } 1164 1179 1165 foreach ( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1166 $cart->remove_cart_item( $item_key ); 1167 } 1168 } 1169 1180 $already_removing = $this->is_removing; 1181 $this->is_removing = true; 1182 1183 try { 1184 if ( ! empty( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1185 foreach ( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1186 $cart->remove_cart_item( $item_key ); 1187 } 1188 } elseif ( isset( $cart->removed_cart_contents[ $cart_item_key ]['asnp_wepb_parent_key'] ) ) { 1189 $parent_key = $cart->removed_cart_contents[ $cart_item_key ]['asnp_wepb_parent_key']; 1190 if ( ! empty( $parent_key ) && isset( $cart->cart_contents[ $parent_key ] ) ) { 1191 $this->remove_bundle_from_cart( $parent_key, $cart ); 1192 } 1193 } 1194 } finally { 1195 $this->is_removing = $already_removing; 1196 } 1197 } 1198 1199 /** 1200 * Cascade bundle item restoration. 1201 * 1202 * @since 1.0.0 1203 * @version 6.22.5 1204 * 1205 * @param string $cart_item_key Cart item key. 1206 * @param \WC_Cart $cart Cart object. 1207 * @return void 1208 */ 1170 1209 public function cart_item_restored( $cart_item_key, $cart ) { 1171 if ( empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] )) {1210 if ( $this->is_restoring ) { 1172 1211 return; 1173 1212 } 1174 1213 1175 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1176 $cart->restore_cart_item( $item_key ); 1214 $already_restoring = $this->is_restoring; 1215 $this->is_restoring = true; 1216 1217 try { 1218 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1219 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1220 $cart->restore_cart_item( $item_key ); 1221 } 1222 } elseif ( isset( $cart->cart_contents[ $cart_item_key ]['asnp_wepb_parent_key'] ) ) { 1223 $parent_key = $cart->cart_contents[ $cart_item_key ]['asnp_wepb_parent_key']; 1224 if ( ! empty( $parent_key ) && ! isset( $cart->cart_contents[ $parent_key ] ) ) { 1225 if ( isset( $cart->removed_cart_contents[ $parent_key ] ) ) { 1226 $cart->restore_cart_item( $parent_key ); 1227 } else { 1228 $cart->remove_cart_item( $cart_item_key ); 1229 } 1230 } 1231 } 1232 } finally { 1233 $this->is_restoring = $already_restoring; 1177 1234 } 1178 1235 } … … 1554 1611 } 1555 1612 1613 // Removes the bundle parent from the cart when any of its child items are not present. 1614 if ( 1615 ! isset( $cart_item['asnp_wepb_order_again'] ) && 1616 is_cart_item_bundle( $cart_item ) && 1617 ! empty( $cart_item[ static::CART_ITEM_ITEMS_KEY ] ) && 1618 is_array( $cart_item[ static::CART_ITEM_ITEMS_KEY ] ) 1619 ) { 1620 foreach ( $cart_item[ static::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1621 if ( ! isset( $cart->cart_contents[ $item_key ] ) ) { 1622 $this->remove_bundle_from_cart( $cart_item_key, $cart ); 1623 break; 1624 } 1625 } 1626 } 1627 1556 1628 // Remove bundle items when order again is set. 1557 1629 if ( isset( $cart_item['asnp_wepb_order_again'], $cart_item['asnp_wepb_parent_id'] ) ) { … … 1574 1646 $cart->set_session(); 1575 1647 } 1648 } 1649 } 1650 } 1651 1652 /** 1653 * Validate cart items integrity for product bundles. 1654 * 1655 * @since 6.22.5 1656 * @return void 1657 */ 1658 public function check_cart_items() { 1659 $cart = WC()->cart; 1660 if ( ! $cart || $cart->is_empty() ) { 1661 return; 1662 } 1663 1664 $cart_contents = $cart->get_cart(); 1665 $removed_bundles = []; 1666 1667 foreach ( $cart_contents as $cart_item_key => $cart_item ) { 1668 if ( is_cart_item_bundle( $cart_item ) ) { 1669 $items_keys = ! empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) && \is_array( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) 1670 ? $cart_item[ self::CART_ITEM_ITEMS_KEY ] 1671 : []; 1672 1673 $has_missing_child = false; 1674 if ( empty( $items_keys ) ) { 1675 $has_missing_child = true; 1676 } else { 1677 foreach ( $items_keys as $child_key ) { 1678 if ( ! isset( $cart_contents[ $child_key ] ) ) { 1679 $has_missing_child = true; 1680 break; 1681 } 1682 } 1683 } 1684 1685 if ( $has_missing_child ) { 1686 $this->remove_bundle_from_cart( $cart_item_key, $cart ); 1687 if ( isset( $cart_item['data'] ) && \is_object( $cart_item['data'] ) ) { 1688 $removed_bundles[ $cart_item_key ] = $cart_item['data']->get_name(); 1689 } 1690 } 1691 } elseif ( is_cart_item_bundle_item( $cart_item ) ) { 1692 $parent_key = isset( $cart_item['asnp_wepb_parent_key'] ) ? $cart_item['asnp_wepb_parent_key'] : null; 1693 if ( ! $parent_key || ! isset( $cart_contents[ $parent_key ] ) ) { 1694 $cart->remove_cart_item( $cart_item_key ); 1695 } 1696 } 1697 } 1698 1699 if ( ! empty( $removed_bundles ) ) { 1700 foreach ( $removed_bundles as $bundle_name ) { 1701 wc_add_notice( 1702 sprintf( 1703 /* translators: %s: bundle product name */ 1704 __( 'The bundle "%s" has been removed from your cart because one or more bundled items were removed or are unavailable.', 'asnp-easy-product-bundles' ), 1705 $bundle_name 1706 ), 1707 'error' 1708 ); 1576 1709 } 1577 1710 } … … 1641 1774 } 1642 1775 1643 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1644 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1645 $cart->remove_cart_item( $item_key ); 1646 } 1647 } 1648 1649 $cart->remove_cart_item( $cart_item_key ); 1776 $already_removing = $this->is_removing; 1777 $this->is_removing = true; 1778 1779 try { 1780 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1781 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1782 $cart->remove_cart_item( $item_key ); 1783 } 1784 } 1785 1786 $cart->remove_cart_item( $cart_item_key ); 1787 } finally { 1788 $this->is_removing = $already_removing; 1789 } 1650 1790 } 1651 1791 -
easy-product-bundles-for-woocommerce/tags/6.22.5/vendor/composer/autoload_static.php
r3767259 r3821742 14 14 15 15 public static $prefixLengthsPsr4 = array ( 16 'A' => 16 'A' => 17 17 array ( 18 18 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 40, … … 21 21 22 22 public static $prefixDirsPsr4 = array ( 23 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 23 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 24 24 array ( 25 25 0 => __DIR__ . '/../..' . '/src', -
easy-product-bundles-for-woocommerce/tags/6.22.5/vendor/composer/installed.php
r3795471 r3821742 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 13b89f49ccae01083ce6250a815f6a2635eb2c1c',6 'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 13b89f49ccae01083ce6250a815f6a2635eb2c1c',16 'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
easy-product-bundles-for-woocommerce/trunk/assets/js/checkout-integration/index.js
r3767259 r3821742 1 (()=>{"use strict";var e, n,i,o,d={};o=d,"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0});var u=(null===(e=window)||void 0===e||null===(n=e.wc)||void 0===n||null===(i=n.blocksCheckout)||void 0===i?void 0:i.registerCheckoutFilters)||null,t=function(e){return e&&"undefined"!==typeof e.is_bundle_item};u&&u("easy-product-bundle",{cartItemClass:function(e,n,i){var o,d=null===n||void 0===n||null===(o=n.easy_product_bundle)||void 0===o?void 0:o.data;if(!d)return e;if(t(d))e+=" wepb-bundle-item","yes"===(null===d||void 0===d?void 0:d.hide_price)?e+=" wepb-hide-price":"regular"===(null===d||void 0===d?void 0:d.hide_price)&&(e+=" wepb-hide-regular-price");else if(function(e){return e&&"undefined"!==typeof e.is_bundle}(d))return"".concat(e," wepb-bundle");return e},showRemoveItemLink:function(e,n,i){var o,d=null===n||void 0===n||null===(o=n.easy_product_bundle)||void 0===o?void 0:o.data;return d?!t(d)&&e:e}}),(window.asnpWepb=window.asnpWepb||{})["checkout-integration"]=d})();1 (()=>{"use strict";var e,o,n,i,d,t,u,l={};u=l,"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0});var r=(null===(e=window)||void 0===e||null===(o=e.wc)||void 0===o||null===(n=o.blocksCheckout)||void 0===n?void 0:n.registerCheckoutFilters)||null,c=(null===(i=window)||void 0===i||null===(d=i.wp)||void 0===d||null===(t=d.hooks)||void 0===t?void 0:t.addFilter)||null,a=function(e){return e&&"undefined"!==typeof e.is_bundle_item},v=function(e,o){var n,i,d,t=(null===o||void 0===o||null===(n=o.extensions)||void 0===n||null===(i=n.easy_product_bundle)||void 0===i?void 0:i.data)||(null===o||void 0===o||null===(d=o.easy_product_bundle)||void 0===d?void 0:d.data);return t?!a(t)&&e:e};r&&r("easy-product-bundle",{cartItemClass:function(e,o,n){var i,d=null===o||void 0===o||null===(i=o.easy_product_bundle)||void 0===i?void 0:i.data;if(!d)return e;if(a(d))e+=" wepb-bundle-item","yes"===(null===d||void 0===d?void 0:d.hide_price)?e+=" wepb-hide-price":"regular"===(null===d||void 0===d?void 0:d.hide_price)&&(e+=" wepb-hide-regular-price");else if(function(e){return e&&"undefined"!==typeof e.is_bundle}(d))return"".concat(e," wepb-bundle");return e},showRemoveItemLink:function(e,o,n){var i,d=null===o||void 0===o||null===(i=o.easy_product_bundle)||void 0===i?void 0:i.data;return d?!a(d)&&e:e}}),c&&(c("woocommerce_show_cart_item_quantity_changed_notice","easy-product-bundle/show-cart-item-quantity-changed-notice",v),c("woocommerce_show_cart_item_removed_notice","easy-product-bundle/show-cart-item-removed-notice",v)),(window.asnpWepb=window.asnpWepb||{})["checkout-integration"]=l})(); -
easy-product-bundles-for-woocommerce/trunk/easy-product-bundles.php
r3795471 r3821742 7 7 * Description: Create product bundles in WooCommerce easily 8 8 * Tags: woocommerce, product bundles, bundled products 9 * Version: 6.22. 49 * Version: 6.22.5 10 10 * Author: Product Bundles Team 11 11 * Author URI: https://www.asanaplugins.com/ … … 25 25 // Plugin version. 26 26 if ( ! defined( 'ASNP_WEPB_VERSION' ) ) { 27 define( 'ASNP_WEPB_VERSION', '6.22. 4' );27 define( 'ASNP_WEPB_VERSION', '6.22.5' ); 28 28 } 29 29 -
easy-product-bundles-for-woocommerce/trunk/languages/asnp-easy-product-bundles.pot
r3795471 r3821742 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Easy Product Bundles for WooCommerce 6.22. 4\n"5 "Project-Id-Version: Easy Product Bundles for WooCommerce 6.22.5\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easy-product-bundles-for-woocommerce\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2026-11- 10T19:51:40+00:00\n"12 "POT-Creation-Date: 2026-11-24T23:26:47+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.12.0\n" … … 383 383 msgstr "" 384 384 385 #: src/ProductBundleHooks.php: 96385 #: src/ProductBundleHooks.php:113 386 386 msgid "Product bundle" 387 387 msgstr "" 388 388 389 #: src/ProductBundleHooks.php: 193390 #: src/ProductBundleHooks.php: 196391 #: src/ProductBundleHooks.php: 198392 #: src/ProductBundleHooks.php:2 01389 #: src/ProductBundleHooks.php:210 390 #: src/ProductBundleHooks.php:213 391 #: src/ProductBundleHooks.php:215 392 #: src/ProductBundleHooks.php:218 393 393 msgid "From" 394 394 msgstr "" 395 395 396 #: src/ProductBundleHooks.php:2 35397 #: src/ProductBundleHooks.php:2 48396 #: src/ProductBundleHooks.php:252 397 #: src/ProductBundleHooks.php:265 398 398 msgid "Please select a product for each of the required bundle items." 399 399 msgstr "" 400 400 401 #: src/ProductBundleHooks.php:2 39401 #: src/ProductBundleHooks.php:256 402 402 msgid "Invalid product bundle." 403 403 msgstr "" 404 404 405 #: src/ProductBundleHooks.php:2 44405 #: src/ProductBundleHooks.php:261 406 406 msgid "Bundle product is unavailable." 407 407 msgstr "" 408 408 409 #: src/ProductBundleHooks.php:2 67409 #: src/ProductBundleHooks.php:284 410 410 #, php-format 411 411 msgid "Selected product for the bundle item %d is invalid." 412 412 msgstr "" 413 413 414 #: src/ProductBundleHooks.php:2 71414 #: src/ProductBundleHooks.php:288 415 415 #, php-format 416 416 msgid "Please select a variation for the bundle item "%s"." 417 417 msgstr "" 418 418 419 #: src/ProductBundleHooks.php:2 75419 #: src/ProductBundleHooks.php:292 420 420 msgid "This product is protected and cannot be purchased." 421 421 msgstr "" 422 422 423 #: src/ProductBundleHooks.php:2 79423 #: src/ProductBundleHooks.php:296 424 424 #, php-format 425 425 msgid "Product "%s" is not purchasable." 426 426 msgstr "" 427 427 428 #: src/ProductBundleHooks.php: 284429 #: src/ProductBundleHooks.php:3 66430 #: src/ProductBundleHooks.php:3 70431 #: src/ProductBundleHooks.php:3 73428 #: src/ProductBundleHooks.php:301 429 #: src/ProductBundleHooks.php:383 430 #: src/ProductBundleHooks.php:387 431 #: src/ProductBundleHooks.php:390 432 432 #, php-format 433 433 msgid "Please select a valid quantity for the bundle item "%s"." … … 435 435 436 436 #. translators: 1: product name 2: quantity in stock 437 #: src/ProductBundleHooks.php:296 437 #: src/ProductBundleHooks.php:313 438 #: src/ProductBundleHooks.php:414 439 #: src/ProductBundleHooks.php:539 440 #, php-format 441 msgid "You cannot add that amount of "%1$s" to the cart because there is not enough stock (%2$s remaining)." 442 msgstr "" 443 444 #: src/ProductBundleHooks.php:338 445 #: src/ProductBundleHooks.php:377 446 #: src/ProductBundleHooks.php:439 447 msgid "View cart" 448 msgstr "" 449 450 #. translators: 1: quantity in stock 2: current quantity 451 #: src/ProductBundleHooks.php:340 452 #: src/ProductBundleHooks.php:441 453 #, php-format 454 msgid "You cannot add that amount of "%1$s" to the cart — we have %2$s in stock and you already have %3$s in your cart." 455 msgstr "" 456 457 #. translators: %s: product name 458 #: src/ProductBundleHooks.php:367 459 #, php-format 460 msgid "You cannot add another \"%s\" to your cart." 461 msgstr "" 462 463 #. translators: %s: product name 438 464 #: src/ProductBundleHooks.php:397 439 #: src/ProductBundleHooks.php:522440 #, php-format441 msgid "You cannot add that amount of "%1$s" to the cart because there is not enough stock (%2$s remaining)."442 msgstr ""443 444 #: src/ProductBundleHooks.php:321445 #: src/ProductBundleHooks.php:360446 #: src/ProductBundleHooks.php:422447 msgid "View cart"448 msgstr ""449 450 #. translators: 1: quantity in stock 2: current quantity451 #: src/ProductBundleHooks.php:323452 #: src/ProductBundleHooks.php:424453 #, php-format454 msgid "You cannot add that amount of "%1$s" to the cart — we have %2$s in stock and you already have %3$s in your cart."455 msgstr ""456 457 #. translators: %s: product name458 #: src/ProductBundleHooks.php:350459 #, php-format460 msgid "You cannot add another \"%s\" to your cart."461 msgstr ""462 463 #. translators: %s: product name464 #: src/ProductBundleHooks.php:380465 465 #, php-format 466 466 msgid "You cannot add "%s" to the bundle item because the product is out of stock." 467 467 msgstr "" 468 468 469 #: src/ProductBundleHooks.php:4 42469 #: src/ProductBundleHooks.php:459 470 470 #, php-format 471 471 msgid "You cannot add "%s" to the bundle item because it is an invalid product." … … 473 473 474 474 #. Translators: %s Product title. 475 #: src/ProductBundleHooks.php: 498475 #: src/ProductBundleHooks.php:515 476 476 #, php-format 477 477 msgid "You can only have 1 %s in your cart." 478 478 msgstr "" 479 479 480 #: src/ProductBundleHooks.php:5 06480 #: src/ProductBundleHooks.php:523 481 481 #, php-format 482 482 msgid "Cart update failed. The quantity of "%1$s" must be at least %2$d." 483 483 msgstr "" 484 484 485 #: src/ProductBundleHooks.php:5 10485 #: src/ProductBundleHooks.php:527 486 486 #, php-format 487 487 msgid "Cart update failed. The quantity of "%1$s" cannot be higher than %2$d." 488 488 msgstr "" 489 489 490 #: src/ProductBundleHooks.php:5 14490 #: src/ProductBundleHooks.php:531 491 491 #, php-format 492 492 msgid "Cart update failed. The quantity of "%1$s" must be equal to %2$d." 493 493 msgstr "" 494 494 495 #: src/ProductBundleHooks.php:1 248495 #: src/ProductBundleHooks.php:1305 496 496 #, php-format 497 497 msgid "(Bundled in %s)" 498 498 msgstr "" 499 499 500 #: src/ProductBundleHooks.php:13 24501 #: src/ProductBundleHooks.php:13 36500 #: src/ProductBundleHooks.php:1381 501 #: src/ProductBundleHooks.php:1393 502 502 msgid "Invalid bundle product." 503 503 msgstr "" 504 504 505 #: src/ProductBundleHooks.php:13 29506 #: src/ProductBundleHooks.php:13 34505 #: src/ProductBundleHooks.php:1386 506 #: src/ProductBundleHooks.php:1391 507 507 msgid "Bundle product has not default items to add it to the order." 508 508 msgstr "" 509 509 510 #: src/ProductBundleHooks.php:14 05510 #: src/ProductBundleHooks.php:1462 511 511 msgid "Can not add bundle product to the order." 512 512 msgstr "" 513 513 514 #: src/ProductBundleHooks.php:14 15514 #: src/ProductBundleHooks.php:1472 515 515 msgid "Can not add bundle item to the order." 516 msgstr "" 517 518 #. translators: %s: bundle product name 519 #: src/ProductBundleHooks.php:1704 520 #, php-format 521 msgid "The bundle "%s" has been removed from your cart because one or more bundled items were removed or are unavailable." 516 522 msgstr "" 517 523 -
easy-product-bundles-for-woocommerce/trunk/readme.txt
r3795471 r3821742 6 6 Tested up to: 7.1 7 7 Requires PHP: 5.6 8 Stable tag: 6.22. 48 Stable tag: 6.22.5 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 217 217 == Changelog == 218 218 219 = 6.22.5 = 220 * Fix: Cascade bundled child item removal to parent bundle and sibling items and validate bundle integrity in cart (Credit: kta1kri). 221 * Fix: Hide bundle items message in the WooCommerce Cart block. 222 * Removed: Removed the `asnp_wepb_apply_total_discount_on_bundle_in_cart` filter hook. 223 Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏 224 219 225 = 6.22.4 = 220 226 * Fix: Ensured proper float casting for regular and parent product prices. 221 227 * Fix: Replaced deprecated findDOMNode usage across components. 222 228 * Improved: Ensured compatibility with WooCommerce 11.2.2 223 Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏224 229 225 230 = 6.22.3 = -
easy-product-bundles-for-woocommerce/trunk/src/Blocks/Integrations/CheckoutIntegration.php
r3722065 r3821742 35 35 'asnp-wepb-checkout-integration', 36 36 $this->get_url( 'checkout-integration/index', 'js' ), 37 [ 'wc-blocks-checkout' ],37 [ 'wc-blocks-checkout', 'wp-hooks' ], 38 38 ASNP_WEPB_VERSION, 39 39 $script_args -
easy-product-bundles-for-woocommerce/trunk/src/ProductBundleHooks.php
r3795471 r3821742 11 11 const CART_ITEM_ITEMS = 'asnp_wepb_items'; 12 12 const CART_ITEM_ITEMS_KEY = 'asnp_wepb_items_key'; 13 14 /** 15 * Flag to prevent recursion during bundle item removal. 16 * 17 * @since 6.22.5 18 * @var bool 19 */ 20 private $is_removing = false; 21 22 /** 23 * Flag to prevent recursion during bundle item restoration. 24 * 25 * @since 6.22.5 26 * @var bool 27 */ 28 private $is_restoring = false; 13 29 14 30 public function init() { … … 84 100 add_filter( 'woocommerce_order_again_cart_item_data', array( $this, 'order_again_cart_item_data' ), 10, 2 ); 85 101 add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'cart_loaded_from_session' ) ); 102 add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_items' ) ); 86 103 } 87 104 … … 705 722 'asnp_wepb_item_quantity', 706 723 'asnp_wepb_hide_price', 707 'asnp_wepb_apply_total_discount',708 724 ]; 709 725 … … 715 731 716 732 return $cart_item; 717 }718 719 /**720 * Check if the total discount should be applied on the bundle in cart.721 *722 * Uses internal memoization in $cart_item to ensure O(1) performance and avoid723 * redundant filter executions during total calculations and cart rendering.724 *725 * @since 6.23.0726 *727 * @param array $cart_item Cart item data.728 *729 * @return bool730 */731 public function apply_total_discount_on_bundle_in_cart( $cart_item ) {732 if ( isset( $cart_item['asnp_wepb_apply_total_discount'] ) ) {733 return (bool) $cart_item['asnp_wepb_apply_total_discount'];734 }735 736 /**737 * Filters whether to apply the total discount on the bundle in cart.738 *739 * @since 6.23.0740 *741 * @param bool $apply Whether to apply the total discount. Default true.742 * @param array $cart_item Cart item data.743 */744 return (bool) apply_filters( 'asnp_wepb_apply_total_discount_on_bundle_in_cart', true, $cart_item );745 733 } 746 734 … … 813 801 } 814 802 815 $apply_total_discount = $this->apply_total_discount_on_bundle_in_cart( $cart_item ); 816 $cart_item['asnp_wepb_apply_total_discount'] = $apply_total_discount; 817 WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_apply_total_discount'] = $apply_total_discount; 818 819 $total_discount = $cart_item['data']->get_total_discount(); 803 $total_discount = $cart_item['data']->get_total_discount(); 820 804 $total_discount_type = $cart_item['data']->get_total_discount_type(); 821 805 822 806 if ( empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) { 823 807 $bundle_product = wc_get_product( $cart_item['product_id'] ); 824 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 825 826 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount ) { 827 $cart_item['data']->set_price( $parent_price - (float) $total_discount ); 828 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount ) { 829 $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) ); 808 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 809 810 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 811 $cart_item['data']->set_price( max( 0, $parent_price - (float) $total_discount ) ); 812 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 813 $cart_item['data']->set_price( max( 0, $parent_price - ( $parent_price * (float) $total_discount / 100 ) ) ); 814 } else { 815 $cart_item['data']->set_price( max( 0, $parent_price ) ); 830 816 } 831 817 continue; 832 818 } 833 819 820 $has_all_children = true; 821 if ( is_array( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) { 822 foreach ( $cart_item[ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 823 if ( ! isset( $cart_contents[ $item_key ] ) ) { 824 $has_all_children = false; 825 break; 826 } 827 } 828 } else { 829 $has_all_children = false; 830 } 831 832 if ( ! $has_all_children ) { 833 $cart_item['data']->set_price( 0 ); 834 continue; 835 } 836 834 837 if ( 'true' !== $cart_item['data']->get_include_parent_price() ) { 835 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {838 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 836 839 $cart_item['data']->set_price( (float) $total_discount * -1 ); 837 840 } else { … … 840 843 } else { 841 844 $bundle_product = wc_get_product( $cart_item['product_id'] ); 842 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0;843 844 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {845 $parent_price = $bundle_product ? (float) $bundle_product->get_price( 'edit' ) : 0; 846 847 if ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 845 848 $cart_item['data']->set_price( $parent_price - (float) $total_discount ); 846 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $apply_total_discount) {849 } elseif ( 0 < $parent_price && 'percentage' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 847 850 $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) ); 848 851 } … … 853 856 if ( isset( $bundle_price['price'] ) ) { 854 857 WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_price'] = $bundle_price['price']; 858 } else { 859 $cart_item['data']->set_price( 0 ); 855 860 } 856 861 } … … 1038 1043 wc_get_price_excluding_tax( $cart_item['data'], [ 'price' => $exchange_price ? maybe_exchange_price( (float) $cart_item['data']->get_regular_price( 'edit' ) ) : (float) $cart_item['data']->get_regular_price( 'edit' ) ] ); 1039 1044 } 1040 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $this->apply_total_discount_on_bundle_in_cart( $cart_item )) {1045 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 1041 1046 $discount = $exchange_price ? maybe_exchange_price( (float) $total_discount ) : (float) $total_discount; 1042 1047 $price -= Cart\display_prices_including_tax() ? … … 1125 1130 } 1126 1131 } 1127 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount && $this->apply_total_discount_on_bundle_in_cart( $cart_item )) {1132 } elseif ( 'price' === $total_discount_type && '' !== $total_discount && 0 < (float) $total_discount ) { 1128 1133 $price -= Cart\display_prices_including_tax() ? 1129 1134 wc_get_price_including_tax( $cart_item['data'], [ 'price' => maybe_exchange_price( (float) $total_discount ) ] ) : … … 1158 1163 } 1159 1164 1165 /** 1166 * Cascade bundle item removal. 1167 * 1168 * @since 1.0.0 1169 * @version 6.22.5 1170 * 1171 * @param string $cart_item_key Cart item key. 1172 * @param \WC_Cart $cart Cart object. 1173 * @return void 1174 */ 1160 1175 public function cart_item_removed( $cart_item_key, $cart ) { 1161 if ( empty( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] )) {1176 if ( $this->is_removing ) { 1162 1177 return; 1163 1178 } 1164 1179 1165 foreach ( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1166 $cart->remove_cart_item( $item_key ); 1167 } 1168 } 1169 1180 $already_removing = $this->is_removing; 1181 $this->is_removing = true; 1182 1183 try { 1184 if ( ! empty( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1185 foreach ( $cart->removed_cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1186 $cart->remove_cart_item( $item_key ); 1187 } 1188 } elseif ( isset( $cart->removed_cart_contents[ $cart_item_key ]['asnp_wepb_parent_key'] ) ) { 1189 $parent_key = $cart->removed_cart_contents[ $cart_item_key ]['asnp_wepb_parent_key']; 1190 if ( ! empty( $parent_key ) && isset( $cart->cart_contents[ $parent_key ] ) ) { 1191 $this->remove_bundle_from_cart( $parent_key, $cart ); 1192 } 1193 } 1194 } finally { 1195 $this->is_removing = $already_removing; 1196 } 1197 } 1198 1199 /** 1200 * Cascade bundle item restoration. 1201 * 1202 * @since 1.0.0 1203 * @version 6.22.5 1204 * 1205 * @param string $cart_item_key Cart item key. 1206 * @param \WC_Cart $cart Cart object. 1207 * @return void 1208 */ 1170 1209 public function cart_item_restored( $cart_item_key, $cart ) { 1171 if ( empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] )) {1210 if ( $this->is_restoring ) { 1172 1211 return; 1173 1212 } 1174 1213 1175 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1176 $cart->restore_cart_item( $item_key ); 1214 $already_restoring = $this->is_restoring; 1215 $this->is_restoring = true; 1216 1217 try { 1218 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1219 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1220 $cart->restore_cart_item( $item_key ); 1221 } 1222 } elseif ( isset( $cart->cart_contents[ $cart_item_key ]['asnp_wepb_parent_key'] ) ) { 1223 $parent_key = $cart->cart_contents[ $cart_item_key ]['asnp_wepb_parent_key']; 1224 if ( ! empty( $parent_key ) && ! isset( $cart->cart_contents[ $parent_key ] ) ) { 1225 if ( isset( $cart->removed_cart_contents[ $parent_key ] ) ) { 1226 $cart->restore_cart_item( $parent_key ); 1227 } else { 1228 $cart->remove_cart_item( $cart_item_key ); 1229 } 1230 } 1231 } 1232 } finally { 1233 $this->is_restoring = $already_restoring; 1177 1234 } 1178 1235 } … … 1554 1611 } 1555 1612 1613 // Removes the bundle parent from the cart when any of its child items are not present. 1614 if ( 1615 ! isset( $cart_item['asnp_wepb_order_again'] ) && 1616 is_cart_item_bundle( $cart_item ) && 1617 ! empty( $cart_item[ static::CART_ITEM_ITEMS_KEY ] ) && 1618 is_array( $cart_item[ static::CART_ITEM_ITEMS_KEY ] ) 1619 ) { 1620 foreach ( $cart_item[ static::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1621 if ( ! isset( $cart->cart_contents[ $item_key ] ) ) { 1622 $this->remove_bundle_from_cart( $cart_item_key, $cart ); 1623 break; 1624 } 1625 } 1626 } 1627 1556 1628 // Remove bundle items when order again is set. 1557 1629 if ( isset( $cart_item['asnp_wepb_order_again'], $cart_item['asnp_wepb_parent_id'] ) ) { … … 1574 1646 $cart->set_session(); 1575 1647 } 1648 } 1649 } 1650 } 1651 1652 /** 1653 * Validate cart items integrity for product bundles. 1654 * 1655 * @since 6.22.5 1656 * @return void 1657 */ 1658 public function check_cart_items() { 1659 $cart = WC()->cart; 1660 if ( ! $cart || $cart->is_empty() ) { 1661 return; 1662 } 1663 1664 $cart_contents = $cart->get_cart(); 1665 $removed_bundles = []; 1666 1667 foreach ( $cart_contents as $cart_item_key => $cart_item ) { 1668 if ( is_cart_item_bundle( $cart_item ) ) { 1669 $items_keys = ! empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) && \is_array( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) 1670 ? $cart_item[ self::CART_ITEM_ITEMS_KEY ] 1671 : []; 1672 1673 $has_missing_child = false; 1674 if ( empty( $items_keys ) ) { 1675 $has_missing_child = true; 1676 } else { 1677 foreach ( $items_keys as $child_key ) { 1678 if ( ! isset( $cart_contents[ $child_key ] ) ) { 1679 $has_missing_child = true; 1680 break; 1681 } 1682 } 1683 } 1684 1685 if ( $has_missing_child ) { 1686 $this->remove_bundle_from_cart( $cart_item_key, $cart ); 1687 if ( isset( $cart_item['data'] ) && \is_object( $cart_item['data'] ) ) { 1688 $removed_bundles[ $cart_item_key ] = $cart_item['data']->get_name(); 1689 } 1690 } 1691 } elseif ( is_cart_item_bundle_item( $cart_item ) ) { 1692 $parent_key = isset( $cart_item['asnp_wepb_parent_key'] ) ? $cart_item['asnp_wepb_parent_key'] : null; 1693 if ( ! $parent_key || ! isset( $cart_contents[ $parent_key ] ) ) { 1694 $cart->remove_cart_item( $cart_item_key ); 1695 } 1696 } 1697 } 1698 1699 if ( ! empty( $removed_bundles ) ) { 1700 foreach ( $removed_bundles as $bundle_name ) { 1701 wc_add_notice( 1702 sprintf( 1703 /* translators: %s: bundle product name */ 1704 __( 'The bundle "%s" has been removed from your cart because one or more bundled items were removed or are unavailable.', 'asnp-easy-product-bundles' ), 1705 $bundle_name 1706 ), 1707 'error' 1708 ); 1576 1709 } 1577 1710 } … … 1641 1774 } 1642 1775 1643 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1644 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1645 $cart->remove_cart_item( $item_key ); 1646 } 1647 } 1648 1649 $cart->remove_cart_item( $cart_item_key ); 1776 $already_removing = $this->is_removing; 1777 $this->is_removing = true; 1778 1779 try { 1780 if ( ! empty( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] ) ) { 1781 foreach ( $cart->cart_contents[ $cart_item_key ][ self::CART_ITEM_ITEMS_KEY ] as $item_key ) { 1782 $cart->remove_cart_item( $item_key ); 1783 } 1784 } 1785 1786 $cart->remove_cart_item( $cart_item_key ); 1787 } finally { 1788 $this->is_removing = $already_removing; 1789 } 1650 1790 } 1651 1791 -
easy-product-bundles-for-woocommerce/trunk/vendor/composer/autoload_static.php
r3767259 r3821742 14 14 15 15 public static $prefixLengthsPsr4 = array ( 16 'A' => 16 'A' => 17 17 array ( 18 18 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 40, … … 21 21 22 22 public static $prefixDirsPsr4 = array ( 23 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 23 'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 24 24 array ( 25 25 0 => __DIR__ . '/../..' . '/src', -
easy-product-bundles-for-woocommerce/trunk/vendor/composer/installed.php
r3795471 r3821742 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 13b89f49ccae01083ce6250a815f6a2635eb2c1c',6 'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 13b89f49ccae01083ce6250a815f6a2635eb2c1c',16 'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note:
See TracChangeset
for help on using the changeset viewer.