HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //proc/self/cwd/wp-content/plugins/woo-multi-currency/plugins/smart_bundle_for_woocommerce.php
<?php

/**
 * Class WOOMULTI_CURRENCY_F_Plugin_Smart_Bundle_For_WooCommerce
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class WOOMULTI_CURRENCY_F_Plugin_Smart_Bundle_For_WooCommerce {
	protected $settings;

	public function __construct() {
		$this->settings = WOOMULTI_CURRENCY_F_Data::get_ins();
		if ( $this->settings->get_enable() ) {
			if ( is_plugin_active( 'smart-bundle-for-woocommerce/smart-bundle-woocommerce.php' ) ) {
				add_action( 'woocommerce_before_calculate_totals', array(
					$this,
					'wcbp_bundle_product_before_calculate_totals'
				), 11, 1 );
			}
		}
	}

	public function wcbp_bundle_product_before_calculate_totals( $cart_object ) {
		//  This is necessary for WC 3.0+
		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
			return;
		}
		if ( $this->settings->get_current_currency() === $this->settings->get_default_currency() ) {
			return;
		}
		foreach ( $cart_object->get_cart() as $cart_item_key => $cart_item ) {
			// child product price
			if ( isset( $cart_item['wcbp_bundle_product_parent_id'] ) && ( '' != $cart_item['wcbp_bundle_product_parent_id'] ) ) {
				$cart_item['data']->set_price( 0 );
			}

			// main product price
			if ( isset( $cart_item['wcbp_product_bundle_ids'] ) && ( '' != $cart_item['wcbp_product_bundle_ids'] ) ) {
				$wcbp_bundle_product_items = explode( ',', $cart_item['wcbp_product_bundle_ids'] );
				$wcbp_bundle_product_items = array_count_values( $wcbp_bundle_product_items );
				$product_id                = $cart_item['product_id'];
				//$cart_item['data']->set_tax_status('none');
				$wcbp_bundle_product_price = 0;
				$pricing_type              = get_post_meta( $product_id, 'wcbp_bundle_prod_pricing', true );

				if ( 'per_product_only' == $pricing_type || 'per_product_bundle' == $pricing_type ) {
					if ( is_array( $wcbp_bundle_product_items ) && count( $wcbp_bundle_product_items ) > 0 ) {
						foreach ( $wcbp_bundle_product_items as $wcbp_bundle_product_item => $qty ) {
							$wcbp_bundle_product_item_id      = absint( $wcbp_bundle_product_item ? $wcbp_bundle_product_item : 0 );
							$wcbp_bundle_product_item_qty     = absint( $qty ? $qty : 1 );
							$wcbp_bundle_product_item_product = wc_get_product( $wcbp_bundle_product_item_id );

							if ( ! $wcbp_bundle_product_item_product || $wcbp_bundle_product_item_product->is_type( 'bundle_product' ) ) {
								continue;
							}

							// Quantity issue calculation fixed  	
							foreach ( $cart_object->get_cart() as $cart_item_key_for_qty => $cart_item_for_qty ) {
								if ( $cart_item_for_qty['product_id'] == $wcbp_bundle_product_item_id ) {
									$cart_item_qty = $cart_item_for_qty['quantity'];
								}
							}
							$wcbp_bundle_product_price += wmc_revert_price( $wcbp_bundle_product_item_product->get_price() ) * $cart_item_qty;
							// Quantity issue calculation fixed  	
						}
					}
				} else {
					$bundle_product            = wc_get_product( $product_id );
					$box_price                 = wmc_revert_price( $bundle_product->get_price() );
					$wcbp_bundle_product_price = $box_price;
				}
				// per item + base price
				if ( ( 'per_product_bundle' == $pricing_type ) && is_numeric( $wcbp_bundle_product_price ) ) {
					$bundle_product            = wc_get_product( $product_id );
					$box_price                 = wmc_revert_price( $bundle_product->get_price() );
					$wcbp_bundle_product_price += $box_price;
				}

				$cart_item['data']->set_price( floatval( $wcbp_bundle_product_price ) );
			}
		}
	}
}