Skip to content

Instantly share code, notes, and snippets.

View andrewreal's full-sized avatar

Andrew Real andrewreal

View GitHub Profile
@andrewreal
andrewreal / attribute-filter-option.php
Created February 24, 2021 08:09
Example of adding an option to a WooCommerce attribute
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action( 'woocommerce_after_edit_attribute_fields', 'blz_attr_filter_option', 50 );
add_action( 'woocommerce_after_add_attribute_fields', 'blz_attr_filter_option', 50 );
add_action( 'admin_init' , 'blz_attr_save', 99 );
/**
* Display the populated checkbox for the Create Filter Widget option
@andrewreal
andrewreal / woocommerce_email_hooks.md
Last active December 3, 2020 09:19
WooCommerce Email Hooks

Modify Email Receipients

Filter - woocommerce_email_recipient_new_order

add_filter( 'woocommerce_email_recipient_new_order', 'blz_add_recipient', 10, 3 );

/**
 * Add Branch to order notification email recipients
 *
 * @param string $recipient
@andrewreal
andrewreal / functions.php
Last active October 29, 2020 14:18 — forked from ouija/functions.php
WooCommerce: Remove checkout field descriptions 'slideUp and hide' animations
<?
// WooCommerce has a stupid function in the ./assets/js/frontent/woocommerce.min.js file that hides/shows the 'description' elements
// for the checkout fields both when there is an onclick event on the document body, and when any field input is clicked.
//
// The offending code for this 'feature' is the following:
// i(document.body).on("click",function(){i(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),i(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),i(".woocommerce-input-wrapper :input").on("keydown",function(e){var o=i(this).parent().find("span.description");if(27===e.which&&o.length&&o.is(":visible"))return o.prop("aria-hidden",!0).slideUp(250),e.preventDefault(),!1}).on("click focus",function(){var e=i(this).parent(),o=e.find("span.description");e.addClass("currentTarget"),i(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),o.length&&o.is(":hidden")&&o.prop("aria-hidd