Fix: Prevent subscription price override for non-subscription products

Ensure `.trigger('change')` on `.wc_input_subscription_price` is only called
when the selected product type is 'subscription' or 'variable-subscription'.

Prevents issue where non-subscription products have their regular price cleared,
which was likely triggered indirectly by the Square plugin.
This commit is contained in:
Narek Zakarian 2025-07-10 17:49:25 +04:00
parent 80d7da4df3
commit b3b44cad12
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -180,7 +180,18 @@ document.addEventListener( 'DOMContentLoaded', () => {
}
} );
jQuery( '.wc_input_subscription_price' ).trigger( 'change' );
const $productType = jQuery( '#product-type' );
const $subscriptionInput = jQuery( '.wc_input_subscription_price' );
if (
$productType.length &&
$subscriptionInput.length &&
[ 'subscription', 'variable-subscription' ].includes(
$productType.val()
)
) {
$subscriptionInput.trigger( 'change' );
}
const variationProductIds = [
PayPalCommerceGatewayPayPalSubscriptionProducts.product_id,