diff --git a/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php b/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php index 90312dcd04..f46d55e417 100644 --- a/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php +++ b/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php @@ -1,4 +1,7 @@ cart->empty_cart(); - if ( ( 'variable' === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) { + if ( ( ProductType::VARIABLE === $product_type || 'variable-subscription' === $product_type ) && isset( $_POST['attributes'] ) ) { $attributes = wc_clean( wp_unslash( $_POST['attributes'] ) ); $data_store = WC_Data_Store::load( 'product' ); @@ -232,7 +235,7 @@ public function ajax_get_selected_product_data() { throw new Exception( sprintf( __( 'Product with the ID (%1$s) cannot be found.', 'woocommerce-gateway-stripe' ), $product_id ) ); } - if ( in_array( $product->get_type(), [ 'variable', 'variable-subscription' ], true ) && isset( $_POST['attributes'] ) ) { + if ( in_array( $product->get_type(), [ ProductType::VARIABLE, 'variable-subscription' ], true ) && isset( $_POST['attributes'] ) ) { $attributes = wc_clean( wp_unslash( $_POST['attributes'] ) ); $data_store = WC_Data_Store::load( 'product' ); diff --git a/includes/payment-methods/class-wc-stripe-express-checkout-helper.php b/includes/payment-methods/class-wc-stripe-express-checkout-helper.php index f488786420..b4d232713f 100644 --- a/includes/payment-methods/class-wc-stripe-express-checkout-helper.php +++ b/includes/payment-methods/class-wc-stripe-express-checkout-helper.php @@ -1,5 +1,7 @@ get_type(), [ 'variable', 'variable-subscription' ], true ) ) { + if ( in_array( $product->get_type(), [ ProductType::VARIABLE, 'variable-subscription' ], true ) ) { $variation_attributes = $product->get_variation_attributes(); $attributes = []; @@ -408,9 +410,9 @@ public function supported_product_types() { return apply_filters( 'wc_stripe_payment_request_supported_types', [ - 'simple', - 'variable', - 'variation', + ProductType::SIMPLE, + ProductType::VARIABLE, + ProductType::VARIATION, 'subscription', 'variable-subscription', 'subscription_variation', @@ -673,7 +675,7 @@ public function should_show_express_checkout_button() { return false; } - if ( $is_product && $product && in_array( $product->get_type(), [ 'variable', 'variable-subscription' ], true ) ) { + if ( $is_product && $product && in_array( $product->get_type(), [ ProductType::VARIABLE, 'variable-subscription' ], true ) ) { $stock_availability = array_column( $product->get_available_variations(), 'is_in_stock' ); // Don't show if all product variations are out-of-stock. if ( ! in_array( true, $stock_availability, true ) ) {