ID, '_loyaltypress_coins_mode', true ); $plural = (string) Settings::get( 'coins.plural' ); echo '
'; wc_enqueue_js( "jQuery( '#_loyaltypress_coins_mode' ).on( 'change', function () { jQuery( '._loyaltypress_coins_fixed_field' ).toggle( 'fixed' === this.value ); } ).trigger( 'change' );" ); } /** * Save fields (WooCommerce's product nonce and the edit capability are checked again here). * * @param \WC_Product $product Product. */ public static function save( $product ) { $nonce = isset( $_POST['woocommerce_meta_nonce'] ) ? sanitize_key( wp_unslash( $_POST['woocommerce_meta_nonce'] ) ) : ''; if ( ! wp_verify_nonce( $nonce, 'woocommerce_save_data' ) || ! current_user_can( 'edit_post', $product->get_id() ) ) { return; } $mode = isset( $_POST['_loyaltypress_coins_mode'] ) ? sanitize_key( wp_unslash( $_POST['_loyaltypress_coins_mode'] ) ) : 'default'; $qty = isset( $_POST['_loyaltypress_coins_fixed'] ) ? absint( wp_unslash( $_POST['_loyaltypress_coins_fixed'] ) ) : 0; $product->update_meta_data( '_loyaltypress_coins_mode', in_array( $mode, array( 'fixed', 'none' ), true ) ? $mode : 'default' ); $product->update_meta_data( '_loyaltypress_coins_fixed', $qty ); } }