Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Form_Handler::add_to_cart_handler_simple( int $product_id )
Handle adding simple products to the cart.
Description Description
Parameters Parameters
- $product_id
-
(Required) Product ID to add to the cart.
Return Return
(bool) success or not
Source Source
File: includes/class-wc-form-handler.php
private static function add_to_cart_handler_simple( $product_id ) { $quantity = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( wp_unslash( $_REQUEST['quantity'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity ); if ( $passed_validation && false !== WC()->cart->add_to_cart( $product_id, $quantity ) ) { wc_add_to_cart_message( array( $product_id => $quantity ), true ); return true; } return false; }
Changelog Changelog
Version | Description |
---|---|
2.4.6 | Introduced. |