- ステータス
- 解決済み
- 解決されたバージョン
- 4.12.0
- 関連するプラグイン/テーマ
- WooCommerce Dynamic Pricing
問題の概要
WooCommerce Dynamic PricingプラグインのAdvanced Category Pricing機能を使用する場合、割引はバリエーション商品には適用されません(シンプルな商品にのみ適用されます)。
回避策
この問題の恒久的な修正は完了しており、現在テストとリリース待ちの状態です。それまでの間、以下の回避策を使用してサイト上の問題を修正できます。
- 続行する前に、サイトの完全なバックアップを作成してください。
- wp-content/plugins/woocommerce-multilingual/compatibility/class-wcml-dynamic-pricing.phpを開き、118行目を見つけます。
- 以下のコードを:
public function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, WC_Product $_product, $module_id, $dynamic_pricing, $cat_ids ) { if ( ! $_product || ! $cat_ids || ! $this->has_requirements( $dynamic_pricing ) ) { return $process_discounts; } $taxonomy = $this->get_taxonomy( $dynamic_pricing ); $product_id = apply_filters( 'wpml_object_id', $_product->get_id(), 'product', true ); return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) ); }次のように置き換えます:
public function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, WC_Product $_product, $module_id, $dynamic_pricing, $cat_ids ) { if ( ! $_product || ! $cat_ids || ! $this->has_requirements( $dynamic_pricing ) ) { return $process_discounts; } $taxonomy = $this->get_taxonomy( $dynamic_pricing ); $product_id = apply_filters( 'wpml_object_id', $_product->get_id(), 'product', true ); //fix for variable products if ($_product->post_type === "product_variation") { $product_id = wc_get_product( $_product->get_parent_id() )->get_id(); $product_id = apply_filters( 'wpml_object_id', $product_id, 'product', true ); return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) ); } return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) ); }