Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / tabs.php
Created April 17, 2024 15:20
Change WooCommerce product tabs to accordion - Modify tabs.php template to use the <details> element for accordion like behaviour for product information. https://www.damiencarbery.com/2024/04/change-woocommerce-product-tabs-to-accordion/
<?php
/**
* Single Product tabs
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/tabs/tabs.php.
*
* HOWEVER, on occasion WooCommerce 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
@damiencarbery
damiencarbery / wc-export-order-csv.php
Last active April 5, 2024 16:10
A quick proof of concept of using an order ID to generate a CSV of order details.
<?php
/*
Plugin Name: WooCommerce - Export order details as CSV
Plugin URI: https://www.damiencarbery.com/
Description: Allow exporting the details .
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1
*/
@damiencarbery
damiencarbery / view-order-on-front-end.php
Last active January 19, 2024 17:46
View WooCommerce order on front end - Use an encrypted link to allow a customer view order details on the front end. https://www.damiencarbery.com/2024/01/view-woocommerce-order-on-front-end/
<?php
/*
Plugin Name: View WooCommerce order on front end
Plugin URI: https://www.damiencarbery.com/2024/01/view-woocommerce-order-on-front-end/
Description: Use an encrypted link to allow a customer view order details on the front end.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.2
WC tested to: 8.5.1
*/
@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 / enable-select2-on-ninja-forms-dropdowns.js
Last active January 15, 2024 16:24
Use Select2 for Ninja Forms dropdowns - When a Ninja Forms form has a dropdown, enable Select2 so that the elements are searchable. https://www.damiencarbery.com/2023/12/use-select2-for-ninja-forms-dropdowns/
// This code enables Select2 to dropdowns as they are rendered.
// Create a new object for custom validation of a custom field.
var dcwdDropdownFieldController = Marionette.Object.extend( {
initialize: function() {
// From: https://developer.ninjaforms.com/codex/field-view-rendering/
this.listenTo( nfRadio.channel( 'listselect' ), 'render:view', this.renderView );
},
renderView: function( view ) {
@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
*/
@damiencarbery
damiencarbery / elementor-page-settings.php
Created November 27, 2023 17:20
Add controls to Elementor Post Settings panel - Short demonstration to add a custom control to the Elementor Post Settings panel. https://www.damiencarbery.com/2023/11/add-controls-to-elementor-post-settings-panel/
<?php
/*
Plugin Name: Add controls to Elementor Post Settings panel
Description: Short demonstration to add a custom control to the Elementor Post Settings panel.
Plugin URI: https://www.damiencarbery.com/2023/11/add-controls-to-elementor-post-settings-panel/
Version: 0.1
Author: Damien Carbery
*/
defined( 'ABSPATH' ) || exit;
@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
*/