Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
working remotely

Vlado Bosnjak Bobz-zg

👨‍💻
working remotely
View GitHub Profile
@Bobz-zg
Bobz-zg / include-email-in-woocommerce-address-output.php
Created Feb 12, 2021
Include email address in WooCommerce address output | Part 3
View include-email-in-woocommerce-address-output.php
<?php
/**
* Replace {email} shortcode with actual email address
*
* @link https://github.com/woocommerce/woocommerce/blob/5a707f3e74a18af2d7bf14c20ee65e702a119557/includes/class-wc-countries.php#L601
*/
add_filter('woocommerce_formatted_address_replacements', function( $address, $args ) {
// Replace email for billing address
if ( isset( $args['billing_email'] ) )
@Bobz-zg
Bobz-zg / include-email-in-woocommerce-address-output.php
Last active Feb 16, 2021
Include email address in WooCommerce address output | Part 2
View include-email-in-woocommerce-address-output.php
<?php
/**
* Append email in list of visible info
*
* @link https://github.com/woocommerce/woocommerce/blob/ab4a46e32e338cbf33094ab26144744a021a21a9/includes/wc-account-functions.php#L316
*/
add_filter( 'woocommerce_my_account_my_address_formatted_address', function( $address, $user_id, $address_type ) {
// Meta key is either billing or shipping
$meta_key = $address_type . '_email';
@Bobz-zg
Bobz-zg / include-email-in-woocommerce-address-output.php
Created Feb 12, 2021
Include email address in WooCommerce address output | Part 1
View include-email-in-woocommerce-address-output.php
<?php
/**
* Append email to address format
*
* @link https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-countries.php#L510
*/
add_filter( 'woocommerce_localisation_address_formats', function( $formats ) {
// Double quotes in sprintf() or \n will not be parsed as a new line character
@Bobz-zg
Bobz-zg / input.scss
Created Dec 7, 2020
Generated by SassMeister.com.
View input.scss
.forms-report-service {
&.loading {
opacity: 0.6;
pointer-events: none;
}
/**
* Grid
@Bobz-zg
Bobz-zg / input.scss
Created Dec 7, 2020
Generated by SassMeister.com.
View input.scss
.forms-report-service {
&.loading {
opacity: 0.6;
pointer-events: none;
}
/**
* Grid
@Bobz-zg
Bobz-zg / input.scss
Created Dec 7, 2020
Generated by SassMeister.com.
View input.scss
.forms-report-service {
.span-4,
.span-12 {
margin-top: 20px;
padding-left: 10px;
padding-right: 10px;
}
.span-buttons {
text-align: right;
@Bobz-zg
Bobz-zg / input.scss
Created Dec 7, 2020
Generated by SassMeister.com.
View input.scss
.forms-report-service {
.span-4,
.span-12 {
margin-top: 20px;
padding-left: 10px;
padding-right: 10px;
}
.span-buttons {
text-align: right;
@Bobz-zg
Bobz-zg / wc-coupon-loggedin-only.php
Last active Dec 12, 2019
Set woocommerce coupon to be available only for logged in users
View wc-coupon-loggedin-only.php
<?php
add_filter( 'woocommerce_coupon_is_valid', function( $is_valid, $coupon ) {
/**
* Selected coupons allowed for logged in users only
*/
if ( in_array( $coupon->get_code() , ['loggedinonly', 'anothercoupontitle']) && ! is_user_logged_in() )
{
return false;
View terms-filter.php
<?php
/**
* Setup query
*/
// Move this on top
$args = [
'paged' => $page,
'post_type' => 'post',
@Bobz-zg
Bobz-zg / dark-mode-favicon.js
Last active Sep 18, 2020
Dark mode favicon
View dark-mode-favicon.js
/**
* HTML Markup to place in your <head> tag
* <link rel="icon" type="image/png" href="/favicon.png" data-dark="/favicon-dark.png" />
*/
// Attach listener to DOM Loaded
window.addEventListener( 'DOMContentLoaded', setFavicon );
// Set specific favicon if browser is in dark mode
function setFavicon() {