Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Rauland BFTrick

View GitHub Profile
@BFTrick
BFTrick / pixel-perfect-webinar-css.css
Last active Mar 22, 2018
CSS Animations for the Pixel Perfect Webinar
View pixel-perfect-webinar-css.css
.home .products .product .price {
opacity: 0;
}
.home .products .product:hover .price {
-webkit-animation: fade-in-bottom 0.6s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
animation: fade-in-bottom 0.6s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
}
/* ----------------------------------------------
View pixel-perfect-webinar.php
<?php
/*
Plugin Name: Pixel Perfect Webinar Changes
Description: The changes for the Pixel Perfect Webinar
Version: 1.0.0
Author: Patrick Rauland
Author URI: https://speakinginbytes.com
*/
@BFTrick
BFTrick / heap.php
Last active Nov 4, 2016
Load Heap Analytics
View heap.php
<?php
/*
* Plugin Name: Heap Analytics
* Plugin URI: https://gist.github.com/BFTrick/bb3b3b0e0497e8adecfa00e3c8e1b33d
* Description: Send all site data to Heap Analytics
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com
* Version: 1.0
*/
@BFTrick
BFTrick / functions.php
Last active Jul 19, 2017
WooCommerce change the number of products per row. You still have to write CSS so each of the products fit in there.
View functions.php
<?php
// change the number of products per row
add_filter( 'loop_shop_columns', 'patricks_loop_columns', 20 );
function patricks_loop_columns() {
return 5; // the number of products per row
}
// you still need to add CSS to make it look right. In Storefront you can add this to your style.css file.
// @media (min-width:768px){
// .products .product {
@BFTrick
BFTrick / functions.php
Last active Jul 26, 2016
Show 20 products per page in WooCommerce
View functions.php
<?php
// Display 25 products per page. Goes in your theme's functions.php
// Credit: https://gist.github.com/jameskoster/1601682
add_filter( 'loop_shop_per_page', 'patricks_products_per_page', 20 );
function patricks_products_per_page( $num_products ) {
return 20;
}
@BFTrick
BFTrick / functions.php
Created Jun 1, 2016
Sort WooCommerce shipping methods by cost
View functions.php
<?php
// credit: ChromeOrange - https://gist.github.com/ChromeOrange/10013862
add_filter( 'woocommerce_package_rates' , 'patricks_sort_woocommerce_available_shipping_methods', 10, 2 );
function patricks_sort_woocommerce_available_shipping_methods( $rates, $package ) {
// if there are no rates don't do anything
if ( ! $rates ) {
return;
}
@BFTrick
BFTrick / functions.php
Last active May 31, 2016
Redirect to a specific product category after a product is added to the cart
View functions.php
<?php
add_filter( 'woocommerce_add_to_cart_redirect', 'patricks_custom_cart_redirect' );
function patricks_custom_cart_redirect() {
// our prodcut category ID
$product_cat_id = 10; // replace this number with your category ID
// redirect to the page
return get_term_link( $product_cat_id, 'product_cat' );
}
@BFTrick
BFTrick / functions.php
Created May 31, 2016
Redirect add to cart action to Shop page
View functions.php
<?php
// credit: WooThemes https://gist.github.com/woogist/6fd2d358bb2e51a25ac5
add_filter( 'woocommerce_add_to_cart_redirect', 'patricks_custom_cart_redirect' );
function patricks_custom_cart_redirect() {
return get_permalink( wc_get_page_id( 'shop' ) );
}
@BFTrick
BFTrick / style.css
Last active Jan 29, 2019
Hide unnecessary elements on the woocommerce checkout page - compatible with the Storefront theme
View style.css
.woocommerce-checkout .storefront-primary-navigation,
.woocommerce-checkout .site-search,
.woocommerce-checkout .header-widget-region,
.woocommerce-checkout .footer-widgets {
display: none;
}
@BFTrick
BFTrick / functions.php
Created May 26, 2016
Add a "How did you hear about us" field in WooCommerce
View functions.php
<?php
// Filter the checkout fields
add_filter( 'woocommerce_checkout_fields', 'patricks_woocommerce_checkout_fields' );
// add a "how did you hear about us" field - $fields is passed via the filter
function patricks_woocommerce_checkout_fields( $fields ) {
// add the field
$fields['order']['hear_about_us'] = array(
'type' => 'select',
'class' => array( 'form-row-wide' ),
You can’t perform that action at this time.