Plugin Directory

Changeset 3821742


Ignore:
Timestamp:
11/25/2026 12:00:35 AM (111 minutes ago)
Author:
asanaplugins
Message:

Update to version 6.22.5 from GitHub

Location:
easy-product-bundles-for-woocommerce
Files:
16 edited
1 copied

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  
    77 * Description: Create product bundles in WooCommerce easily
    88 * Tags: woocommerce, product bundles, bundled products
    9  * Version: 6.22.4
     9 * Version: 6.22.5
    1010 * Author: Product Bundles Team
    1111 * Author URI: https://www.asanaplugins.com/
    … …  
    2525// Plugin version.
    2626if ( ! defined( 'ASNP_WEPB_VERSION' ) ) {
    27         define( 'ASNP_WEPB_VERSION', '6.22.4' );
     27        define( 'ASNP_WEPB_VERSION', '6.22.5' );
    2828}
    2929
  • easy-product-bundles-for-woocommerce/tags/6.22.5/languages/asnp-easy-product-bundles.pot

    r3795471 r3821742  
    33msgid ""
    44msgstr ""
    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"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easy-product-bundles-for-woocommerce\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    … …  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"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"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
    … …  
    383383msgstr ""
    384384
    385 #: src/ProductBundleHooks.php:96
     385#: src/ProductBundleHooks.php:113
    386386msgid "Product bundle"
    387387msgstr ""
    388388
    389 #: src/ProductBundleHooks.php:193
    390 #: src/ProductBundleHooks.php:196
    391 #: src/ProductBundleHooks.php:198
    392 #: src/ProductBundleHooks.php:201
     389#: src/ProductBundleHooks.php:210
     390#: src/ProductBundleHooks.php:213
     391#: src/ProductBundleHooks.php:215
     392#: src/ProductBundleHooks.php:218
    393393msgid "From"
    394394msgstr ""
    395395
    396 #: src/ProductBundleHooks.php:235
    397 #: src/ProductBundleHooks.php:248
     396#: src/ProductBundleHooks.php:252
     397#: src/ProductBundleHooks.php:265
    398398msgid "Please select a product for each of the required bundle items."
    399399msgstr ""
    400400
    401 #: src/ProductBundleHooks.php:239
     401#: src/ProductBundleHooks.php:256
    402402msgid "Invalid product bundle."
    403403msgstr ""
    404404
    405 #: src/ProductBundleHooks.php:244
     405#: src/ProductBundleHooks.php:261
    406406msgid "Bundle product is unavailable."
    407407msgstr ""
    408408
    409 #: src/ProductBundleHooks.php:267
     409#: src/ProductBundleHooks.php:284
    410410#, php-format
    411411msgid "Selected product for the bundle item %d is invalid."
    412412msgstr ""
    413413
    414 #: src/ProductBundleHooks.php:271
     414#: src/ProductBundleHooks.php:288
    415415#, php-format
    416416msgid "Please select a variation for the bundle item &quot;%s&quot;."
    417417msgstr ""
    418418
    419 #: src/ProductBundleHooks.php:275
     419#: src/ProductBundleHooks.php:292
    420420msgid "This product is protected and cannot be purchased."
    421421msgstr ""
    422422
    423 #: src/ProductBundleHooks.php:279
     423#: src/ProductBundleHooks.php:296
    424424#, php-format
    425425msgid "Product &quot;%s&quot; is not purchasable."
    426426msgstr ""
    427427
    428 #: src/ProductBundleHooks.php:284
    429 #: src/ProductBundleHooks.php:366
    430 #: src/ProductBundleHooks.php:370
    431 #: src/ProductBundleHooks.php:373
     428#: src/ProductBundleHooks.php:301
     429#: src/ProductBundleHooks.php:383
     430#: src/ProductBundleHooks.php:387
     431#: src/ProductBundleHooks.php:390
    432432#, php-format
    433433msgid "Please select a valid quantity for the bundle item &quot;%s&quot;."
    … …  
    435435
    436436#. 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
     441msgid "You cannot add that amount of &quot;%1$s&quot; to the cart because there is not enough stock (%2$s remaining)."
     442msgstr ""
     443
     444#: src/ProductBundleHooks.php:338
     445#: src/ProductBundleHooks.php:377
     446#: src/ProductBundleHooks.php:439
     447msgid "View cart"
     448msgstr ""
     449
     450#. translators: 1: quantity in stock 2: current quantity
     451#: src/ProductBundleHooks.php:340
     452#: src/ProductBundleHooks.php:441
     453#, php-format
     454msgid "You cannot add that amount of &quot;%1$s&quot; to the cart &mdash; we have %2$s in stock and you already have %3$s in your cart."
     455msgstr ""
     456
     457#. translators: %s: product name
     458#: src/ProductBundleHooks.php:367
     459#, php-format
     460msgid "You cannot add another \"%s\" to your cart."
     461msgstr ""
     462
     463#. translators: %s: product name
    438464#: src/ProductBundleHooks.php:397
    439 #: src/ProductBundleHooks.php:522
    440 #, php-format
    441 msgid "You cannot add that amount of &quot;%1$s&quot; to the cart because there is not enough stock (%2$s remaining)."
    442 msgstr ""
    443 
    444 #: src/ProductBundleHooks.php:321
    445 #: src/ProductBundleHooks.php:360
    446 #: src/ProductBundleHooks.php:422
    447 msgid "View cart"
    448 msgstr ""
    449 
    450 #. translators: 1: quantity in stock 2: current quantity
    451 #: src/ProductBundleHooks.php:323
    452 #: src/ProductBundleHooks.php:424
    453 #, php-format
    454 msgid "You cannot add that amount of &quot;%1$s&quot; to the cart &mdash; 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:350
    459 #, php-format
    460 msgid "You cannot add another \"%s\" to your cart."
    461 msgstr ""
    462 
    463 #. translators: %s: product name
    464 #: src/ProductBundleHooks.php:380
    465465#, php-format
    466466msgid "You cannot add &quot;%s&quot; to the bundle item because the product is out of stock."
    467467msgstr ""
    468468
    469 #: src/ProductBundleHooks.php:442
     469#: src/ProductBundleHooks.php:459
    470470#, php-format
    471471msgid "You cannot add &quot;%s&quot; to the bundle item because it is an invalid product."
    … …  
    473473
    474474#. Translators: %s Product title.
    475 #: src/ProductBundleHooks.php:498
     475#: src/ProductBundleHooks.php:515
    476476#, php-format
    477477msgid "You can only have 1 %s in your cart."
    478478msgstr ""
    479479
    480 #: src/ProductBundleHooks.php:506
     480#: src/ProductBundleHooks.php:523
    481481#, php-format
    482482msgid "Cart update failed. The quantity of &quot;%1$s&quot; must be at least %2$d."
    483483msgstr ""
    484484
    485 #: src/ProductBundleHooks.php:510
     485#: src/ProductBundleHooks.php:527
    486486#, php-format
    487487msgid "Cart update failed. The quantity of &quot;%1$s&quot; cannot be higher than %2$d."
    488488msgstr ""
    489489
    490 #: src/ProductBundleHooks.php:514
     490#: src/ProductBundleHooks.php:531
    491491#, php-format
    492492msgid "Cart update failed. The quantity of &quot;%1$s&quot; must be equal to %2$d."
    493493msgstr ""
    494494
    495 #: src/ProductBundleHooks.php:1248
     495#: src/ProductBundleHooks.php:1305
    496496#, php-format
    497497msgid "(Bundled in %s)"
    498498msgstr ""
    499499
    500 #: src/ProductBundleHooks.php:1324
    501 #: src/ProductBundleHooks.php:1336
     500#: src/ProductBundleHooks.php:1381
     501#: src/ProductBundleHooks.php:1393
    502502msgid "Invalid bundle product."
    503503msgstr ""
    504504
    505 #: src/ProductBundleHooks.php:1329
    506 #: src/ProductBundleHooks.php:1334
     505#: src/ProductBundleHooks.php:1386
     506#: src/ProductBundleHooks.php:1391
    507507msgid "Bundle product has not default items to add it to the order."
    508508msgstr ""
    509509
    510 #: src/ProductBundleHooks.php:1405
     510#: src/ProductBundleHooks.php:1462
    511511msgid "Can not add bundle product to the order."
    512512msgstr ""
    513513
    514 #: src/ProductBundleHooks.php:1415
     514#: src/ProductBundleHooks.php:1472
    515515msgid "Can not add bundle item to the order."
     516msgstr ""
     517
     518#. translators: %s: bundle product name
     519#: src/ProductBundleHooks.php:1704
     520#, php-format
     521msgid "The bundle &quot;%s&quot; has been removed from your cart because one or more bundled items were removed or are unavailable."
    516522msgstr ""
    517523
  • easy-product-bundles-for-woocommerce/tags/6.22.5/readme.txt

    r3795471 r3821742  
    66Tested up to: 7.1
    77Requires PHP: 5.6
    8 Stable tag: 6.22.4
     8Stable tag: 6.22.5
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    217217== Changelog ==
    218218
     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.
     223Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏
     224
    219225= 6.22.4 =
    220226* Fix: Ensured proper float casting for regular and parent product prices.
    221227* Fix: Replaced deprecated findDOMNode usage across components.
    222228* 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.🙏
    224229
    225230= 6.22.3 =
  • easy-product-bundles-for-woocommerce/tags/6.22.5/src/Blocks/Integrations/CheckoutIntegration.php

    r3722065 r3821742  
    3535                        'asnp-wepb-checkout-integration',
    3636                        $this->get_url( 'checkout-integration/index', 'js' ),
    37                         [ 'wc-blocks-checkout' ],
     37                        [ 'wc-blocks-checkout', 'wp-hooks' ],
    3838                        ASNP_WEPB_VERSION,
    3939                        $script_args
  • easy-product-bundles-for-woocommerce/tags/6.22.5/src/ProductBundleHooks.php

    r3795471 r3821742  
    1111        const CART_ITEM_ITEMS = 'asnp_wepb_items';
    1212        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;
    1329
    1430        public function init() {
    … …  
    84100                add_filter( 'woocommerce_order_again_cart_item_data', array( $this, 'order_again_cart_item_data' ), 10, 2 );
    85101                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' ) );
    86103        }
    87104
    … …  
    705722                        'asnp_wepb_item_quantity',
    706723                        'asnp_wepb_hide_price',
    707                         'asnp_wepb_apply_total_discount',
    708724                ];
    709725
    … …  
    715731
    716732                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 avoid
    723          * redundant filter executions during total calculations and cart rendering.
    724          *
    725          * @since 6.23.0
    726          *
    727          * @param array $cart_item Cart item data.
    728          *
    729          * @return bool
    730          */
    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.0
    740                  *
    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 );
    745733        }
    746734
    … …  
    813801                                }
    814802
    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();
    820804                                $total_discount_type = $cart_item['data']->get_total_discount_type();
    821805
    822806                                if ( empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) {
    823807                                        $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 ) );
    830816                                        }
    831817                                        continue;
    832818                                }
    833819
     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
    834837                                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 ) {
    836839                                                $cart_item['data']->set_price( (float) $total_discount * -1 );
    837840                                        } else {
    … …  
    840843                                } else {
    841844                                        $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 ) {
    845848                                                $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 ) {
    847850                                                $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) );
    848851                                        }
    … …  
    853856                                if ( isset( $bundle_price['price'] ) ) {
    854857                                        WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_price'] = $bundle_price['price'];
     858                                } else {
     859                                        $cart_item['data']->set_price( 0 );
    855860                                }
    856861                        }
    … …  
    10381043                                        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' ) ] );
    10391044                        }
    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 ) {
    10411046                        $discount = $exchange_price ? maybe_exchange_price( (float) $total_discount ) : (float) $total_discount;
    10421047                        $price -= Cart\display_prices_including_tax() ?
    … …  
    11251130                                }
    11261131                        }
    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 ) {
    11281133                        $price -= Cart\display_prices_including_tax() ?
    11291134                                wc_get_price_including_tax( $cart_item['data'], [ 'price' => maybe_exchange_price( (float) $total_discount ) ] ) :
    … …  
    11581163        }
    11591164
     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         */
    11601175        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 ) {
    11621177                        return;
    11631178                }
    11641179
    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         */
    11701209        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 ) {
    11721211                        return;
    11731212                }
    11741213
    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;
    11771234                }
    11781235        }
    … …  
    15541611                        }
    15551612
     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
    15561628                        // Remove bundle items when order again is set.
    15571629                        if ( isset( $cart_item['asnp_wepb_order_again'], $cart_item['asnp_wepb_parent_id'] ) ) {
    … …  
    15741646                                        $cart->set_session();
    15751647                                }
     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 &quot;%s&quot; 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                                );
    15761709                        }
    15771710                }
    … …  
    16411774                }
    16421775
    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                }
    16501790        }
    16511791
  • easy-product-bundles-for-woocommerce/tags/6.22.5/vendor/composer/autoload_static.php

    r3767259 r3821742  
    1414
    1515    public static $prefixLengthsPsr4 = array (
    16         'A' =>
     16        'A' => 
    1717        array (
    1818            'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 40,
    … …  
    2121
    2222    public static $prefixDirsPsr4 = array (
    23         'AsanaPlugins\\WooCommerce\\ProductBundles\\' =>
     23        'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 
    2424        array (
    2525            0 => __DIR__ . '/../..' . '/src',
  • easy-product-bundles-for-woocommerce/tags/6.22.5/vendor/composer/installed.php

    r3795471 r3821742  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '13b89f49ccae01083ce6250a815f6a2635eb2c1c',
     6        'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
    … …  
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '13b89f49ccae01083ce6250a815f6a2635eb2c1c',
     16            'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433',
    1717            'type' => 'wordpress-plugin',
    1818            '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  
    77 * Description: Create product bundles in WooCommerce easily
    88 * Tags: woocommerce, product bundles, bundled products
    9  * Version: 6.22.4
     9 * Version: 6.22.5
    1010 * Author: Product Bundles Team
    1111 * Author URI: https://www.asanaplugins.com/
    … …  
    2525// Plugin version.
    2626if ( ! defined( 'ASNP_WEPB_VERSION' ) ) {
    27         define( 'ASNP_WEPB_VERSION', '6.22.4' );
     27        define( 'ASNP_WEPB_VERSION', '6.22.5' );
    2828}
    2929
  • easy-product-bundles-for-woocommerce/trunk/languages/asnp-easy-product-bundles.pot

    r3795471 r3821742  
    33msgid ""
    44msgstr ""
    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"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easy-product-bundles-for-woocommerce\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    … …  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"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"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
    … …  
    383383msgstr ""
    384384
    385 #: src/ProductBundleHooks.php:96
     385#: src/ProductBundleHooks.php:113
    386386msgid "Product bundle"
    387387msgstr ""
    388388
    389 #: src/ProductBundleHooks.php:193
    390 #: src/ProductBundleHooks.php:196
    391 #: src/ProductBundleHooks.php:198
    392 #: src/ProductBundleHooks.php:201
     389#: src/ProductBundleHooks.php:210
     390#: src/ProductBundleHooks.php:213
     391#: src/ProductBundleHooks.php:215
     392#: src/ProductBundleHooks.php:218
    393393msgid "From"
    394394msgstr ""
    395395
    396 #: src/ProductBundleHooks.php:235
    397 #: src/ProductBundleHooks.php:248
     396#: src/ProductBundleHooks.php:252
     397#: src/ProductBundleHooks.php:265
    398398msgid "Please select a product for each of the required bundle items."
    399399msgstr ""
    400400
    401 #: src/ProductBundleHooks.php:239
     401#: src/ProductBundleHooks.php:256
    402402msgid "Invalid product bundle."
    403403msgstr ""
    404404
    405 #: src/ProductBundleHooks.php:244
     405#: src/ProductBundleHooks.php:261
    406406msgid "Bundle product is unavailable."
    407407msgstr ""
    408408
    409 #: src/ProductBundleHooks.php:267
     409#: src/ProductBundleHooks.php:284
    410410#, php-format
    411411msgid "Selected product for the bundle item %d is invalid."
    412412msgstr ""
    413413
    414 #: src/ProductBundleHooks.php:271
     414#: src/ProductBundleHooks.php:288
    415415#, php-format
    416416msgid "Please select a variation for the bundle item &quot;%s&quot;."
    417417msgstr ""
    418418
    419 #: src/ProductBundleHooks.php:275
     419#: src/ProductBundleHooks.php:292
    420420msgid "This product is protected and cannot be purchased."
    421421msgstr ""
    422422
    423 #: src/ProductBundleHooks.php:279
     423#: src/ProductBundleHooks.php:296
    424424#, php-format
    425425msgid "Product &quot;%s&quot; is not purchasable."
    426426msgstr ""
    427427
    428 #: src/ProductBundleHooks.php:284
    429 #: src/ProductBundleHooks.php:366
    430 #: src/ProductBundleHooks.php:370
    431 #: src/ProductBundleHooks.php:373
     428#: src/ProductBundleHooks.php:301
     429#: src/ProductBundleHooks.php:383
     430#: src/ProductBundleHooks.php:387
     431#: src/ProductBundleHooks.php:390
    432432#, php-format
    433433msgid "Please select a valid quantity for the bundle item &quot;%s&quot;."
    … …  
    435435
    436436#. 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
     441msgid "You cannot add that amount of &quot;%1$s&quot; to the cart because there is not enough stock (%2$s remaining)."
     442msgstr ""
     443
     444#: src/ProductBundleHooks.php:338
     445#: src/ProductBundleHooks.php:377
     446#: src/ProductBundleHooks.php:439
     447msgid "View cart"
     448msgstr ""
     449
     450#. translators: 1: quantity in stock 2: current quantity
     451#: src/ProductBundleHooks.php:340
     452#: src/ProductBundleHooks.php:441
     453#, php-format
     454msgid "You cannot add that amount of &quot;%1$s&quot; to the cart &mdash; we have %2$s in stock and you already have %3$s in your cart."
     455msgstr ""
     456
     457#. translators: %s: product name
     458#: src/ProductBundleHooks.php:367
     459#, php-format
     460msgid "You cannot add another \"%s\" to your cart."
     461msgstr ""
     462
     463#. translators: %s: product name
    438464#: src/ProductBundleHooks.php:397
    439 #: src/ProductBundleHooks.php:522
    440 #, php-format
    441 msgid "You cannot add that amount of &quot;%1$s&quot; to the cart because there is not enough stock (%2$s remaining)."
    442 msgstr ""
    443 
    444 #: src/ProductBundleHooks.php:321
    445 #: src/ProductBundleHooks.php:360
    446 #: src/ProductBundleHooks.php:422
    447 msgid "View cart"
    448 msgstr ""
    449 
    450 #. translators: 1: quantity in stock 2: current quantity
    451 #: src/ProductBundleHooks.php:323
    452 #: src/ProductBundleHooks.php:424
    453 #, php-format
    454 msgid "You cannot add that amount of &quot;%1$s&quot; to the cart &mdash; 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:350
    459 #, php-format
    460 msgid "You cannot add another \"%s\" to your cart."
    461 msgstr ""
    462 
    463 #. translators: %s: product name
    464 #: src/ProductBundleHooks.php:380
    465465#, php-format
    466466msgid "You cannot add &quot;%s&quot; to the bundle item because the product is out of stock."
    467467msgstr ""
    468468
    469 #: src/ProductBundleHooks.php:442
     469#: src/ProductBundleHooks.php:459
    470470#, php-format
    471471msgid "You cannot add &quot;%s&quot; to the bundle item because it is an invalid product."
    … …  
    473473
    474474#. Translators: %s Product title.
    475 #: src/ProductBundleHooks.php:498
     475#: src/ProductBundleHooks.php:515
    476476#, php-format
    477477msgid "You can only have 1 %s in your cart."
    478478msgstr ""
    479479
    480 #: src/ProductBundleHooks.php:506
     480#: src/ProductBundleHooks.php:523
    481481#, php-format
    482482msgid "Cart update failed. The quantity of &quot;%1$s&quot; must be at least %2$d."
    483483msgstr ""
    484484
    485 #: src/ProductBundleHooks.php:510
     485#: src/ProductBundleHooks.php:527
    486486#, php-format
    487487msgid "Cart update failed. The quantity of &quot;%1$s&quot; cannot be higher than %2$d."
    488488msgstr ""
    489489
    490 #: src/ProductBundleHooks.php:514
     490#: src/ProductBundleHooks.php:531
    491491#, php-format
    492492msgid "Cart update failed. The quantity of &quot;%1$s&quot; must be equal to %2$d."
    493493msgstr ""
    494494
    495 #: src/ProductBundleHooks.php:1248
     495#: src/ProductBundleHooks.php:1305
    496496#, php-format
    497497msgid "(Bundled in %s)"
    498498msgstr ""
    499499
    500 #: src/ProductBundleHooks.php:1324
    501 #: src/ProductBundleHooks.php:1336
     500#: src/ProductBundleHooks.php:1381
     501#: src/ProductBundleHooks.php:1393
    502502msgid "Invalid bundle product."
    503503msgstr ""
    504504
    505 #: src/ProductBundleHooks.php:1329
    506 #: src/ProductBundleHooks.php:1334
     505#: src/ProductBundleHooks.php:1386
     506#: src/ProductBundleHooks.php:1391
    507507msgid "Bundle product has not default items to add it to the order."
    508508msgstr ""
    509509
    510 #: src/ProductBundleHooks.php:1405
     510#: src/ProductBundleHooks.php:1462
    511511msgid "Can not add bundle product to the order."
    512512msgstr ""
    513513
    514 #: src/ProductBundleHooks.php:1415
     514#: src/ProductBundleHooks.php:1472
    515515msgid "Can not add bundle item to the order."
     516msgstr ""
     517
     518#. translators: %s: bundle product name
     519#: src/ProductBundleHooks.php:1704
     520#, php-format
     521msgid "The bundle &quot;%s&quot; has been removed from your cart because one or more bundled items were removed or are unavailable."
    516522msgstr ""
    517523
  • easy-product-bundles-for-woocommerce/trunk/readme.txt

    r3795471 r3821742  
    66Tested up to: 7.1
    77Requires PHP: 5.6
    8 Stable tag: 6.22.4
     8Stable tag: 6.22.5
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    217217== Changelog ==
    218218
     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.
     223Have questions, suggestions, or feedback? We'd love to hear from you.❤️ If you enjoy the plugin, please consider leaving a ★★★★★ review.🙏
     224
    219225= 6.22.4 =
    220226* Fix: Ensured proper float casting for regular and parent product prices.
    221227* Fix: Replaced deprecated findDOMNode usage across components.
    222228* 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.🙏
    224229
    225230= 6.22.3 =
  • easy-product-bundles-for-woocommerce/trunk/src/Blocks/Integrations/CheckoutIntegration.php

    r3722065 r3821742  
    3535                        'asnp-wepb-checkout-integration',
    3636                        $this->get_url( 'checkout-integration/index', 'js' ),
    37                         [ 'wc-blocks-checkout' ],
     37                        [ 'wc-blocks-checkout', 'wp-hooks' ],
    3838                        ASNP_WEPB_VERSION,
    3939                        $script_args
  • easy-product-bundles-for-woocommerce/trunk/src/ProductBundleHooks.php

    r3795471 r3821742  
    1111        const CART_ITEM_ITEMS = 'asnp_wepb_items';
    1212        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;
    1329
    1430        public function init() {
    … …  
    84100                add_filter( 'woocommerce_order_again_cart_item_data', array( $this, 'order_again_cart_item_data' ), 10, 2 );
    85101                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' ) );
    86103        }
    87104
    … …  
    705722                        'asnp_wepb_item_quantity',
    706723                        'asnp_wepb_hide_price',
    707                         'asnp_wepb_apply_total_discount',
    708724                ];
    709725
    … …  
    715731
    716732                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 avoid
    723          * redundant filter executions during total calculations and cart rendering.
    724          *
    725          * @since 6.23.0
    726          *
    727          * @param array $cart_item Cart item data.
    728          *
    729          * @return bool
    730          */
    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.0
    740                  *
    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 );
    745733        }
    746734
    … …  
    813801                                }
    814802
    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();
    820804                                $total_discount_type = $cart_item['data']->get_total_discount_type();
    821805
    822806                                if ( empty( $cart_item[ self::CART_ITEM_ITEMS_KEY ] ) ) {
    823807                                        $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 ) );
    830816                                        }
    831817                                        continue;
    832818                                }
    833819
     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
    834837                                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 ) {
    836839                                                $cart_item['data']->set_price( (float) $total_discount * -1 );
    837840                                        } else {
    … …  
    840843                                } else {
    841844                                        $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 ) {
    845848                                                $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 ) {
    847850                                                $cart_item['data']->set_price( $parent_price - ( $parent_price * (float) $total_discount / 100 ) );
    848851                                        }
    … …  
    853856                                if ( isset( $bundle_price['price'] ) ) {
    854857                                        WC()->cart->cart_contents[ $cart_item_key ]['asnp_wepb_price'] = $bundle_price['price'];
     858                                } else {
     859                                        $cart_item['data']->set_price( 0 );
    855860                                }
    856861                        }
    … …  
    10381043                                        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' ) ] );
    10391044                        }
    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 ) {
    10411046                        $discount = $exchange_price ? maybe_exchange_price( (float) $total_discount ) : (float) $total_discount;
    10421047                        $price -= Cart\display_prices_including_tax() ?
    … …  
    11251130                                }
    11261131                        }
    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 ) {
    11281133                        $price -= Cart\display_prices_including_tax() ?
    11291134                                wc_get_price_including_tax( $cart_item['data'], [ 'price' => maybe_exchange_price( (float) $total_discount ) ] ) :
    … …  
    11581163        }
    11591164
     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         */
    11601175        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 ) {
    11621177                        return;
    11631178                }
    11641179
    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         */
    11701209        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 ) {
    11721211                        return;
    11731212                }
    11741213
    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;
    11771234                }
    11781235        }
    … …  
    15541611                        }
    15551612
     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
    15561628                        // Remove bundle items when order again is set.
    15571629                        if ( isset( $cart_item['asnp_wepb_order_again'], $cart_item['asnp_wepb_parent_id'] ) ) {
    … …  
    15741646                                        $cart->set_session();
    15751647                                }
     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 &quot;%s&quot; 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                                );
    15761709                        }
    15771710                }
    … …  
    16411774                }
    16421775
    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                }
    16501790        }
    16511791
  • easy-product-bundles-for-woocommerce/trunk/vendor/composer/autoload_static.php

    r3767259 r3821742  
    1414
    1515    public static $prefixLengthsPsr4 = array (
    16         'A' =>
     16        'A' => 
    1717        array (
    1818            'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 40,
    … …  
    2121
    2222    public static $prefixDirsPsr4 = array (
    23         'AsanaPlugins\\WooCommerce\\ProductBundles\\' =>
     23        'AsanaPlugins\\WooCommerce\\ProductBundles\\' => 
    2424        array (
    2525            0 => __DIR__ . '/../..' . '/src',
  • easy-product-bundles-for-woocommerce/trunk/vendor/composer/installed.php

    r3795471 r3821742  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '13b89f49ccae01083ce6250a815f6a2635eb2c1c',
     6        'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
    … …  
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '13b89f49ccae01083ce6250a815f6a2635eb2c1c',
     16            'reference' => '28ce346f84b5c9a940e4c218dde06aeda079e433',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.