'; woocommerce_wp_checkbox( array( 'id' => '_objeka_bundles', 'label' => __( 'Objeka volume pricing', 'objeka-toolkit' ), 'description' => __( '2+ units: 15%; 3+ units: 25%. Applied on the server. Coupons may stack.', 'objeka-toolkit' ), ) ); woocommerce_wp_text_input( array( 'id' => '_objeka_deadline', 'label' => __( 'Fixed offer deadline (UTC)', 'objeka-toolkit' ), 'description' => __( 'ISO 8601, for example 2027-12-31T23:59:00Z. Leave blank to disable. The display timer does not schedule product sale prices.', 'objeka-toolkit' ), 'desc_tip' => true, ) ); woocommerce_wp_text_input( array( 'id' => '_objeka_evergreen_hours', 'label' => __( 'Personal reminder (hours)', 'objeka-toolkit' ), 'type' => 'number', 'custom_attributes' => array( 'min' => '0', 'max' => '168', ), 'description' => __( 'Optional browser-local reminder; explicitly labeled, never a stock or price guarantee.', 'objeka-toolkit' ), ) ); woocommerce_wp_textarea_input( array( 'id' => '_objeka_specs', 'label' => __( 'Specifications', 'objeka-toolkit' ), 'description' => __( 'Plain text specification sheet shown in the product modal.', 'objeka-toolkit' ), ) ); woocommerce_wp_textarea_input( array( 'id' => '_objeka_size_guide', 'label' => __( 'Size / care guide', 'objeka-toolkit' ), ) ); woocommerce_wp_text_input( array( 'id' => '_objeka_bump_id', 'label' => __( 'Order bump product ID', 'objeka-toolkit' ), 'type' => 'number', 'custom_attributes' => array( 'min' => '0' ), 'description' => __( 'An in-stock simple product. Added only when the shopper chooses it.', 'objeka-toolkit' ), ) ); echo ''; } /** * Save metadata through the validated WooCommerce product editor. * * @param WC_Product $product Product being edited. */ public static function save( $product ) { // phpcs:disable WordPress.Security.NonceVerification.Missing -- WooCommerce validates its product-edit nonce before this hook. $product->update_meta_data( '_objeka_bundles', isset( $_POST['_objeka_bundles'] ) ? 'yes' : 'no' ); foreach ( array( '_objeka_specs', '_objeka_size_guide' ) as $key ) { if ( isset( $_POST[ $key ] ) ) { $product->update_meta_data( $key, sanitize_textarea_field( wp_unslash( $_POST[ $key ] ) ) ); } } if ( isset( $_POST['_objeka_deadline'] ) ) { $value = sanitize_text_field( wp_unslash( $_POST['_objeka_deadline'] ) ); $valid = preg_match( '/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', $value ) && false !== strtotime( $value ); $product->update_meta_data( '_objeka_deadline', $valid ? $value : '' ); } foreach ( array( '_objeka_bump_id', '_objeka_evergreen_hours' ) as $key ) { if ( isset( $_POST[ $key ] ) ) { $value = absint( wp_unslash( $_POST[ $key ] ) ); $product->update_meta_data( $key, '_objeka_evergreen_hours' === $key ? min( 168, $value ) : $value ); } } // phpcs:enable WordPress.Security.NonceVerification.Missing } }