Disable srcset on Frontend (WooCommerce)
function disable_wp_responsive_images() { return 1; } add_filter(‘max_srcset_image_width’, ‘disable_wp_responsive_images’);Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
function disable_wp_responsive_images() { return 1; } add_filter(‘max_srcset_image_width’, ‘disable_wp_responsive_images’);Continue reading
(function ($) { $(document).ready(function ($) { var variations = JSON.parse( jQuery(“.variations_form”).attr(“data-product_variations”) ); if (variations) { var nthAttributeToSwitchImage = 1; var attributeName = Object.keys( variations[nthAttributeToSwitchImage – 1].attributes )[0]; // jQuery(“[name=” + attributeName + “]”).change(function () { jQuery(“.woocommerce div.product form.cart .variations select”).change(…Continue reading
document.addEventListener(‘DOMContentLoaded’, function () { // Select the First Name field var firstNameField = document.querySelector(‘#billing_first_name’); var lastNameField = document.querySelector(‘#billing_last_name’); if (firstNameField) { firstNameField.addEventListener(‘change’, function () { var fullName = firstNameField.value.trim(); var nameParts = fullName.split(‘ ‘); // Extract First Name and Last…Continue reading
/** * Snippet Name: Add the Buy on Kindle button near Add to Cart in WooCommerce PDP. */ add_action(‘woocommerce_after_add_to_cart_button’,’add_kindle_button’); function add_kindle_button() { $kindle_button_url = get_post_meta( get_the_ID(),’kindle_button_url’,true); if ( isset($kindle_button_url) && filter_var($kindle_button_url, FILTER_VALIDATE_URL)) { $style = ‘style=”background-color: #ff9900; color: #fff;’; $button…Continue reading
add_filter( ‘woocommerce_coupon_message’, ‘modify_woocommerce_coupon_message’, 10, 3 ); function modify_woocommerce_coupon_message( $msg, $msg_code, $coupon ) { if( $msg === __( ‘Coupon code applied successfully.’, ‘woocommerce’ ) ) { $msg = sprintf( __( “You are getting $%s discounts.”, “woocommerce” ), ‘‘ . $coupon->get_amount() .…Continue reading
/** * Snippet Name: Change the WooCommerce variable product drop down place holder text */ add_filter( ‘woocommerce_dropdown_variation_attribute_options_args’, ‘change_dropdown_text_args’, 10 ); function change_dropdown_text_args( $args ) { $args[‘show_option_none’] = ‘Choose a size’; return $args; }Continue reading
/** * Snippet: Apply Coupon when a radio button is clicked on The Product Page * Author: https://profiles.wordpress.org/kishores * Url: https://upnrunn.com * Note: Please make sure to create the coupon in the WC Admin */ // Add radio button below…Continue reading
/** * Snippet Name: Exclude Product From Discount Coupons. */ add_filter( ‘woocommerce_coupon_is_valid_for_product’, ‘exclude_product_from_product_promotions’, 999, 4 ); function exclude_product_from_product_promotions( $valid, $product, $coupon, $values ) { // Product id here (i.e. 123) if ( 123 == $product->get_id() ) { $valid = false;…Continue reading
/** * Snippet Name: Apply discount on the cheapest item */ add_action( ‘woocommerce_before_calculate_totals’, ‘apply_discount_on_cheapest_item’, 999 ); function apply_discount_on_cheapest_item( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; if ( did_action( ‘woocommerce_before_calculate_totals’ ) >= 2 ) return;…Continue reading