Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🙏
Please watch out for each other

Luke Cavanagh lukecav

🙏
Please watch out for each other
View GitHub Profile
<?php
add_filter( 'woocommerce_no_shipping_available_html', 'my_custom_no_shipping_message' );
add_filter( 'woocommerce_cart_no_shipping_available_html', 'my_custom_no_shipping_message' );
function my_custom_no_shipping_message( $message ) {
return __( 'A minimum of 6 products is required. Add more products to complete your purchase' );
}
@lukecav
lukecav / wc-redirect-after-add-to-cart.php
Created August 9, 2016 16:07 — forked from JeroenSormani/wc-redirect-after-add-to-cart.php
WooCommerce redirect after add to cart
/**
* Redirect to checkout at add-to-cart action.
*/
function redirect_to_checkout() {
return WC()->cart->get_checkout_url();
}
add_filter( 'woocommerce_add_to_cart_redirect', 'redirect_to_checkout' );
------------------------------------
@lukecav
lukecav / phprc
Created August 10, 2016 22:09 — forked from rfmeier/phprc
Enable opcache on DreamHost for php 5.5 and greater
[opcache]
; the path to the .so file
zend_extension=opcache.so
; Enabled. Set to 0 to disable
opcache.enable=1
; Max memory consumption. Default 32 megs
opcache.memory_consumption=32
@lukecav
lukecav / gist:0ccf9101665b8b6b88d4e834f7c2bd5e
Created August 11, 2016 16:43 — forked from bradleysa/gist:7d1448253097784daf94
WooCommerce: Add Continue Shopping Button on Cart Page
<?php
/**
* Add Continue Shopping Button on Cart Page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
@lukecav
lukecav / functions.php
Created August 15, 2016 17:17 — forked from mikejolley/functions.php
WooCommerce - Show quantity inputs for simple products within loops.
<?php
/**
* Code should be placed in your theme functions.php file.
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
@lukecav
lukecav / add-to-cart.php
Created August 15, 2016 17:20 — forked from claudiosanches/add-to-cart.php
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@lukecav
lukecav / wp-seo-tweaks.php
Created August 16, 2016 20:12 — forked from theJasonJones/wp-seo-tweaks.php
Had to a few tweaks to the WP-SEO breadcrumbs. This is what I did.
<?php
// Remove the last link in breadcrumbs
// WHY? Because it an span tag that contains the title of the page
// But you're already on the page, so what's the point?
add_filter( 'wpseo_breadcrumb_links', 'jj_wpseo_breadcrumb_links' );
function jj_wpseo_breadcrumb_links( $links ) {
//pk_print( sizeof($links) );
if( sizeof($links) > 1 ){
array_pop($links);
@lukecav
lukecav / gravity-form-reset.less
Created August 16, 2016 20:14 — forked from theJasonJones/gravity-form-reset.less
Base Gravity Form Reset
#gform_wrapper_1{
li { .clearfix(); position: relative; }
label { float: left; width: 25%;
@media( max-width: @screen-xs-max ){ float: none; width: 100%; }
}
input, select, textarea { width: 75%; float: left; color: @black; .fs(18px);
@media( max-width: @screen-xs-max ){ float: none; width: 100%; }
}
.gfield_checkbox{
li { width: auto; float: left; }
@lukecav
lukecav / acf-fields.php
Created August 29, 2016 18:19 — forked from hereswhatidid/acf-fields.php
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'acf_product_options',
'title' => 'Product Options',
'fields' => array (
array (
'key' => 'acf_product_options_tabbedcontent_label',
'label' => 'Tabbed Content',
@lukecav
lukecav / functions.php
Created August 29, 2016 21:24 — forked from woogist/functions.php
Autocomplete all WooCommerce orders
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );