Skip to content

Instantly share code, notes, and snippets.

View daveloodts's full-sized avatar

Dave Loodts daveloodts

View GitHub Profile
@daveloodts
daveloodts / gist:67473ca072f613fb4f1175b2463504dc
Created January 15, 2021 09:41
Verplichte checkbox toevoegen in WooCommerce + notificatie indien niet ingevuld
/**
* Add WooCommerce Checkbox checkout
*/
add_action( 'woocommerce_review_order_before_submit', 'woofers_add_checkout_checkbox', 10 );
function woofers_add_checkout_checkbox() {
woocommerce_form_field( 'checkout-checkbox', array( // CSS ID
'type' => 'checkbox',
'class' => array('form-row mycheckbox'), // CSS Class
'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
wp_enqueue_style( 'site-css', get_template_directory_uri() . '/assets/css/style.css', array(),filemtime(get_theme_file_path('/assets/css/style.css')), 'all' );
@daveloodts
daveloodts / gist:53a3827e9dc1a88648bd1273c88ca2f8
Created January 14, 2021 06:12
Tekst in WooCommerce checkout afhankelijk de shipping zone
/* add_action( 'woocommerce_cart_totals_after_shipping' , 'shipping_zone_targeted_postcodes_custom_notice' ); */
add_action( 'woocommerce_review_order_after_shipping' , 'shipping_zone_targeted_postcodes_custom_notice' );
function shipping_zone_targeted_postcodes_custom_notice() {
// HERE DEFINE YOUR SHIPPING ZONE NAME(S)
$targeted_zones_names = array('Afhalen'); // <====== <====== <====== <====== <======
// Get the customer shipping zone name
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); // The chosen shipping mehod
$chosen_method = explode(':', reset($chosen_methods) );
$shipping_zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $chosen_method[1] );
@daveloodts
daveloodts / gist:a36a27a8efdc08871eeebb5ea461c16a
Created January 14, 2021 06:10
Tekst in WooCommerce checkout afhankelijk verzendzone en bedrag in winkelmand
add_action( 'woocommerce_review_order_after_shipping' , 'shipping_zone_targeted_postcodes_afhaal2030' );
function shipping_zone_targeted_postcodes_afhaal2030() {
// HERE DEFINE YOUR SHIPPING ZONE NAME(S)
$targeted_zones_names = array('Verzendzones 20 euro', 'Verzendzone 30 euro'); // <====== <====== <====== <====== <======
// Get the customer shipping zone name
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); // The chosen shipping mehod
$chosen_method = explode(':', reset($chosen_methods) );
$shipping_zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $chosen_method[1] );
$current_zone_name = $shipping_zone->get_zone_name();
@daveloodts
daveloodts / gist:b81ba5970b7580e21cbcb282ce93d7a4
Created March 27, 2020 12:19
Hide free shipping in cart when multiple specific shipping class #woocommerce #shipping
/* verberg gratis shipping > €85 als verzendklasse groot in winkelwagen zit */
/* source: https://businessbloomer.com/woocommerce-disable-free-shipping-if-cart-has-shipping-class/ */
add_filter( 'woocommerce_package_rates', 'hide_free_shipping_for_shipping_class', 10, 2 );
function hide_free_shipping_for_shipping_class( $rates, $package ) {
$shipping_class_target = array( 220,318,319); // shipping class ID (to find it, see screenshot below)
$in_cart = false;
foreach( WC()->cart->get_cart_contents() as $key => $values ) {
$product_shipping_class = $values[ 'data' ]->get_shipping_class_id();
if (in_array($product_shipping_class, $shipping_class_target)) {
@daveloodts
daveloodts / gist:dbcabc8187facb58c847f036bcc152af
Last active March 27, 2020 09:25
Display a custom text under cart item name in checkout #woocommerce #shipping
// Display a custom text under cart item name in checkout
add_filter( 'woocommerce_checkout_cart_item_quantity', 'custom_checkout_text_cart_item_name', 10, 3 );
function custom_checkout_text_cart_item_name( $item_qty, $cart_item, $cart_item_key ) {
// Here below define your shipping class slug
$shipping_class = 'be-shipping-klein';
if( $cart_item['data']->get_shipping_class() === $shipping_class ) {
$item_qty .= '<br /><div class="item-shipping-class">' . __("Gratis geleverd 2-4 werkdagen", "woocommerce") . '</div>';
}
return $item_qty;
@daveloodts
daveloodts / gist:7cb0915942c31e71f09d0327a463603a
Last active March 27, 2020 09:25
Display a custom text under cart item name in cart page for specific shipping class #WooCommerce #shipping
// Display a custom text under cart item name in cart page for specific shipping class
add_filter( 'woocommerce_cart_item_name', 'custom_text_cart_item_name', 10, 3 );
function custom_text_cart_item_name( $item_name, $cart_item, $cart_item_key ) {
// Here below define your shipping class slug
$shipping_class = 'be-shipping-klein';
if( is_cart() && $cart_item['data']->get_shipping_class() === $shipping_class ) {
$item_name .= '<br /><div class="item-shipping-class">' . __("Gratis geleverd 2-4 werkdagen", "woocommerce") . '</div>';
}
<?php
// link to the font file no the server
$fontname = 'font/Capriola-Regular.ttf';
// controls the spacing between text
$i=30;
//JPG image quality 0-100
$quality = 90;
function create_image($user){
function wpdocs_custom_excerpt_length( $length ) {
return 150;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
@daveloodts
daveloodts / wcant.css
Created September 12, 2017 13:56
WCANT css
/*
Theme Name: Twenty Fifteen
Description: Used to style the TinyMCE editor.
*/
/**
* Table of Contents:
*
* 1.0 - Body
* 2.0 - Typography
* 3.0 - Elements