WPML
Статус
Открыто
Заявлено для
WPML Multilingual & Multicurrency for WooCommerce 5.3.2
Связанный плагин/тема
WooCommerce Subscriptions
Теги темы
Compatibility, WCML

Обзор проблемы

В WooCommerce Subscriptions при обновлении подписки (будь то переход на более высокий тип аккаунта, понижение или кроссгрейд) цена фильтруется некорректно. Это приводит к неправильным ценам при смене планов подписки.

Обходное решение

Пожалуйста, перед продолжением убедитесь, что у Вас есть полная резервная копия сайта.


  • Откройте файл …/wp-content/plugins/woocommerce-multilingual/compatibility/WcSubscriptions/MulticurrencyHooks.php.

  • Найдите строку 253.

  • Замените:
    	public function woocommerce_subscription_price_from( $price, $product ) {
    		if ( $product instanceof WC_Product_Subscription_Variation ) {
    			$customPricesOn = get_post_meta( $product->get_id(), '_wcml_custom_prices_status', true );
    
    			if ( $customPricesOn ) {
    				$price = get_post_meta( $product->get_id(), '_price_' . $this->woocommerce_wpml->multi_currency->get_client_currency(), true );
    			} else {
    				$price = apply_filters( 'wcml_raw_price_amount', $price );
    			}
    		}
    
    		return $price;
    	}

  • На:
    	public function woocommerce_subscription_price_from( $price, $product ) {
    		if ( $product instanceof WC_Product_Subscription_Variation || $product instanceof \WC_Product_Subscription) {
    			$customPricesOn = get_post_meta( $product->get_id(), '_wcml_custom_prices_status', true );
    
    			if ( $customPricesOn ) {
    				$price = get_post_meta( $product->get_id(), '_price_' . $this->woocommerce_wpml->multi_currency->get_client_currency(), true );
    			} else {
                    $id = $product->get_id();
                    $type = get_post_type($id);
    				$trid = apply_filters( 'wpml_element_trid', NULL, $id,  'post_'.$type );
    				$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid , 'post_'.$type );
                    foreach ($translations as $translation){
                        if ($translation->original == 1){
                            if ( get_post_meta( $translation->element_id, '_wcml_custom_prices_status', true ) ) {
    	                        $price = get_post_meta( $translation->element_id, '_price_' . $this->woocommerce_wpml->multi_currency->get_client_currency(), true );
                            } else {
    	                        $price = apply_filters( 'wcml_raw_price_amount', $price );
                            }
                        }
                    }
                }
    		}
    
    		return (int)$price;
    	}

Все известные проблемы →