Skip to content

Instantly share code, notes, and snippets.

View NiklasHogefjord's full-sized avatar

Niklas Högefjord NiklasHogefjord

View GitHub Profile
@NiklasHogefjord
NiklasHogefjord / gist:fd76f7e2d4f2e6a21e8f
Created July 14, 2014 12:07
WooCommerce, DIBS Payment Gateway - Add the DIBS Transaction ID to order emails
/**
* Add the DIBS Transaction ID to order emails
**/
add_filter('woocommerce_email_order_meta_keys', 'dibs_woocommerce_email_order_meta_keys');
function dibs_woocommerce_email_order_meta_keys( $keys ) {
$keys['DIBS Transaction ID'] = 'dibs_transaction_no';
return $keys;
}
@NiklasHogefjord
NiklasHogefjord / gist:3f4a8a12462252450149
Created February 17, 2015 13:58
WooCommerce, Payson Payment Gateway - Change the Payson Direct icon in checkout
<?php
/**
* WooCommerce - Payson payment gateway
* Change the Payson Direct icon in checkout
*
**/
function myprefix_change_payson_direct_icon($logourl) {
return get_stylesheet_directory_uri(). '/images/my-payson-icon.png';
}
add_filter('payson_direct_icon', 'myprefix_change_payson_direct_icon');
@NiklasHogefjord
NiklasHogefjord / wc-custom-currency-symbol
Last active August 29, 2015 14:17
WooCommerce - custom currency symbol
add_filter('woocommerce_currency_symbol', 'my_custom_currency_symbol', 10, 2) ;
function my_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'SEK': $currency_symbol = 'SEK';
break;
}
return $currency_symbol;
}
@NiklasHogefjord
NiklasHogefjord / gist:2fe91f5fb70ee11c34e5
Created April 10, 2015 07:03
WooCommerce, DIBS Payment Gateway - Filter the payment gateway icon used in checkout
/**
* WooCommerce - DIBS payment gateway
* Filter the payment gateway icon used in checkout
*
**/
// Credit card payment method
add_filter('wc_dibs_icon_html', 'my_wc_dibs_icon_html');
function my_wc_dibs_icon_html( ) {
@NiklasHogefjord
NiklasHogefjord / wc-specter-filter-order-reference
Last active August 29, 2015 14:19
Specter for WooCommerce - Filter Customer Order Reference
/**
* Specter for WooCommerce
* Filter the Customer Order Reference sent to Specter.
* Useful when you want to pass extra order data that should be visible on the invoice or packing list sent to the customer.
* The default value of the Internal comment is the WooCommerce Order number.
*
**/
add_filter('wc_specter_order_reference', 'my_custom_order_reference');
@NiklasHogefjord
NiklasHogefjord / wc-specter-filter-internal-comment
Created April 24, 2015 09:45
Specter for WooCommerce - Filter Internal Order Comment
/**
* Specter for WooCommerce
* Filter the Internal Order Comment sent to Specter.
* Useful when you want to pass extra order data that only should be visible in Specter for you as a merchant.
* Internal Order Comment is not visible on invoices and packing lists for the customer to see.
* The default value of the Internal comment is the WooCommerce Order number.
*
**/
add_filter('wc_specter_internal_comment', 'my_custom_internal_comment');
@NiklasHogefjord
NiklasHogefjord / gist:582213ad736aac46681f
Created April 29, 2015 09:04
Klarna for WooCommerce - filter the phone number returned from Klarna (KCO)
/**
* WooCommerce - Klarna payment gateway
* Filter the phone number returned from Klarna when customer pays via Klarna Checkout.
* Useful when you want to add the country prefix to the phone number.
*
**/
add_filter('klarna_checkout_billing_phone', 'my_custom_klarna_checkout_billing_phone');
function my_custom_klarna_checkout_billing_phone( $phone_number ) {
@NiklasHogefjord
NiklasHogefjord / wc-dibs-filter-language
Created May 12, 2015 08:39
DIBS for WooCommerce - filter the language parameter sent to DIBS.
/**
* DIBS payment gateway for WooCommerce
* Filter the language parameter sent to DIBS.
* Useful when you want the language of the DIBS Payment Window to match the language in your WooCommerce store.
*
**/
add_filter( 'dibs_language', 'my_dibs_language' );
function my_dibs_language() {
@NiklasHogefjord
NiklasHogefjord / wc-dibs-filter-args
Created July 2, 2015 14:52
DIBS for WooCommerce - add acquirerinfo parameter sent to DIBS
/**
* Add an acquirerinfo parameter sent to DIBS
**/
add_filter('dibs_checkout_form', 'my_dibs_checkout_form', 10, 3);
function my_dibs_checkout_form( $args, $paytype, $order ) {
$args['acquirerinfo'] = ltrim( $order->get_order_number(), '#');
return $args;
}
@NiklasHogefjord
NiklasHogefjord / wc-specter-received-product-data
Created July 13, 2015 14:21
Save custom product data received from Specter in WooCommerce
/**
* Action hook wc_specter_received_product_data
* Save custom product data received from Specter on product updates/changes in Specters system.
*
**/
add_action( 'wc_specter_received_product_data', 'my_custom_product_update' );
function my_custom_product_update( $article ) {
// Update your product here. $article is the returned product data from Specter, stored as an array.