Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / sul-demo-avatars.php
Created April 19, 2024 16:23
Use Picsum.photos to generate some random random avatars.
<?php
/**
* Plugin Name: Simple User Listing - Demo Avatars
* Description: Use Picsum.photos to generate some random random avatars.
* Author: helgatheviking
* Version: 1.0.0
* Requires at least: 6.5
*/
defined( 'ABSPATH' ) || exit;
@helgatheviking
helgatheviking / action-types.js
Last active September 28, 2023 15:00
Product Data Store Example
const TYPES = {
FETCH_FROM_API : "FETCH_FROM_API",
HYDRATE_PRODUCT: "HYDRATE_PRODUCT",
};
export default TYPES;
@helgatheviking
helgatheviking / wc-bcc-emails.php
Last active January 7, 2023 22:44
Add BCC to certain store emails
/**
* Add BCC to certain store emails.
*
* @param string $headers
* @param string $email_id
* @return string
*/
function kia_add_bcc_to_specific_emails( $headers, $email_id ) {
$bbc_these_emails = array(
@helgatheviking
helgatheviking / billing-details-translation.php
Created April 12, 2022 17:19
Change Billing Details text on free checkout
function kia_translate_billing_details_when_free( $translated_text, $untranslated_text, $domain ) {
if ( function_exists( 'wc' ) && 'woocommerce' === $domain ) {
//make the changes to the text
switch( $untranslated_text ) {
case 'Billing details':
if ( ! WC()->cart->needs_shipping() && 0.0 === floatval( WC()->cart->get_total( 'edit' ) ) ) {
$translated_text = __( 'NOT billing details', 'kia_textdomain' );
@helgatheviking
helgatheviking / wc-clear-persistent-carts-daily.php
Created March 8, 2022 14:30
Schedule a task to run daily to delete WooCommerce persistent carts
<?php
/**
* Plugin Name: Clear persistent carts daily
* Plugin URI: https://gist.github.com/
* Description: Schedule a task to run daily to delete WooCommerce persistent carts
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com/
* WC requires at least: 6.3.0
* WC tested up to: 6.3.0
@helgatheviking
helgatheviking / wc-attributes-shortcode.php
Last active January 18, 2022 15:28
Adds a [display_attributes] shortcode that will display all the terms for each attribute. Use [display_attributes attributes="some_taxonomy"] to show a particular attribute's terms.
<?php
/**
* Plugin Name: Attributes shortcode
* Plugin URI: https://gist.github.com/helgatheviking/1d34f84fc93b8a08c258a37768802625
* Description: Create a shortcode to display product attribute taxonomies
* Version: 6.8.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Requires PHP: 7.4
@helgatheviking
helgatheviking / mnm-product-thumbnail.php
Last active November 9, 2021 22:00
Template override for Mix and Match child thumbnails - replace with first gallery image
<?php
/**
* Mix and Match Item Thumbnail
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/mnm/mnm-product-thumbnail.php.
*
* HOWEVER, on occasion WooCommerce Mix and Match will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@helgatheviking
helgatheviking / give-count-unique-donors.php
Last active October 23, 2021 18:34
Shortcode to output unique donor count for specific form (needs caching)
<?php
/**
* Give count unique donors
*
* @param array $atts [
* 'form_id' => int The form ID to count donors for
* ]
*/
function kia_give_donor_count( $atts ) {
@helgatheviking
helgatheviking / dequeue-script-example.php
Created January 6, 2021 19:50
Code snippet for dequeing a script on the single produt page
function kia_unload_script() {
if ( function_exists( 'is_product' ) && is_product() ) {
wp_dequeue_script( 'wc-single-product' );
}
}
add_action( 'wp_enqueue_scripts', 'kia_unload_script', 20 );
@helgatheviking
helgatheviking / wc-mnm-simplify-variation-names.php
Created December 11, 2020 22:38
Reduce Mix and Match variation names to only their attributes
<?php
/**
* Plugin Name: WooCommerce Mix and Match Products - Simplify variation names
* Plugin URI: https://woocommerce.com/products/woocommerce-mix-and-match-products
* Description: Reduce container variation names to only their attributes
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com
* Requires at least: 5.5
* Requires PHP: 7.0