Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / wc-defer-order-emails.php
Last active January 9, 2024 15:54
Defer WooCommerce emails for a few minutes - Defer WooCommerce emails for a specified time after the normal delivery time. https://www.damiencarbery.com/2020/04/defer-woocommerce-emails-for-a-few-minutes/
<?php
/*
Plugin Name: Defer WooCommerce emails for a few minutes (use Action Scheduler)
Plugin URI: https://www.damiencarbery.com/2020/04/defer-woocommerce-emails-for-a-few-minutes/
Description: Defer WooCommerce emails for a specified time after the normal delivery time. Use Action Scheduler instead of WP Cron. Call do_action() instead of remove_action() and calling trigger.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.8
*/
@damiencarbery
damiencarbery / add-class-on-ninja-forms-dropdowns.js
Last active January 9, 2024 10:23
Ninja Forms - add class to listselect element as element rendered
// This code attempts to add a .with-border class to dropdowns as they are rendered.
// Create a new object for custom validation of a custom field.
var dcwdCustomFieldController = Marionette.Object.extend( {
initialize: function() {
console.log( 'In initialize of new code 1154' );
// From: https://developer.ninjaforms.com/codex/field-view-rendering/
this.listenTo( nfRadio.channel( 'listselect' ), 'render:view', this.renderView );
},
@damiencarbery
damiencarbery / hide-non-free-shipping-rates.php
Created January 1, 2024 13:43
Hide shipping rates if free shipping available - Hide non-free shipping rates if zero cost shipping rates are available. https://www.damiencarbery.com/2024/01/hide-shipping-rates-if-free-shipping-available/
<?php
/*
Plugin Name: Hide shipping rates if free shipping available
Plugin URI: https://www.damiencarbery.com/2024/01/hide-shipping-rates-if-free-shipping-available/
Description: Hide non-free shipping rates if zero cost shipping rates are available.
Author: Damien Carbery
Version: 0.1
WC tested up to: 8.4.0
*/
@damiencarbery
damiencarbery / cf7-form.txt
Last active December 29, 2023 22:05
Use Select2 for Contact Form 7 dropdowns - When a Contact Form 7 form has a dropdown, enable Select2 so that the elements are searchable. https://www.damiencarbery.com/2023/12/use-select2-for-contact-form-7-dropdowns/
<p>Experiment with <a href="https://contactform7.com/2023/06/20/setting-upper-limit-of-checkbox-selection/">Schema-Woven Validation</a> and limiting the number of checkboxes that can be clicked.</p>
<label> Your name
[text* your-name] </label>
<label> Your email
[email* your-email] </label>
[select your-country class:enable-select2 "China" "India" "San Marino" "Adélie penguin" "Emperor penguin" "Gentoo penguin" "Little penguin" "Humboldt penguin" "Southern rockhopper penguin" "Galapagos penguin"]
@damiencarbery
damiencarbery / add-order-note-after-email-sent.php
Created December 13, 2023 15:26
Add order note after WooCommerce order email sent - Add a private order note when an order email is sent to the customer. https://www.damiencarbery.com/2023/12/add-order-note-when-email-sent-to-customer/
<?php
/*
Plugin Name: Add order note after WooCommerce order email sent
Plugin URI: https://www.damiencarbery.com/2023/12/add-order-note-when-email-sent-to-customer/
Description: Add a private order note when an order email is sent to the customer.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1
WC tested to: 8.3.1
*/
<?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, email, phone number, full name or order number 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. Asked on <a href="https://www.facebook.com/groups/advanced.woocommerce/permalink/6233848903296143/">WooCommerce Community Facebook group</a>.
Author: Damien Carbery
Version: 0.5
*/
@damiencarbery
damiencarbery / notify-admin-of-address-change.php
Last active November 14, 2023 17:34
Notify admin of customer address changes - Email the site admin when a customer changes their billing or shipping address in WooCommerce. https://www.damiencarbery.com/2019/09/notify-admin-of-customer-address-changes/
<?php
/*
Plugin Name: Notify admin of customer address changes
Plugin URI: https://www.damiencarbery.com/2019/09/notify-admin-of-customer-address-changes/
Description: Email the site admin when a customer changes their billing or shipping address in WooCommerce.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.2
WC tested up to: 8.2.2
*/
@damiencarbery
damiencarbery / days-messages-widget.php
Created September 20, 2023 14:52
Elementor Days Widget - Display different text based on the day of the week. https://www.damiencarbery.com/2023/10/custom-elementor-widget-daily-text/
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Elementor DaysMessages Widget - Elementor widget that displays different text based on the day of the week.
class Elementor_DaysMessages_Widget extends \Elementor\Widget_Base {
// Set widget internal name.
public function get_name() {
@damiencarbery
damiencarbery / wc-defer-advanced-notifications.php
Last active October 27, 2023 21:31
Defer WooCommerce Advanced Notifications emails for a few minutes - Delay the sending of emails from the Advanced Notification plugin. https://www.damiencarbery.com/2023/10/defer-woocommerce-advanced-notifications-emails-for-a-few-minutes/
<?php
/*
Plugin Name: Defer WooCommerce Advanced Notifications emails for a few minutes
Plugin URI: https://www.damiencarbery.com/2023/10/defer-woocommerce-advanced-notifications-emails-for-a-few-minutes/
Description: Delay the sending of emails from the Advanced Notification plugin for a specified time after the normal delivery time. Use Action Scheduler instead of WP Cron.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1
*/
@damiencarbery
damiencarbery / cmb2-options-page.php
Last active October 15, 2023 05:42
Use a CMB2 options page to populate Ninja Forms dropdown: Use an options page to create dynamic select options for a Ninja Forms. Easier for a client to manage. https://www.damiencarbery.com/2019/01/use-a-cmb2-options-page-to-populate-ninja-forms-dropdown/
<?php
/*
Plugin Name: CMB2 Options Page
Plugin URI: https://www.damiencarbery.com/2019/01/use-a-cmb2-options-page-to-populate-ninja-forms-dropdown/
Description: Use CMB2 to add an options page with repeater fields.
Author: Damien Carbery
Version: 0.2
*/
// Create an options page.