Skip to content

Instantly share code, notes, and snippets.

Damien Carbery damiencarbery

Block or report user

Report or block damiencarbery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cart-contents-shortcode.php
<?php
// To the CF7 form add:
// [dynamichidden dynamichidden-cart "cart_contents"]
// In the CF7 Mail add:
// [dynamichidden-cart]
// The "cart_contents" uses this code
add_shortcode( 'cart_contents', 'dcwd_cart_contents' );
function dcwd_cart_contents($atts, $content, $code) {
$cart_contents = array();
View wc-order-history-test.php
<?php
/*
Plugin Name: WooCommerce Order History Test
Plugin URI: http://www.damiencarbery.com
Description: Quick experiment with adding order history info to My Orders tab.
Author: Damien Carbery
Version: 0.1
$Id: $
*/
View wc-free-shipping-notice.php
<?php
/*
Plugin Name: WooCommerce - Free Shipping Notice
Plugin URI: http://www.damiencarbery.com
Description: Add note about free shipping for all except one product.
Author: Damien Carbery
Version: 0.1
*/
View eircode-ireland-addresses.php
<?php
/*
Plugin Name: Eircode field for Irish addresses
Plugin URI: http://www.damiencarbery.com
Description: Eircode field for Ireland addresses in WooCommerce.
Author: Damien Carbery
Version: $Revision: $
*/
@damiencarbery
damiencarbery / my-dashboard.php
Created Dec 20, 2016
Customise WooCommerce template files in a plugin
View my-dashboard.php
<?php
/**
* My Account Dashboard
*
* Shows the first intro screen on the account dashboard.
*
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/dashboard.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
@damiencarbery
damiencarbery / conditional-debug-code.php
Last active Jan 20, 2017
Debugging with WordPress - enable WP_DEBUG, with sample usage to investigate wc_get_template()
View conditional-debug-code.php
<?php
// Only call error_log() when in debug mode.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log('WP_DEBUG is enabled');
}
@damiencarbery
damiencarbery / basic-get-site-title.php
Last active Jan 27, 2017
Standalone WordPress Scripts
View basic-get-site-title.php
<?php
define('WP_USE_THEMES', false);
require( 'wp-blog-header.php' );
bloginfo( 'name' );
View add-cf7-popup-to-product-page.php
<?php
/*
Plugin Name: CF7 to product page
Plugin URI: https://www.damiencarbery.com/2018/06/customise-choose-an-option-dropdown-item/
Description: Add a Contact Form 7 form to the product page.
Author: Damien Carbery
Version: 0.1
WC tested up to: 3.5.5
*/
@damiencarbery
damiencarbery / aj-demo-ajax-code.js
Last active May 17, 2019
Demo of AJAX in WordPress
View aj-demo-ajax-code.js
jQuery(document).ready( function(){
jQuery('.count_btn').on('click', function(e) {
var post_type = jQuery(this).data( 'type' ); // Get post type via the 'data-type' attribute of the button.
jQuery('#'+post_type+'_count').html('?'); // Clear existing value.
e.preventDefault();
jQuery.ajax({
url : aj_ajax_demo.ajax_url, // Note that 'aj_ajax_demo' is from the wp_localize_script() call.
@damiencarbery
damiencarbery / rac-calc-free-shipping-min-amount.php
Last active Feb 13, 2017
Woocommerce - Promote Free Shipping
View rac-calc-free-shipping-min-amount.php
<?php
// Code inspired by http://ibenic.com/ultimate-guide-woocommerce-shipping-zones/
function rac_get_free_shipping_amount( $package ) {
$all_zones = WC_Shipping_Zones::get_zones();
$shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
$min_amounts = array();
// Verify that the shipping zone is in $all_zones (zone id 0 isn't!)
if ( array_key_exists( $shipping_zone->get_id(), $all_zones ) ) {
$methods = $all_zones[ $shipping_zone->get_id() ][ 'shipping_methods' ];
You can’t perform that action at this time.