Skip to content

Instantly share code, notes, and snippets.

View vanbo's full-sized avatar

Ivan Andreev vanbo

View GitHub Profile
@vanbo
vanbo / wc wirecard icon filter
Last active August 29, 2015 14:08
wc wirecard icon filter
add_filter( 'woocommerce_wirecard_icon', 'wirecard_filter_gateway_icon' );
function wirecard_filter_gateway_icon( $icon ) {
$icon = 'path/to/your/gateway/icon.png';
return $icon;
}
@vanbo
vanbo / back to order in emails
Last active October 4, 2017 15:37
WC Link Back to the Order in WooCommerce New Order Emails
add_action( 'woocommerce_email_after_order_table', 'add_link_back_to_order', 10, 2 );
function add_link_back_to_order( $order, $is_admin ) {
// Only for admin emails
if ( ! $is_admin ) {
return;
}
// Open the section with a paragraph so it is separated from the other content
$link = '<p>';
@vanbo
vanbo / skip activation page on multisite
Created February 17, 2015 16:18
Skip activation page on MultiSite - Activate header
add_action( 'activate_header', 'check_activation_key_redirect_to_page' );
/**
* Check the wp-activate key and redirect the user to home page.
*/
function check_activation_key_redirect_to_page() {
// We check if the key is not empty
if ( ! empty($_GET['key']) && ! empty($_POST['key']) ) {
$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
@vanbo
vanbo / User Activation Message Hook - MultiSite
Created February 17, 2015 16:20
User Activation Message Hook - MultiSite
add_action('my_do_active_user_message_hook', 'check_header_for_active_user');
/**
* Check for the set activated user and echo a message on the home page
*/
function check_header_for_active_user() {
if ( ! session_id() ) {
session_start();
}
if ( isset($_SESSION['my_active_user_variable']) && ! empty( $_SESSION['my_active_user_variable'] ) ) {
$user = $_SESSION['my_active_user_variable'];
@vanbo
vanbo / tg-add-order-status-to-sync-list
Created April 16, 2015 15:59
Add TradeGecko Order status to Orders Sync watch list
// Use the filter to any status to the Order sync watch list.
add_filter( 'wc_tradegecko_query_orders_status', 'wc_tg_add_orders_sync_statuses' );
function wc_tg_add_orders_sync_statuses( $statuses ) {
// Here you add all statuses that you want to support.
// They should be in array format and the value should be the status slug
// For WC 2.2+ statuses are added with "wc-" prefix, like this
$statuses[] = 'wc-pending'; // for Pending Payment status
$statuses[] = 'wc-on-hold'; // for On Hold status
@vanbo
vanbo / wc-add-order-notes-to-admin-emails
Last active November 14, 2022 13:02
WooCommerce: Add Order notes to admin emails
add_action( 'woocommerce_email_order_meta', 'woo_add_order_notes_to_email', 10, 3 );
function woo_add_order_notes_to_email( $order, $sent_to_admin = true, $plain_text = false ) {
// You want to send those only to the Admin
if ( ! $sent_to_admin ) {
return;
}
// You can also check which email you are sending, by checking the order status
// Optional, comment it out, if not needed
@vanbo
vanbo / customer-order-note-html
Last active August 29, 2015 14:20
Add own HTML for Customer order note
/**
* Add the code to your theme functions.php file
*/
// Remove the order meta function from the email
remove_action( 'woocommerce_email_order_meta', array( WC()->mailer(), 'order_meta' ), 10, 3 );
// Add your own order meta function
add_action( 'woocommerce_email_order_meta', 'woo_add_order_notes_to_email', 10, 3 );
function woo_add_order_notes_to_email( $order, $sent_to_admin = true, $plain_text = false ) {
@vanbo
vanbo / get-order-item-full-product-description
Created May 30, 2015 09:02
Get order items full product description
/**
* You need the order object here.
* So we'll assume you already have it.
*
* To get the order you can call
* $order = wc_get_order( $order_id );
*/
// Get Order items
$items = $order->get_items();
@vanbo
vanbo / remove-bank-details-from-order-email.php
Last active June 3, 2023 18:11
Remove bank details from WC order email. Place in functions.php
// Add your own action for the bank instructions
add_action( 'woocommerce_email_before_order_table', 'prefix_email_instructions', 9, 3 );
function prefix_email_instructions( $order, $sent_to_admin, $plain_text = false ) {
// Get the gateway object
$gateways = WC_Payment_Gateways::instance();
$available_gateways = $gateways->get_available_payment_gateways();
$gateway = isset( $available_gateways['bacs'] ) ? $available_gateways['bacs'] : false;
// We won't do anything if the gateway is not available
if ( false == $gateway ) {
@vanbo
vanbo / paysafe-hosted-exclude-ip-address
Last active August 22, 2017 20:51
Exclude IP address from Paysafe Hosted API request
// Normal order
add_filter( 'wc_paysafe_request_params', 'prefix_remove_ip_address', 10, 2 );
// Subscriptions/Pre-Orders order
add_filter( 'wc_paysafe_addons_request_params', 'prefix_remove_ip_address', 10, 2 );
function prefix_remove_ip_address( $params, $order ) {
if ( isset( $params['customerIp'] ) ) {
unset( $params['customerIp'] );
}
return $params;