Skip to content

Instantly share code, notes, and snippets.

View boywondercreative's full-sized avatar

shawn boywondercreative

View GitHub Profile
@varun-pluginhive
varun-pluginhive / functions.php
Created November 7, 2018 09:33
Snippet to hide specified shipping methods with zero cost. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to hide specified shipping methods with zero cost.
* Created at : 07 Nov 2018
* Updated at : 07 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/a7b88d265b5ecb89d823ffe9d06daf7c
*/
add_filter( 'woocommerce_package_rates', function( $shipping_rates ){
$shipping_methods = array( 'wf_woocommerce_shipping_pro:1shipping-pro-1'); // Array of Shipping method ids
@xadapter
xadapter / functions.php
Last active March 11, 2020 06:50
Snippet to switch UPS account and origin address based on the destination. Supports WooCommerce UPS Shipping Plugin: https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
<?php
/**
* Snippet to Change UPS account based on destination country while confirming shipment (not while generating packages).
*
*/
add_filter( 'wf_ups_shipment_confirm_request_data', 'switch_origin_adress_based_on_country', 10, 2 );
if( ! function_exists('switch_origin_adress_based_on_country') )
{
@xadapter
xadapter / functions.php
Last active March 10, 2021 04:48
Snippet to change the default WooCommerce shipping method. Supports PluginHive Shipping Plugins: https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/
function wf_default_shipping_method( $method ) {
$the_cheapest_cost = 1000000;
$packages = WC()->shipping()->get_packages()[0]['rates'];
foreach ( array_keys( $packages ) as $key ) {
if ( ( $packages[$key]->cost > 0 ) && ( $packages[$key]->cost < $the_cheapest_cost ) ) {
$the_cheapest_cost = $packages[$key]->cost;
$method_id = $packages[$key]->id;
}
}
@yanknudtskov
yanknudtskov / archive-product.php
Last active August 30, 2021 16:05
FacetWP Pagination for Enfold and WooCommerce #woocommerce #enfold
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
*
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
@ChrisTimperley
ChrisTimperley / install-docker-elementary-loki.sh
Last active April 27, 2020 19:44
Installs Docker on Elementary OS 0.4 (Loki)
#!/bin/bash
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -u -cs) \
stable"
sudo apt-get update
sudo apt-get purge lxc-docker
@mikejolley
mikejolley / functions.php
Last active May 17, 2021 13:51
WooCommerce - Split shipping class items into a new package and limit shipping methods
/**
* This function loops over cart items, and moves any item with shipping class 'special-class' into a new package.
* The new package in this example only takes flat rate shipping.
*/
function split_special_shipping_class_items( $packages ) {
$found_item = false;
$special_class = 'special-class'; // edit this with the slug of your shippig class
$new_package = current( $packages );
$new_package['contents'] = array();
$new_package['contents_cost'] = 0;
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;