Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / attach-product-docs-to-cf7-email.php
Last active December 19, 2022 13:05
Attach WooCommerce product docs to Contact Form 7 email - Create a brochure request form to send documents to a customer. https://www.damiencarbery.com/2022/12/attach-woocommerce-product-docs-to-contact-form-7-email/
View attach-product-docs-to-cf7-email.php
<?php
/*
Plugin Name: Attach WooCommerce product docs to Contact Form 7 email
Plugin URI: https://www.damiencarbery.com/2022/12/attach-woocommerce-product-docs-to-contact-form-7-email/
Description: Create a brochure request form to send documents to a customer.
Author: Damien Carbery
Version: 0.1
WC tested up to: 7.2.0
*/
@damiencarbery
damiencarbery / genesis-breadcrumb-link-current-view.php
Created December 14, 2022 12:37
Make title a link in Genesis breadcrumbs
View genesis-breadcrumb-link-current-view.php
@damiencarbery
damiencarbery / acf-load-select-values.php
Created December 9, 2022 20:51
Populate ACF Select field with menu names - Use the acf/load_value filter to load values to a Select field. https://www.damiencarbery.com/2022/12/populate-acf-select-field-with-menu-names/
View acf-load-select-values.php
<?php
/*
Plugin Name: Populate ACF Select field with menu names
Plugin URI: https://www.damiencarbery.com/2022/12/populate-acf-select-field-with-menu-names/
Description: Use the acf/load_value filter to load values to a Select field.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / wc-show-shipping-class-ids.php
Created December 3, 2022 16:00
Show shipping class IDs in WooCommerce - List shipping classes and their IDs for use in custom code. https://www.damiencarbery.com/2022/12/show-shipping-class-ids-in-woocommerce/
View wc-show-shipping-class-ids.php
<?php
/*
Plugin Name: Show shipping class IDs in WooCommerce
Plugin URI: https://www.damiencarbery.com/2022/12/show-shipping-class-ids-in-woocommerce/
Description: List shipping classes and their IDs for use in custom code.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / wc-convert-order-note-to-custom-field.php
Last active November 23, 2022 15:34
Convert WooCommerce order note to custom field - Parse order notes to extract a shipping tracking number, creating a custom field if found.
View wc-convert-order-note-to-custom-field.php
<?php
/*
Plugin Name: Convert WooCommerce order note to custom field
Plugin URI: https://www.damiencarbery.com/
Description: Parse order notes to extract a shipping tracking number, creating a custom field if found.
Author: Damien Carbery
Version: 0.2
*/
@damiencarbery
damiencarbery / divisible-and-at-least-6.php
Created November 23, 2022 09:54
Check whether numbers are divisible by 6 and are at least 6 (for checking the weight of a WooCommerce cart).
View divisible-and-at-least-6.php
<?php
$weights = array( -6, 0, 2, 4, 6, 8, 10, 12, 13, 17, 18, 21, 24, 29, 30, 31 );
$min_weight = 6;
$increments = 6;
foreach ( $weights as $weight ) {
echo "Weight: $weight\n";
// Check if divisible by $increments.
if ( $weight % $increments == 0 ) {
@damiencarbery
damiencarbery / create-admin-user.php
Created November 20, 2022 19:27
Create a new admin user programmatically - If you have ftp access you can create an admin user for yourself.
View create-admin-user.php
<?php
/*
Plugin Name: Create a new admin user programmatically
Plugin URI: https://www.damiencarbery.com/2022/11/create-a-new-admin-user-programmatically/
Description: If you have ftp access you can create an admin user for yourself.
Author: Damien Carbery
Version: 0.1
*/
// Code originally from https://wphub.me/create-new-wordpress-admin-user-programmatically/
@damiencarbery
damiencarbery / posts-featured-image-column.php
Created November 5, 2022 19:16
Add Featured Image column to Posts admin page - Easily see whether a post has a featured image set. https://www.damiencarbery.com/2022/11/add-featured-image-column-to-posts-admin-page/
View posts-featured-image-column.php
@damiencarbery
damiencarbery / attach-download-files-to-cf7-email.php
Created November 3, 2022 12:55
Attach WooCommerce download docs to Contact Form 7 email
View attach-download-files-to-cf7-email.php
<?php
/*
Plugin Name: Attach WooCommerce download docs to Contact Form 7 email
Plugin URI: https://www.damiencarbery.com/
Description: Use a CF7 filter to attach a WooCommerce product's downloadable files to the email.
Author: Damien Carbery
Version: 0.2
*/
View wc-copy-order-address-to-clipboard.php
<?php
/*
Plugin Name: Copy WooCommerce order shipping address to clipboard
Plugin URI: https://www.damiencarbery.com/2022/11/copy-woocommerce-order-shipping-address-to-clipboard/
Description: Copy the shipping (or billing) address to the clipboard for pasting in another application. A WooCommerce Community member asked how to add a button to the order admin page to copy the shipping address to the clipboard. https://www.facebook.com/groups/advanced.woocommerce/permalink/6233848903296143/
Author: Damien Carbery
Version: 0.2
*/