/** * Disable for automated testing. * * @link https://wpforms.com/developers/how-to-disable-recaptcha-for-automated-testing/ */ // Disable reCAPTCHA assets and initialisation on the frontend. add_filter( ‘wpforms_frontend_recaptcha_disable’, ‘__return_true’ ); // Disable validation and verification on the backend. add_filter( ‘wpforms_process_bypass_captcha’, ‘__return_true’ );Continue reading
/** * Customize Rich Text Field TinyMCE buttons for top toolbar. * * @link https://wpforms.com/developers/how-to-customize-the-rich-text-field-tinymce-icons/ */ // Function to change the top toolbar function wpf_dev_customize_tinymce_buttons_toolbar1( $toolbar, $field_id, $field_data ) { $toolbar = [ ‘fontselect’, ‘fontsizeselect’, ‘forecolor’, ‘indent’, ‘outdent’, ‘italic’, ‘styleselect’,…Continue reading
/** * Restrict countries inside the Smart Phone form field * * @link https://wpforms.com/how-to-restrict-countries-inside-smart-phone-form-fields/ */ function wpf_dev_smart_phone_field_restrict_countries() { ?>Continue reading
/** * Disallow numbers in a single-line text field * * @link https://wpforms.com/developers/how-to-restrict-numbers-in-a-single-line-text-form-field/ */ function wpf_dev_disallow_numbers_text_field( $fields, $entry, $form_data ) { // Optional, you can limit to specific forms. Below, we restrict output to // form ID #1000. if (…Continue reading
add_filter( ‘woocommerce_cart_item_price’, ‘filter_cart_item_price’, 10, 3 ); function filter_cart_item_price( $price_html, $cart_item, $cart_item_key ) { if( $cart_item[‘data’]->is_on_sale() ) { return $cart_item[‘data’]->get_price_html(); } return $price_html; } add_filter( ‘woocommerce_cart_item_subtotal’, ‘filter_cart_item_subtotal’, 10, 3 ); function filter_cart_item_subtotal( $subtotal_html, $cart_item, $cart_item_key ){ $product = $cart_item[‘data’]; $quantity =…Continue reading
add_action( ‘woocommerce_after_shop_loop_item’, ‘wc_loop_get_product_stock_availability_text’, 10 ); function wc_loop_get_product_stock_availability_text() { global $wpdb, $product; // For variable products if( $product->is_type(‘variable’) ) { // Get the stock quantity sum of all product variations (children) $stock_quantity = $wpdb->get_var(” SELECT SUM(pm.meta_value) FROM {$wpdb->prefix}posts as p JOIN…Continue reading
add_action( ‘woocommerce_check_cart_items’, ‘required_min_cart_subtotal_amount’ ); function required_min_cart_subtotal_amount() { // HERE Set minimum cart total amount $minimum_amount = 250; // Total (before taxes and shipping charges) $cart_subtotal = WC()->cart->subtotal; // Add an error notice is cart total is less than the minimum…Continue reading
// Display notice on single product page for specific category add_action(‘woocommerce_before_single_product_summary’, ‘display_category_notice’); function display_category_notice() { global $product; if (!$product) { return; // Exit if $product is not defined } $categories = get_categories_with_minimum_amount(); $cart_items = WC()->cart->get_cart(); $notices = array(); foreach ($categories…Continue reading
add_action(‘woocommerce_order_status_pending’, ‘woo_schedule_cancel_order_event’); function woo_schedule_cancel_order_event($order_id) { if (!wp_next_scheduled(‘woo_cancel_pending_order’, array($order_id))) { wp_schedule_single_event(time() + 3600, ‘woo_cancel_pending_order’, array($order_id)); } } add_action(‘woo_cancel_pending_order’, ‘woo_cancel_order’); function woo_cancel_order($order_id) { $order = wc_get_order($order_id); wp_clear_scheduled_hook(‘woo_cancel_pending_order’, array($order_id)); if ($order && $order->has_status(‘pending’)) { $order->update_status(‘cancelled’, ‘Pending order cancelled after 1 hour’); } }Continue reading
// Add discount for Local Pickup shipping method add_action( ‘woocommerce_cart_calculate_fees’, ‘custom_discount_for_pickup_shipping_method’, 10, 1 ); function custom_discount_for_pickup_shipping_method( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) { return; } $chosen_shipping_methods = WC()->session->get( ‘chosen_shipping_methods’ ); if ( !empty($chosen_shipping_methods) )…Continue reading