isSubscriptionPlanItem( $cartItem ) ) { return $price; } return PriceManager::getPriceByRules( $totalQuantity, $cartItem['data']->get_id(), 'edit', 'cart', false ); }, 10, 4 ); // Display: defer the subtotal column to WooCommerce for plan items so it matches the charge. add_filter( 'tiered_pricing_table/cart/recalculate_cart_item_subtotal', function ( $state, $cartItem ) { return $this->isSubscriptionPlanItem( $cartItem ) ? false : $state; }, 10, 2 ); // Display: defer the price column to WooCommerce for plan items. add_filter( 'tiered_pricing_table/cart/need_price_recalculation/item', function ( $state, $cartItem ) { return $this->isSubscriptionPlanItem( $cartItem ) ? false : $state; }, 10, 2 ); } /** * Whether a cart item is currently purchased on a subscription plan (APFS). * * Reads the scheme stored on the cart item itself, which survives the cloned recurring cart, rather * than the product object's runtime state. * * @param array $cartItem * * @return bool */ protected function isSubscriptionPlanItem( $cartItem ): bool { if ( ! class_exists( '\WCS_ATT_Cart' ) ) { return false; } if ( empty( $cartItem['data'] ) || ! ( $cartItem['data'] instanceof WC_Product ) ) { return false; } $scheme = \WCS_ATT_Cart::get_subscription_scheme( $cartItem ); // A non-empty, non-'0' scheme key means the item is on a plan; '0'/null means a one-time purchase. return ! empty( $scheme ) && '0' !== (string) $scheme; } public function getTitle(): string { return 'WooCommerce Subscriptions'; } public function getDescription(): string { return __( 'Apply tiered pricing correctly to products purchased on a WooCommerce Subscriptions plan, in both the initial and recurring totals.', 'tier-pricing-table' ); } public function getSlug(): string { return 'woocommerce-subscriptions'; } public function getAuthorURL(): string { return 'https://woocommerce.com/products/woocommerce-subscriptions/'; } public function getIconURL(): string { return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/woocommerce-develop.jpeg' ); } public function getIntegrationCategory(): string { return 'custom_product_types'; } }