Skip to content

Instantly share code, notes, and snippets.

View AmeliaBriscoe's full-sized avatar

Amelia Briscoe AmeliaBriscoe

View GitHub Profile
@AmeliaBriscoe
AmeliaBriscoe / show_unit_stock.php
Created January 28, 2021 22:46
Show Unit Stock for Products that have Pre-Orders enabled.
<?php
add_action( 'woocommerce_single_product_summary', 'bbloomer_product_sold_count', 11 );
function bbloomer_product_sold_count() {
global $product;
$units_sold = $product->get_total_sales();
if ( $units_sold && ( 'yes' === $product->get_meta( '_wc_pre_orders_enabled' ) ) ) echo '<p>' . sprintf( __( 'Units Sold: %s', 'woocommerce' ), $units_sold ) . '</p>';
}
@AmeliaBriscoe
AmeliaBriscoe / add-bcc-to-email.php
Created October 4, 2019 02:55
Add Bcc to WooCommerce Emails
<?php
add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
$email = array('new_order', 'new_booking');
if (in_array($object, $email)) {
$headers .= 'BCC: Admin <email@domain.com>' . "\r\n";
@AmeliaBriscoe
AmeliaBriscoe / gifting-checked.php
Last active November 22, 2021 03:36
Gifting for Subscriptions box checked by default
<?php
/* set the gifting checkbox to be autochecked */
add_filter('wcsg_recipient_checkbox_checked', '__return_true');
@AmeliaBriscoe
AmeliaBriscoe / show-all-products.php
Created August 22, 2019 02:36
Override the default number of products on the shop page to show all products
<?php
/*
* Display all products on one page.
*/
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ), 20 );
@AmeliaBriscoe
AmeliaBriscoe / auto-check-update-subs.php
Created August 20, 2019 23:37
Auto-check Update All Subscriptions Checkbox
<?php
/* Auto check box to update the shipping/billing address on all subscriptions */
add_filter( 'wcs_update_all_subscriptions_addresses_checked', '__return_true' );
/* Auto check box to update the payment method on all subscriptions */
add_filter( 'wcs_update_all_subscriptions_payment_method_checked', '__return_true' );
@AmeliaBriscoe
AmeliaBriscoe / my-account-filters.php
Last active November 22, 2021 03:33
Example filters to change a label in My Account, or remove it
<?php
/* rename the Membership tab in My account
*/
add_filter( 'woocommerce_account_menu_items', 'wcs_rename_membership_my_account', 999 );
function wcs_rename_membership_my_account( $items ) {
$items['members-area'] = 'Custom Tab Title';
return $items;
}
@AmeliaBriscoe
AmeliaBriscoe / woo-customer-cancelled-failed-email.php
Last active November 22, 2021 03:33
Send WooCommerce cancelled or failed order email to customers
<?php
/*
* add the customer to the recipient field for the WooCommerce Failed and Cancelled Order email
*/
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
add_filter( 'woocommerce_email_recipient_failed_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
@AmeliaBriscoe
AmeliaBriscoe / append-product-name.php
Last active November 22, 2021 03:34
Append the product name of the subscription to the ID in the My Account area.
<?php
/*
* Adds subscription name, with link to the product page, beside subscription ID in My Account > Subscriptions
*/
add_action( 'woocommerce_my_subscriptions_after_subscription_id', 'wcs_add_subscription_name_to_table', 35 );
function wcs_add_subscription_name_to_table( $subscription ) {
foreach ( $subscription->get_items() as $item_id => $item ) {
@AmeliaBriscoe
AmeliaBriscoe / index.html
Created September 11, 2018 22:56
JavaScript for WordPress 1.2.1 - Writing JavaScript in the Browser // source https://jsbin.com/powapa
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="1.2.1 - Writing JavaScript in the Browser">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JavaScript for WordPress</title>
<style id="jsbin-css">
form {
background: #fff;
@AmeliaBriscoe
AmeliaBriscoe / index.html
Created September 11, 2018 22:49
JS Bin 1.2.10 - Strong v Weak Typing and typeof // source https://jsbin.com/jiturin
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="1.2.10 - Strong v Weak Typing and typeof">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>