Skip to content

Instantly share code, notes, and snippets.

View codeagencybe's full-sized avatar
🏠
Working from home

Fabio Tielen codeagencybe

🏠
Working from home
View GitHub Profile
@codeagencybe
codeagencybe / text-changes.php
Created January 14, 2016 14:36 — forked from BurlesonBrad/text-changes.php
For Nikki ~ Change Text in WooCommerce
<?php
/**
* Plugin Name: Nikki Gets to Change Her Text
* Plugin URI: https://bradgriffin.me
* Description:
* Version: 1
* Author: Brad
* Author URI: https://bradgriffin.me
* Requires at least: 4.5
* Tested up to: 4.5
@codeagencybe
codeagencybe / quantities-next-add-to-cart-buttons
Created September 26, 2017 08:17
Override loop template and show quantities next to add to cart buttons
<?php
/**
* Override loop template and show quantities next to add to cart buttons
*/
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 );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
@codeagencybe
codeagencybe / CSS
Created April 27, 2018 07:03 — forked from soldier99/CSS
Woocommerce sale flash badges: New, Featured and save percentage
/* Woocommerce regular Sale badge */
.woocommerce span.onsale {
left: 0;
top: -10;
font-weight: 600 !important;
min-width: 100px !important;
text-align: center;
}
.woocommerce ul.products li.product .onsale {
@codeagencybe
codeagencybe / gist:752d2e6551bd37cb6bf7762d738aabfd
Last active April 27, 2018 16:11
WooCommerce show product VAT rating on product page
/**
* Display the tax rate applicable to a product, on the single product page.
*/
function show_product_vat_rating(){
global $product;
$price_incl_tax = wc_get_price_including_tax($product);
$price_excl_tax = wc_get_price_excluding_tax($product);
if(($price_incl_tax != 0) && ($price_excl_tax != 0)) {
@codeagencybe
codeagencybe / wget.txt
Created May 2, 2018 11:50 — forked from suzannealdrich/wget.txt
wget spider cache warmer
wget --spider -o wget.log -e robots=off -r -l 5 -p -S --header="X-Bypass-Cache: 1" live-mysite.gotpantheon.com
# Options explained
# --spider: Crawl the site
# -o wget.log: Keep the log
# -e robots=off: Ignore robots.txt
# -r: specify recursive download
# -l 5: Depth to search. I.e 1 means 'crawl the homepages'.  2 means 'crawl the homepage and all pages it links to'...
# -p: get all images, etc. needed to display HTML page
# -S: print server response
// show new fields in signup form: checkbox for B2B account, billing_company & billing_vat
// perhaps the checkbox can be left away
function ca_extra_register_fields() {?>
<p class="form-row form-row-wide">
<?php _e( 'Ik registreer een zakelijke account', 'woocommerce' ); ?><label for="reg_billing_account"></label>
<input type="checkbox" class="input-text" name="billing_account" id="reg_billing_account" value="<?php esc_attr_e( $_POST['billing_account'] ); ?>" />
</p>
<p class="form-row form-row-wide">
<label for="reg_billing_company"><?php _e( 'Bedrijfsnaam', 'woocommerce' ); ?></label>
<input type="text" class="input-text" name="billing_company" id="reg_billing_company" value="<?php esc_attr_e( $_POST['billing_company'] ); ?>" />
@codeagencybe
codeagencybe / gist:f7ee93916cfef12eb0d555476a16b632
Created July 7, 2018 15:52
hide free shipping if shipping class is in cart
/**
* @snippet Disable free shipping option if a specific shipping class is added to cart
* @author Fabio Tielen // Code Agency // https://codeagency.be
* @testedwith WooCommerce 3.2+
*/
add_filter( 'woocommerce_package_rates', 'ca_hide_free_shipping_for_shipping_class', 10, 2 );
function ca_hide_free_shipping_for_shipping_class( $rates, $package ) {
$shipping_class_target = XXX; // search for shipping class ID in your settings
@codeagencybe
codeagencybe / gist:06736feef01e1a523b48f280076c42e9
Last active July 9, 2018 11:24
conditionally show a custom product badge
/**
* @snippet Checkbox to display Custom Product Badge Part 1 - WooCommerce
* @author Fabio Tielen // Code Agency // https://codeagency.be
* @testedwith Woo 3.3+
*/
// -----------------------------------------
// STEP 1. adding a custom checkbox to product edit page
add_action( 'woocommerce_product_options_general_product_data', 'codeagency_add_badge_checkbox_to_products' );
@codeagencybe
codeagencybe / gist:a1542fbc5b25cbb295be910afbf15f73
Created July 9, 2018 12:18
automatically add product to cart when cart total is above certain amount
/**
* @snippet Automatically add a specific product to cart when cart amount is above certain amount
* @author Fabio Tielen // Code Agency // https://codeagency.be
* @testedwith Woo 3.3+
*/
add_action( 'template_redirect', 'codeagency_add_product_to_cart' );
function codeagency_add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
@codeagencybe
codeagencybe / gist:7a7429334fa504338e45812601dc53a3
Last active August 4, 2018 09:45
WooCommerce order step values
/**
* @description Minimum, maximum, incremental and start quantity for products | WooCommerce
* @author Fabio Tielen / Code Agency / https://codeagency.be
* @testedwith WooCommerce 3.3
*/
add_filter( 'woocommerce_quantity_input_args', 'ca_woocommerce_quantity_increment_changes', 10, 2 );
function ca_woocommerce_quantity_increment_changes( $args, $product ) {
if ( is_singular( 'product' ) ) {