Skip to content

Instantly share code, notes, and snippets.

View BFTrick's full-sized avatar

Patrick Rauland BFTrick

View GitHub Profile
@BFTrick
BFTrick / woocommerce-example-plugin.php
Created April 6, 2024 20:42
Packt Mastering WooCommerce - Example WooCommerce Plugin
<?php
/*
* Plugin Name: WooCommerce Example Plugin
* Requires Plugins: woocommerce
* Plugin URI: http://speakinginbytes.com
* Description: Our custom WooCommerce functionality
* Version: 2.0
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com
* License: GPL2
@BFTrick
BFTrick / woocommerce-accessible-sale-price.php
Last active February 14, 2024 05:34
Make WooCommerce Sale Prices Accessible
<?php
/*
Plugin Name: WooCommerce Make Sale Prices Accessible
Plugin URI: https://gist.github.com/BFTrick/47b0710a6d27332d0c109cfe75c58be6
Description: Make WooCommerce sale prices accessible
Version: 1.0
Author: Patrick Rauland
Author URI: http://speakinginbytes.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@BFTrick
BFTrick / woocommerce-move-product-price.php
Last active January 28, 2024 20:32
A demo plugin to move the WooCommerce sinmple product price lower
<?php
/*
Plugin Name: WooCommerce Move Product Page Price Lower
Plugin URI: https://gist.github.com/BFTrick/e19bd2bb648558ca78279c3d5ba9524e
Description: A demo plugin to move the WooCommerce sinmple product price lower
Version: 1.0
Author: Patrick Rauland
Author URI: http://speakinginbytes.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@BFTrick
BFTrick / pixel-perfect-webinar-css.css
Last active March 22, 2018 17:25
CSS Animations for the Pixel Perfect Webinar
.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;
}
/* ----------------------------------------------
<?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 November 4, 2016 14:59
Load Heap Analytics
<?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 July 19, 2017 18:58
WooCommerce change the number of products per row. You still have to write CSS so each of the products fit in there.
<?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 July 26, 2016 20:39
Show 20 products per page in WooCommerce
<?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 June 1, 2016 16:46
Sort WooCommerce shipping methods by cost
<?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 23:52
Redirect to a specific product category after a product is added to the cart
<?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' );
}