Skip to content

Instantly share code, notes, and snippets.

View torbentschechne's full-sized avatar

Torben Tschechne torbentschechne

View GitHub Profile
@torbentschechne
torbentschechne / bankdetails.php
Created March 21, 2020 19:47
WooCommerce - add bank details to email
add_action( 'woocommerce_email_after_order_table', 'custom_email_after_order_table', 10, 4 );
function custom_email_after_order_table($order, $sent_to_admin, $plain_text, $email) {
if( $order->get_payment_method() === 'bacs') {
$bacs_info = get_option('woocommerce_bacs_accounts');
if ($bacs_info) : foreach ($bacs_info as $account) :
$account_name = esc_attr(wp_unslash($account['account_name']));
$bank_name = esc_attr(wp_unslash($account['bank_name']));
$account_number = esc_attr($account['account_number']);
$sort_code = esc_attr($account['sort_code']);
@torbentschechne
torbentschechne / gist:2ff937803c482957955f1e2387410c10
Created November 1, 2019 15:14
Remove WooCommerce result count and ordering
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering',30 );
@torbentschechne
torbentschechne / gist:bfb2be3ab9bc36e6e2487966e149b707
Created November 2, 2018 09:00
Prevent e-Mails from being sent out
function childtheme_no_emails( &$phpmailer ) {
// Empty out the values that may be set
$phpmailer->ClearAllRecipients();
$phpmailer->ClearAttachments();
$phpmailer->ClearCustomHeaders();
$phpmailer->ClearReplyTos();
}
add_action( 'phpmailer_init', 'childtheme_no_emails', 99, 1 );
@torbentschechne
torbentschechne / functions.php
Created August 25, 2018 11:19 — forked from shivapoudel/functions.php
WooCommerce - Allow rendering of checkout and account pages in iframes
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'after_setup_theme', 'wc_remove_frame_options_header', 11 );
/**
* Allow rendering of checkout and account pages in iframes.
*/
@torbentschechne
torbentschechne / .php
Created August 10, 2018 14:44
Create PHP .zip file
/**
* @param array $contents
* @param bool $overwrite
* @return bool
*/
public function create_zip($contents = array(), $overwrite = false) {
$zip_filename = Shopware()->DocPath() . "files/documents" . "/jett_mce_support_".time().".zip";
if (file_exists($zip_filename) && !$overwrite) { return false; }
function iconic_variable_price_format( $price, $product ) {
$prefix = sprintf('%s: ', __('From', 'iconic'));
$min_price_regular = $product->get_variation_regular_price( 'min', true );
$min_price_sale = $product->get_variation_sale_price( 'min', true );
$max_price = $product->get_variation_price( 'max', true );
$min_price = $product->get_variation_price( 'min', true );
$price = ( $min_price_sale == $min_price_regular ) ?
function child_remove_parent_function() {
remove_action( 'woocommerce_single_product_summary', 'sf_product_share', 45);
}
add_action( 'wp_loaded', 'child_remove_parent_function' );
function custom_dequeue() {
wp_dequeue_style('default_body_font');
wp_deregister_style('default_body_font');
wp_dequeue_style('default_heading_font');
wp_deregister_style('default_heading_font');
}
add_action( 'wp_print_styles', 'custom_dequeue', 100 );
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
@torbentschechne
torbentschechne / gist:a7a7b16c0df57ec4091968b425a9c4e5
Created March 17, 2018 21:14
WooCommerce - free shipping notice
function free_shipping_cart_notice_zones() {
global $woocommerce;
// Get Free Shipping Methods for Rest of the World Zone & populate array $min_amounts
$default_zone = new WC_Shipping_Zone(0);
$default_methods = $default_zone->get_shipping_methods();
foreach( $default_methods as $key => $value ) {
if ( $value->id === "free_shipping" ) {