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 / add-taxonomy-to-woocommerce-export.php
Last active March 4, 2024 14:51
Add a custom taxonomy to WooCommerce import/export
<?php
/*
* Plugin Name: WooCommerce Add Taxonomy to Export
* Plugin URI: https://gist.github.com/helgatheviking/114c8df50cabb7119b3c895b1d854533/
* Description: Add a custom taxonomy to WooCommerce import/export.
* Version: 1.0.1
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Woo: 18716:fbca839929aaddc78797a5b511c14da9
@helgatheviking
helgatheviking / kia-sample-custom-field-for-woocommerce.php
Last active March 3, 2024 18:33
Add a custom text field to a WooCommerce Product
<?php
/**
* Plugin Name: Sample Customizable Product Field for WooCommerce
* Plugin URI: https://www.kathyisawesome.com/add-a-custom-field-to-woocommerce-product/
* Description: Add a custom text field to a WooCommerce Product
* Version: 1.1.0
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com
* Requires at least: 5.2.0
* Tested up to: 5.2.2
@helgatheviking
helgatheviking / custom-meta-for-woocommerce-product-variations.php
Last active January 31, 2024 23:06
Add custom fields to WooCommerce variations
<?php
/**
* Plugin Name: Example custom variation meta for WooCommerce
* Plugin URI: hhttps://www.kathyisawesome.com/add-custom-meta-fields-to-woocommerce-variations/
* Description: Add thickness and diameter fields to variations.
* Version: 6.22.5
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Text Domain: extra-product-data
@helgatheviking
helgatheviking / wordpress-add-custom-menu-meta-fields.php
Created February 26, 2020 02:06
Add an example custom meta field to WordPress menu and display text on front-end (Requires WP5.4)
<?php
/**
* Add custom fields to menu item
*
* This will allow us to play nicely with any other plugin that is adding the same hook
*
* @param int $item_id
* @params obj $item - the menu item
* @params array $args
@helgatheviking
helgatheviking / wc-mnm-alphabetical-sorting.php
Last active October 1, 2023 20:29
Sort Mix and Match children alphabetically
<?php
/**
* Sort the mix and match children alphabetically
*
* @param array $children : an array of $product objects
* @param obj $product : the container product
* @return array
*/
function mnm_order_children_args( $children, $product ){
@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-add-field-to-variation.php
Created October 30, 2019 00:51
Example of how to add custom fields to WooCommmerce variations admin and display on front end.
<?php
/**
* Plugin Name: Add sample field to variations
* Plugin URI: https://kathyisawesome.com/
* Description: Example of how to add custom fields to variations admin and display on front end.
* Version: 0.1.0
* Author: helgatheviking
* Author URI: https://kathyisawesome.com
* Text Domain: extra-variation-data
*
@helgatheviking
helgatheviking / woocommerce-shipping-contact.php
Last active June 7, 2023 11:34
Add a shipping email/phone field to checkout and notify of new orders
<?php
/*
Plugin Name: WooCommerce Shipping Contact
Plugin URI: https://github.com/helgatheviking/wc-shipping-contact
Description: Add a shipping email field to checkout and notify of new orders
Version: 1.1.0
Author: Kathy Darling
Author URI: http://kathyisawesome.com
Requires at least: 4.0
Tested up to: 4.8
@helgatheviking
helgatheviking / wc-mnm-price-range.php
Created March 2, 2020 17:31
Change Mix and Match price string from From: $99 to range style $99 - $100
<?php
/**
* Change price string from From: $99 to range style $99 - $100
*
* @return string
*/
function kia_mnm_price_range( $price, $product ) {
if ( $product->get_max_container_size() && $product->get_mnm_price( 'max' ) && $product->get_mnm_price( 'min' ) !== $product->get_mnm_price( 'max' ) ) {
$price = sprintf( _x( '%1$s - %2$s', 'Price range', 'woocommerce-mix-and-match-products' ), $price . $product->get_price_suffix(), $product->get_mnm_price( 'max' ) . $product->get_price_suffix() );