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 / 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 / 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 / stripe-charge
Last active June 9, 2016 13:52
Charge
<?php
\Stripe\Stripe::setApiKey('the_key');
// I do set this usually, but tried without it, too
\Stripe\Stripe::setApiVersion('2016-03-07');
$card = array(
'number' => '4242424242424242',
'exp_month' => 5,
@vanbo
vanbo / linnworks-change-discount-item-sku
Created June 16, 2016 13:06
Linnworks Discount Item SKU
add_filter( 'wc_linnworks_orders_discount_sku_name', 'linnworks_change_discount_item_sku' );
function linnworks_change_discount_item_sku($sku) {
// Change the SKU value by returning a new value
return 'NEW-SKU-HERE';
}
@vanbo
vanbo / borica-encryption-password-filter
Created June 30, 2016 09:23
Borica encryption password filter
add_filter( 'wc_borica_certificates_password', 'prefix_add_filter' );
function prefix_add_filter( $name ) {
return 'your-password-here';
}
@vanbo
vanbo / psigate-curl-ssl-version.php
Created June 21, 2017 09:32
psigate-curl-ssl-version
if ( ! function_exists( 'your_site_curl_ssl_v3' ) ) {
add_action( 'http_api_curl', 'your_site_curl_ssl_v3' );
function your_site_curl_ssl_v3( $handle ) {
curl_setopt($handle, CURLOPT_SSLVERSION, 1);
}
}
@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;