Skip to content

Instantly share code, notes, and snippets.

View NiklasHogefjord's full-sized avatar

Niklas Högefjord NiklasHogefjord

View GitHub Profile
@NiklasHogefjord
NiklasHogefjord / wc-securetrading-filter-billingtelephonetype.php
Last active August 29, 2015 14:24
SecureTrading for WooCommerce - Filter the billingtelephonetype
/**
* WooCommerce - SecureTrading payment gateway
* Filter the billingtelephonetype sent to SecureTrading
*
**/
add_filter('securetrading_billing_phone_type', 'my_securetrading_billing_phone_type');
function my_securetrading_billing_phone_type( ) {
// Available Phone Types are H (Home), W (Work), M (Mobile)
@NiklasHogefjord
NiklasHogefjord / wc-specter-pay-type-identifier.php
Last active October 19, 2017 12:09
Filter the payTypeIdentifier sent to Specter
/**
* Specter for WooCommerce
* Filter the payTypeIdentifier sent to Specter
*
**/
add_filter('wc_specter_pay_type_identifier', 'my_wc_specter_pay_type_identifier', 10, 2);
function my_wc_specter_pay_type_identifier( $paytype, $order_id ) {
// Switches the paytype to D (cash payment) for all orders that uses Cach on Delivery (originally paytype P in the extension) as the payment method.
@NiklasHogefjord
NiklasHogefjord / wc-securetrading-filter-version.php
Created July 21, 2015 08:47
SecureTrading for WooCommerce - Filter version sent to SecureTrading
/**
* WooCommerce - SecureTrading payment gateway
* Filter the version sent to SecureTrading
*
**/
add_filter('securetrading_version', 'my_securetrading_version');
function my_securetrading_version( ) {
// Default is 2 since version 1.5 of the plugin
/**
* WooCommerce - Klarna payment gateway
* Filter Create order & Update order for adding separate shipping address fields in Klarna Checkout iframe.
**/
// New order ($create)
add_filter('kco_create_order', 'my_kco_create_order');
function my_kco_create_order( $create ) {
$create['options']['allow_separate_shipping_address'] = true;
@NiklasHogefjord
NiklasHogefjord / wc-klarna-disable-autofocus.php
Created October 7, 2015 15:03
Klarna for WooCommerce - Filter Create order object sent to Klarna for disabling autofocus of email field
/**
* WooCommerce - Klarna payment gateway
* Filter Create order for disabling autofocus of email field.
**/
// New order ($create)
add_filter('kco_create_order', 'my_kco_create_order');
function my_kco_create_order( $create ) {
$create['gui']['options'] = array('disable_autofocus');
@NiklasHogefjord
NiklasHogefjord / klarna-checkout-extra-fields.php
Last active September 16, 2019 13:19
Add custom input fields to Klarna Checkout page. Added via shortcode [woocommerce_klarna_checkout_extra_fields]. Saved as post_meta to the order directly on .blur via ajax.
<?php
/**
* Plugin Name: Klarna Checkout Extra Fields
* Plugin URI: http://krokedil.com
* Description: Add custom input fields to Klarna Checkout page. Added via shortcode [woocommerce_klarna_checkout_extra_fields]. Saved as post_meta to the order directly on .blur via ajax.
* Version: 1.1
* Author: Krokedil
* Author URI: http://krokedil.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@NiklasHogefjord
NiklasHogefjord / modify-woocommerce-thankyou-page-for-dibs-wpml.php
Last active August 10, 2017 09:42
Adjust the url specified in WooCommerce function get_checkout_order_received_url() so that the correct thankyou page set in WPML is used. // From version 2.4.5 of the DIBS plugin this code is no longer needed. The plugin now have built in support for redirecting to the correct page if using WPML.
<?php
/*
Plugin Name: Correct thankyou page for DIBS/WPML
Plugin URI: http://krokedil.com
Description: Adjust the url specified in WooCommerce function get_checkout_order_received_url() so that the correct thankyou page set in WPML is used.
Version: 1.0
Author: Krokedil
Author URI: http://krokedil.com
*/
@NiklasHogefjord
NiklasHogefjord / wc-specter-send-custom-customer-data.php
Last active April 12, 2016 07:04
Modify customer data sent to Specter on a new order submission
<?php
/**
* Filter hook wc_specter_send_custom_customer_data
* Modify customer data sent to Specter on new order submission.
*
**/
add_filter( 'wc_specter_send_custom_customer_data', 'my_wc_specter_send_custom_customer_data', 10, 2 );
function my_wc_specter_send_custom_customer_data( $params, $order ) {
@NiklasHogefjord
NiklasHogefjord / wc-klarna-modify-kco-checkout-url.php
Last active March 3, 2016 14:46
Change checkout URL for Klarna Checkout if user isn't from a specific country. Can be useful if selling to multiple countries and you want to redirect customers that can't pay with KCO directly to the standard WooCommerce Checkout. Requires Default Customer Address to be set to Geolocate in WooCommerce settings.
<?php
/*
Plugin Name: Modify Klarna Checkout URL
Plugin URI: http://krokedil.com
Description: Change checkout URL for Klarna Checkout if user isn't from a specific country
Version: 1.0
Author: Krokedil
Author URI: http://krokedil.com
*/
add_filter( 'woocommerce_get_checkout_url', 'krokedil_change_checkout_url', 30 );
/**
* WooCommerce - Klarna payment gateway
* Filter the label for Klarna Invoice payment method, displayed in the selectbox in the description field in WooCommerce Checkout page.
**/
add_filter( 'klarna_invoice_label', 'my_klarna_invoice_label', 10, 2);
function my_klarna_invoice_label( $invoice_string, $country ) {
switch ( $country ) {
case 'DK' :