Skip to content

Instantly share code, notes, and snippets.

@jan-koch
jan-koch / remove-woo-scripts.php
Created February 28, 2020 09:14
Remove WooCommerce related resources except on WooCommerce-based pages (products, cart, checkout, etc). Use on a testing environment before pasting this into your live website!
/**
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary.
*
* Please test this on a staging copy of your website before putting this into the functions.php of your live website.
*/
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 );
function my_remove_woo_assets() {
if ( function_exists( 'is_woocommerce' ) ) { // Check if Woo is installed.
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { // Only run on non-Woo pages.
// Remove unnecessary stylesheets.
@Daniel217D
Daniel217D / woocommerce - minimum and maximum price
Last active September 9, 2023 21:02
woocommerce - get minimum and maximum price for current products
function get_filtered_price() {
global $wpdb;
$args = wc()->query->get_main_query();
$tax_query = isset( $args->tax_query->queries ) ? $args->tax_query->queries : array();
$meta_query = isset( $args->query_vars['meta_query'] ) ? $args->query_vars['meta_query'] : array();
foreach ( $meta_query + $tax_query as $key => $query ) {
if ( ! empty( $query['price_filter'] ) || ! empty( $query['rating_filter'] ) ) {
@satya164
satya164 / quantity-query.scss
Last active September 7, 2023 20:06
Quantity Queries in Sass
@mixin quantity-query($selector, $type, $amount, $max: null) {
@if $type == at-least {
#{$selector}:nth-last-child(n+#{$amount}),
#{$selector}:nth-last-child(n+#{$amount}) ~ #{$selector} { @content; }
} @else if $type == at-most {
#{$selector}:nth-last-child(-n+#{$amount}):first-child,
#{$selector}:nth-last-child(-n+#{$amount}):first-child ~ #{$selector} { @content; }
} @else if $type == between {
@if type-of($max) != "number" {
@error "Max value must be a number for quantity-query.";
@drawcard
drawcard / woocommerce-sage-template-part-overrides.md
Last active August 16, 2021 08:39
Woocommerce - Using template part overrides in Sage

So, you know how to override a template file in Woocommerce using Sage, but you're having trouble changing something within the deeper level of that template file. For example, you want to change the output HTML structure of a given part of the product page loop, or incorporate a Bootstrap class into a button element without using Jquery to inject it. Here's how you can override deeper level parts, the default WC theme elements.

Prerequisites

Now you're familiar with how to do Sage + Woocommerce templates, it's time to make it happen.

The template page override

@vlandham
vlandham / part1.md
Last active March 21, 2024 12:57
Feature Branches and Pull Requests : Walkthrough

Here's a little walkthrough of how Yannick and I are using feature branches and pull requests to develop new features and adding them to the project. Below are the steps I take when working on a new feature. Hopefully this, along with watching the process on Github, will serve as a starting point to having everyone use a similar workflow.

Questions, comments, and suggestions for improvements welcome!

Start with the latest on master

When starting a new feature, I make sure to start with the latest and greatest codebase:

git checkout master
@brianmacarthur
brianmacarthur / flash-app.js
Last active July 10, 2023 18:41
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@einkoro
einkoro / password_bcrypt.php
Last active May 10, 2016 16:52
Must-use plugin for WordPress to swap phpass to PHP 5.5's new password_hash and password_verify using bcrypt
<?php
/**
* Plugin Name: WP PASSWORD_BCRYPT
* Plugin URI: http://bitpiston.com/
* Description: Replaces wp_hash_password and wp_check_password's phpass hasher with PHP 5.5's password_hash and password_verify using bcrypt.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.2
* Licence: BSD
*/
anonymous
anonymous / class-piklist.php
Created February 15, 2014 09:35
includes/class-piklist.php - Solution to getting piklist working on windows (and in my case, on a dropbox hardlinked folder structure)
<?php
if (!defined('ABSPATH'))
{
exit;
}
class PikList
{
public static $version;
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );