ul#wpforms-1000-field_25 li.choice-1 label:before { content: “”; display: inline-block; background-image: url(http://yoursite.com/wp-content/uploads/2019/10/your-image-filename.png); background-size: 100%; height: 45px; width: 30px; background-repeat: no-repeat; position: relative; right: 5px; top: 20px; }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
// 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