Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
Infinite data generation engine

Luke Cavanagh lukecav

Infinite data generation engine
View GitHub Profile
@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 / 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 );
/**
* Register term fields
*/
add_action( 'init', 'register_vendor_custom_fields' );
function register_vendor_custom_fields() {
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_add_form_fields', 'add_vendor_custom_fields' );
add_action( WC_PRODUCT_VENDORS_TAXONOMY . '_edit_form_fields', 'edit_vendor_custom_fields', 10 );
add_action( 'edited_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
add_action( 'created_' . WC_PRODUCT_VENDORS_TAXONOMY, 'save_vendor_custom_fields' );
}
@lukecav
lukecav / functions.php
Created August 29, 2016 21:34 — forked from woogist/functions.php
Redirect to a custom page after login based on the user role
<?php
/**
* Redirect users to custom URL based on their role after login
*
* @param string $redirect
* @param object $user
* @return string
*/
function wc_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user