Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function custom_woocommerce_get_cart_contents( $cart_contents ) {
- //return $cart_contents;
- foreach ( $cart_contents as $key => $cart_item ) {
- do_action( 'woocommerce/cart_loop/start', $cart_item );
- $product_id = isset( $cart_item['variation_id'] ) && $cart_item['variation_id'] ? $cart_item['variation_id'] : $cart_item['product_id'];
- $_product = wc_get_product( $product_id );
- $product_price = $_product->get_price( 'edit' );
- $product_price_by_currency = YayCurrencyHelper::calculate_price_by_currency( $product_price, false, $this->apply_currency );
- $product_price_by_currency = FixedPriceHelper::get_price_fixed_by_apply_currency( $_product, $product_price_by_currency, $this->apply_currency );
- if ( isset( $cart_item['subscription_renewal'] ) ) {
- $order_id = $cart_item['subscription_renewal']['renewal_order_id'];
- $order_currency = YayCurrencyHelper::get_order_currency_by_order_id( $order_id, $this->converted_currency );
- if ( $order_currency ) {
- $currency_code = $order_currency['currency'];
- if ( $this->default_currency != $currency_code && ( $currency_code != $this->apply_currency['currency'] || YayCurrencyHelper::disable_fallback_option_in_checkout_page( $this->apply_currency ) ) ) {
- $cart_contents[ $key ]['data']->subscription_renewal_price_original = $product_price_by_currency;
- $cart_contents[ $key ]['data']->subscription_renewal_price_original_default = $product_price;
- }
- $cart_contents[ $key ]['data']->subscription_renewal_price_currency = $currency_code;
- }
- }
- if ( isset( $cart_item['subscription_resubscribe'] ) ) {
- $order_id = $cart_item['subscription_resubscribe']['subscription_id'];
- $order_currency = YayCurrencyHelper::get_order_currency_by_order_id( $order_id, $this->converted_currency );
- if ( $order_currency ) {
- $currency_code = $order_currency['currency'];
- if ( $this->default_currency != $currency_code && ( $currency_code != $this->apply_currency['currency'] || YayCurrencyHelper::disable_fallback_option_in_checkout_page( $this->apply_currency ) ) ) {
- $cart_contents[ $key ]['data']->subscription_resubscribe_price_original = $product_price_by_currency;
- $cart_contents[ $key ]['data']->subscription_resubscribe_price_original_default = $product_price;
- }
- $cart_contents[ $key ]['data']->subscription_resubscribe_price_currency = $currency_code;
- }
- }
- do_action( 'woocommerce/cart_loop/end', $cart_item );
- }
- return $cart_contents;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement