Skip to content

Instantly share code, notes, and snippets.

View mio31337's full-sized avatar
🎳
Multiprojecting

Mario Markovic mio31337

🎳
Multiprojecting
View GitHub Profile
@mio31337
mio31337 / functions.php
Last active April 8, 2020 16:56
WooCommerce: Add reference ID in BACS Payment Method - Bank Details (Displayed on confirmation E-mail and Thank You Page)
/**
* WooCommerce: Add reference ID in BACS Payment Method - Bank Details (Displayed on confirmation E-mail and Thank You Page)
* Author: MarioMarkovic.com
*/
add_filter( 'woocommerce_bacs_account_fields', 'custom_bacs_account_field', 10, 2);
function custom_bacs_account_field( $account_fields, $order_id ) {
$order = wc_get_order( $order_id );
$account_fields['reference_no' ] = array(
'label' => "Reference No.",
@mio31337
mio31337 / functions.php
Last active April 8, 2020 17:01
WooCommerce: Hide other shipping rates when free shipping is available.
/**
* Hide other shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
* Author: MarioMarkovic.com
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function hide_shipping_when_free_is_available( $rates ) {
$free = array();
@mio31337
mio31337 / functions.php
Last active April 8, 2020 17:06
WooCommerce: Add custom tabs
/**
* Add custom tabs
* Author: MarioMarkovic.com
*/
add_filter( 'woocommerce_product_tabs', 'custom_product_tabs' );
function custom_product_tabs( $tabs ) {
if(get_field('navodila_za_uporabo')) {
$tabs['general'] = array(
'title' => __('Navodila za uporabo', 'nm-framework'),
'callback' => 'product_tab_instructions_content',
@mio31337
mio31337 / functions.php
Created April 8, 2020 17:05
WooCommerce: Remove downloads tab in My Account
/**
* Remove downloads tab in My Account
* Author: MarioMarkovic.com
*/
add_filter( 'woocommerce_account_menu_items', 'custom_remove_downloads_my_account', 999 );
function custom_remove_downloads_my_account( $items ) {
unset($items['downloads']);
return $items;
}
@mio31337
mio31337 / functions.php
Last active April 14, 2020 19:27
WooCommerce: Add Product Cateogry class to body on single Product page
/**
* Add Product Cateogry class to body on single Product page
* Author: MarioMarkovic.com
*/
add_filter( 'body_class', 'wc_product_cats_css_body_class' );
function wc_product_cats_css_body_class( $classes ){
if ( is_singular( 'product' ) ) {
$current_product = wc_get_product();
$custom_terms = get_the_terms( $current_product->get_id(), 'product_cat' );
if ( $custom_terms ) {
@mio31337
mio31337 / script.js
Created October 17, 2020 17:36
WooCommerce Ajax Add to cart
(function ($) {
$.fn.serializeArrayAll = function () {
var rCRLF = /\r?\n/g;
return this.map(function () {
return this.elements ? jQuery.makeArray(this.elements) : this;
}).map(function (i, elem) {
var val = jQuery(this).val();
if (val == null) {
return val == null
//next 2 lines of code look if it is a checkbox and set the value to blank
@mio31337
mio31337 / functions.php
Last active October 17, 2022 15:16
WooCommerce: Add To: Recipient to a Customer WooCommerce Email PROCESSING AND COMPLETED
/**
* WooCommerce: Add To: Recipient to a Customer WooCommerce Email PROCESSING AND COMPLETED
* Author: MarioMarkovic.com
*/
function wc_order_completed_email_add_to( $email_recipient, $email_object, $email ) {
$email_recipient .= ', info@example.com';
return $email_recipient;
}
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'wc_order_completed_email_add_to', 9999, 3 );
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'wc_order_completed_email_add_to', 9999, 3 );
@mio31337
mio31337 / index.html
Last active January 14, 2021 15:28
Prevent mobile browsers from zooming when focusing on input field
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
// //remove emoji support
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
// // Remove rss feed links
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
// // remove wp-embed
add_action( 'wp_footer', function(){
@mio31337
mio31337 / functions.php
Created April 13, 2022 11:40
Add class if only 1 item left in stock
/**
* Add class if only 1 item left in stock
* Author: MarioMarkovic.com
*/
function filter_get_stock_html( $html, $product ) {
// Low stock quantity amount
$low_stock_qty = 1;
$availability = $product->get_availability();