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
// Rename “Add to Cart” button to “Call to Order” add_filter(‘woocommerce_product_single_add_to_cart_text’, ‘rename_add_to_cart_button’, 10, 1); function rename_add_to_cart_button($button_text) { return __(‘Call to Order’, ‘woocommerce’); } // Redirect “Call to Order” button to initiate a phone call add_filter(‘woocommerce_product_add_to_cart_url’, ‘redirect_to_call_for_order’, 10, 2); function redirect_to_call_for_order($add_to_cart_url,…Continue reading
// Add checkbox and input field to general tab add_action(‘woocommerce_product_options_general_product_data’, ‘add_custom_fields_to_general_tab’); function add_custom_fields_to_general_tab() { global $post; // Retrieve the current values of the checkbox and input field $checked = get_post_meta($post->ID, ‘_allow_discount’, true); $required_quantity = get_post_meta($post->ID, ‘_required_quantity’, true); // Output the…Continue reading
// Add checkbox and input field to general tab add_action(‘woocommerce_product_options_general_product_data’, ‘add_custom_fields_to_general_tab’); function add_custom_fields_to_general_tab() { global $post; // Retrieve the current values of the checkbox and input field $checked = get_post_meta($post->ID, ‘_allow_discount’, true); $required_quantity = get_post_meta($post->ID, ‘_required_quantity’, true); // Output the…Continue reading
// Hook to apply progressive discount based on cart quantity add_action(‘woocommerce_cart_calculate_fees’, ‘progressive_discount’, 20, 1); function progressive_discount($cart) { // Check if the action is not triggered in the admin and not during AJAX if (is_admin() && !defined(‘DOING_AJAX’)) return; // Define progressive…Continue reading
/* Plugin Name: SuperWp WhatsApp Product Enquiry Description: Adds a WhatsApp enquiry button to WooCommerce product pages with customizable options, custom messages, and phone number input. Version: 1.0.3 Author: Thiarara SuperWP */ // Add WooCommerce Submenu for WhatsApp Enquiry Settings…Continue reading
// Exit if accessed directly if (!defined(‘ABSPATH’)) { exit; } // Check if WooCommerce is active if (!in_array(‘woocommerce/woocommerce.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))) { add_action(‘admin_notices’, ‘superwp_wc_not_active_notice’); function superwp_wc_not_active_notice() { ?>Continue reading